Skip to content

Commit

Permalink
run tests with PHP 7.0 to 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
deminy committed Jan 18, 2021
1 parent d802ae4 commit 77f4623
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 31 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/syntax_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Syntax Checks

on: [ push, pull_request, workflow_dispatch ]

jobs:
ci:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: ["7.0", "7.1", "7.2", "7.3", "7.4", "8.0"]

name: PHP ${{ matrix.php }}

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Run Syntax Checks
run: |
if [ ${{ matrix.php }} == '7.0' ] ; then
docker run --rm -v "$(pwd)/src:/data" -i cytopia/phplint:${{ matrix.php }}
else
docker run --rm -v "$(pwd):/project" -w /project -i jakzal/phpqa:php${{ matrix.php }} phplint src
fi
3 changes: 0 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ jobs:
sed "s/%%PHP_VERSION%%/${{ matrix.php }}/g" Dockerfile.tpl > Dockerfile
docker-compose up -d
- name: Run Syntax Checks
run: docker run --rm -v "$(pwd):/project" -w /project -i jakzal/phpqa:php${{ matrix.php }} phplint src

- name: Run Unit Tests
run: docker exec -t $(docker ps -qf "name=php") bash -c "./vendor/bin/phpunit"

Expand Down
20 changes: 0 additions & 20 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
* [2.0.0 (2021-01-17)](#200-2021-01-17)
* [1.0.2 (2021-01-17)](#102-2021-01-17)
* [1.0.1 (2019-01-14)](#101-2019-01-14)
* [Added](#added)
* [1.0.0 (2018-08-14)](#100-2018-08-14)
* [Changed](#changed)
* [0.0.2 (2018-05-31)](#002-2018-05-31)

# 2.0.0 (2021-01-17)

This release supports PHP 7.3 to 8.0. Starting from this version, PHP 7.2 and older won't be supported any more.

There is not any PHP code changes needed when upgrading from version 1 to version 2. All classes/methods are the same as
in _1.0.2_, except that more return type declarations are added.

# 1.0.2 (2021-01-17)

This release supports PHP 7.0 to 8.0. It is the last (and probably the last) stable release that supports PHP 7.0, 7.1,
and 7.2.

# 1.0.1 (2019-01-14)

## Added
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ previous request, since a lock may still be active while running background task
# Installation

```bash
composer require crowdstar/background-processing:~2.0.0 # Works under PHP 7.3 to PHP 8.0; Actively supported.
# OR,
composer require crowdstar/background-processing:~1.0.0 # Works under PHP 7.0 to PHP 8.0.
composer require crowdstar/background-processing:~1.0.0
```

# Sample Usage
Expand Down
29 changes: 24 additions & 5 deletions src/BackgroundProcessing.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ class BackgroundProcessing

/**
* @param bool $stopTiming Stop timing the current transaction or not before starting processing tasks in background
* @return void
* @throws Exception
*/
public static function run(bool $stopTiming = false): void
public static function run(bool $stopTiming = false)
{
if (self::isInvoked()) {
throw new Exception('background process invoked already');
Expand Down Expand Up @@ -76,30 +77,48 @@ public static function run(bool $stopTiming = false): void
/**
* This method should only be called by test scripts (e.g., PHPUnit tests) to reset states of this class during
* repetitive tests.
*
* @return void
*/
public static function reset(): void
public static function reset()
{
self::$closures = [];
self::$invoked = false;
}

public static function add(Closure $op, ...$params): void
/**
* @param Closure $op
* @param array ...$params
* @return void
*/
public static function add(Closure $op, ...$params)
{
self::$closures[] = function () use ($op, $params) {
return $op(...$params);
};
}

public static function addTimer(AbstractTimer $timer): void
/**
* @param AbstractTimer $timer
* @return void
*/
public static function addTimer(AbstractTimer $timer)
{
self::$timers[] = $timer;
}

protected static function setInvoked(bool $invoked): void
/**
* @param bool $invoked
* @return void
*/
protected static function setInvoked(bool $invoked)
{
self::$invoked = $invoked;
}

/**
* @return bool
*/
protected static function isInvoked(): bool
{
return self::$invoked;
Expand Down
2 changes: 2 additions & 0 deletions src/Timer/AbstractTimer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ abstract class AbstractTimer
{
/**
* Stop timing the current transaction before starting processing tasks in background.
*
* @return AbstractTimer
*/
abstract public function stopTiming(): AbstractTimer;
}

0 comments on commit 77f4623

Please sign in to comment.