diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..d4f9a74 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,45 @@ +name: Tests + +on: + workflow_dispatch: + pull_request: + push: + branches: + - master + +jobs: + tests: + runs-on: ubuntu-latest + + strategy: + matrix: + php-version: [ '8.1', '8.2' ] + + name: Run tests on PHP v${{ matrix.php-version }} + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + extensions: pcntl + + - name: Set composer cache directory + id: composer-cache + run: echo "COMPOSER_CACHE_DIRECTORY=$(composer config cache-files-dir)" >> $GITHUB_ENV + + - name: Restore composer from cache + uses: actions/cache@v3 + with: + path: ${{ env.COMPOSER_CACHE_DIRECTORY }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install composer dependencies + run: composer install --no-interaction --prefer-dist --no-progress + + - name: Run phpunit tests + run: vendor/bin/phpunit --colors=always --testdox \ No newline at end of file diff --git a/composer.json b/composer.json index 91b8198..beeab11 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,9 @@ "Aternos\\Taskmaster\\Test\\": "test/" } }, + "require": { + "php": ">=8.1" + }, "require-dev": { "phpunit/phpunit": "^10.4" }, diff --git a/composer.lock b/composer.lock index 7077358..666fe83 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6fcfb8f846ff97558723c79b9ca673a0", + "content-hash": "44485d3ef6c50b377f0caf59bc12c1f5", "packages": [], "packages-dev": [ { @@ -1626,7 +1626,9 @@ "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, - "platform": [], + "platform": { + "php": ">=8.1" + }, "platform-dev": [], "plugin-api-version": "2.6.0" } diff --git a/test/Task/SynchronizedFieldTask.php b/test/Task/SynchronizedFieldTask.php index 5225d9c..24e8ff2 100644 --- a/test/Task/SynchronizedFieldTask.php +++ b/test/Task/SynchronizedFieldTask.php @@ -32,13 +32,12 @@ public function increaseCounter(): void * @throws Throwable */ #[OnChild] - public function run(): null + public function run(): void { for ($i = 0; $i < $this->amount; $i++) { $this->increaseCounter(); $this->call($this->increaseCounter(...)); } - return null; } /**