From 7cccd8e22130d977023f001de5cc7e25f751494f Mon Sep 17 00:00:00 2001 From: Michal Sniatala Date: Wed, 18 Sep 2024 15:45:54 +0200 Subject: [PATCH] Update to PHPUnit 10 (#46) * update to phpunit 10 * fix phpunit workflow * update deptrac workflow * rector workflow update --- .github/workflows/deptrac.yml | 55 ++-------------------------------- .github/workflows/phpunit.yml | 2 +- .github/workflows/rector.yml | 15 ++++++---- .gitignore | 2 +- composer.json | 5 +++- phpunit.xml.dist | 56 ++++++++++++----------------------- rector.php | 2 -- 7 files changed, 37 insertions(+), 100 deletions(-) diff --git a/.github/workflows/deptrac.yml b/.github/workflows/deptrac.yml index c735ed2..ebaf4df 100644 --- a/.github/workflows/deptrac.yml +++ b/.github/workflows/deptrac.yml @@ -19,56 +19,5 @@ on: - '.github/workflows/deptrac.yml' jobs: - build: - name: Dependency Tracing - runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, '[ci skip]')" - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.1' - tools: phive - extensions: intl, json, mbstring, xml - coverage: none - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Get composer cache directory - run: echo "COMPOSER_CACHE_FILES_DIR=$(composer config cache-files-dir)" >> $GITHUB_ENV - - - name: Cache composer dependencies - uses: actions/cache@v4 - with: - path: ${{ env.COMPOSER_CACHE_FILES_DIR }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - - name: Create Deptrac cache directory - run: mkdir -p build/ - - - name: Cache Deptrac results - uses: actions/cache@v4 - with: - path: build - key: ${{ runner.os }}-deptrac-${{ github.sha }} - restore-keys: ${{ runner.os }}-deptrac- - - - name: Install dependencies - run: | - if [ -f composer.lock ]; then - composer install --no-progress --no-interaction --prefer-dist --optimize-autoloader - else - composer update --no-progress --no-interaction --prefer-dist --optimize-autoloader - fi - - - name: Trace dependencies - run: | - sudo phive --no-progress install --global --trust-gpg-keys B8F640134AB1782E,A98E898BB53EB748 qossmic/deptrac - deptrac analyze --cache-file=build/deptrac.cache - env: - GITHUB_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + deptrac: + uses: codeigniter4/.github/.github/workflows/deptrac.yml@main diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index d5b141d..f2b9a10 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -72,7 +72,7 @@ jobs: fi - name: Test with PHPUnit - run: vendor/bin/phpunit --verbose --coverage-text + run: vendor/bin/phpunit --coverage-text env: TERM: xterm-256color TACHYCARDIA_MONITOR_GA: enabled diff --git a/.github/workflows/rector.yml b/.github/workflows/rector.yml index 7530d1a..cab67ce 100644 --- a/.github/workflows/rector.yml +++ b/.github/workflows/rector.yml @@ -18,15 +18,22 @@ on: - 'rector.php' - '.github/workflows/rector.yml' +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read + jobs: build: name: PHP ${{ matrix.php-versions }} Rector Analysis runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, '[ci skip]')" + if: (! contains(github.event.head_commit.message, '[ci skip]')) strategy: fail-fast: false matrix: - php-versions: ['8.1', '8.2'] + php-versions: ['8.1', '8.3'] steps: - name: Checkout @@ -61,6 +68,4 @@ jobs: fi - name: Analyze for refactoring - run: | - composer global require --dev rector/rector:^0.19.5 - rector process --dry-run --no-progress-bar + run: vendor/bin/rector process --dry-run --no-progress-bar diff --git a/.gitignore b/.gitignore index 74c6d0c..8a589c5 100644 --- a/.gitignore +++ b/.gitignore @@ -126,5 +126,5 @@ nb-configuration.xml /results/ /phpunit*.xml /.phpunit.*.cache - +/.phpunit.cache /.php-cs-fixer.php diff --git a/composer.json b/composer.json index 59acaa0..2c843ff 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,10 @@ "autoload": { "psr-4": { "CodeIgniter\\Queue\\": "src" - } + }, + "exclude-from-classmap": [ + "**/Database/Migrations/**" + ] }, "autoload-dev": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 8b5daca..927d60a 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,15 +1,10 @@ + cacheDirectory=".phpunit.cache" + beStrictAboutCoverageMetadata="true"> - - - ./src/ - - - ./src/Commands/Generators - ./src/Commands/Utils - ./src/Config - + @@ -44,27 +32,11 @@ - - - - - 0.50 - - - 30 - - - 2 - - - true - - - true - - - - + + + + + @@ -100,4 +72,14 @@ --> + + + ./src/ + + + ./src/Commands/Generators + ./src/Commands/Utils + ./src/Config + + diff --git a/rector.php b/rector.php index 5480c51..68f6940 100644 --- a/rector.php +++ b/rector.php @@ -27,7 +27,6 @@ use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector; use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector; use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector; -use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector; use Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector; use Rector\PHPUnit\AnnotationsToAttributes\Rector\Class_\AnnotationWithValueToAttributeRector; use Rector\PHPUnit\AnnotationsToAttributes\Rector\ClassMethod\DataProviderAnnotationToAttributeRector; @@ -82,7 +81,6 @@ $rectorConfig->skip([ __DIR__ . '/app/Views', - JsonThrowOnErrorRector::class, StringifyStrNeedlesRector::class, YieldDataProviderRector::class,