From 068387cab2f88507f98051c9e3f0a10366966e8c Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 23 Aug 2024 16:36:22 +0200 Subject: [PATCH] Update CI --- .github/workflows/cacert.yml | 6 ++- .github/workflows/continuous-integration.yml | 45 ++++++++------------ .github/workflows/lint.yml | 27 +++++++++--- .github/workflows/phpstan.yml | 34 ++++----------- composer.json | 6 +-- phpunit.xml.dist | 36 ++++++---------- 6 files changed, 67 insertions(+), 87 deletions(-) diff --git a/.github/workflows/cacert.yml b/.github/workflows/cacert.yml index 545b750..14ce34e 100644 --- a/.github/workflows/cacert.yml +++ b/.github/workflows/cacert.yml @@ -5,6 +5,9 @@ on: schedule: - cron: '0 0 * * *' # Midnight - every night +permissions: + contents: read + jobs: update: strategy: @@ -14,8 +17,7 @@ jobs: runs-on: ubuntu-latest steps: - - name: "Checkout" - uses: actions/checkout@v4 + - uses: actions/checkout@v4 with: ref: ${{ matrix.branch }} diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 5c45797..adcf8b4 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -4,15 +4,15 @@ on: - push - pull_request -env: - COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist" - SYMFONY_PHPUNIT_REMOVE_RETURN_TYPEHINT: "1" +permissions: + contents: read jobs: tests: name: "CI" - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + continue-on-error: ${{ matrix.experimental }} strategy: matrix: @@ -25,33 +25,24 @@ jobs: - "8.2" - "8.3" - "8.4" + experimental: [false] + os: [ubuntu-latest] + include: + - php-version: "8.3" + os: windows-latest + experimental: false steps: - - name: "Checkout" - uses: "actions/checkout@v4" + - uses: actions/checkout@v4 - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" + - uses: shivammathur/setup-php@v2 with: - coverage: "none" php-version: "${{ matrix.php-version }}" + coverage: none - - name: Get composer cache directory - id: composercache - run: "echo \"dir=$(composer config cache-files-dir)\" >> $GITHUB_OUTPUT" - - - name: Cache dependencies - uses: actions/cache@v4 + - uses: ramsey/composer-install@v3 with: - path: ${{ steps.composercache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: ${{ runner.os }}-composer- - - - name: "Install latest dependencies" - run: | - # Remove PHPStan as it requires a newer PHP - composer remove phpstan/phpstan --dev --no-update - composer update ${{ env.COMPOSER_FLAGS }} - - - name: "Run tests" - run: "vendor/bin/simple-phpunit --verbose" + dependency-versions: highest + + - name: Run tests + run: composer test diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 10ec853..f23abf1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,6 +4,9 @@ on: - push - pull_request +permissions: + contents: read + jobs: tests: name: "Lint" @@ -14,17 +17,27 @@ jobs: matrix: php-version: - "7.2" - - "8.3" + - "nightly" steps: - - name: "Checkout" - uses: "actions/checkout@v4" + - uses: actions/checkout@v4 - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" + - uses: shivammathur/setup-php@v2 with: - coverage: "none" php-version: "${{ matrix.php-version }}" + coverage: none - name: "Lint PHP files" - run: "find src/ -type f -name '*.php' -print0 | xargs -0 -L1 -P4 -- php -l -f" + run: | + hasErrors=0 + for f in $(find src/ tests/ -type f -name '*.php' ! -path '*/vendor/*' ! -path '*/Fixtures/*') + do + { error="$(php -derror_reporting=-1 -ddisplay_errors=1 -l -f $f 2>&1 1>&3 3>&-)"; } 3>&1; + if [ "$error" != "" ]; then + while IFS= read -r line; do echo "::error file=$f::$line"; done <<< "$error" + hasErrors=1 + fi + done + if [ $hasErrors -eq 1 ]; then + exit 1 + fi diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 6253f9b..ce7db11 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -4,9 +4,8 @@ on: - push - pull_request -env: - COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist" - SYMFONY_PHPUNIT_VERSION: "" +permissions: + contents: read jobs: tests: @@ -21,31 +20,16 @@ jobs: - "8.3" steps: - - name: "Checkout" - uses: "actions/checkout@v4" + - uses: actions/checkout@v4 - - name: "Install PHP" - uses: "shivammathur/setup-php@v2" + - uses: shivammathur/setup-php@v2 with: - coverage: "none" php-version: "${{ matrix.php-version }}" + coverage: none - - name: Get composer cache directory - id: composercache - run: "echo \"dir=$(composer config cache-files-dir)\" >> $GITHUB_OUTPUT" - - - name: Cache dependencies - uses: actions/cache@v4 + - uses: ramsey/composer-install@v3 with: - path: ${{ steps.composercache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} - restore-keys: ${{ runner.os }}-composer- - - - name: "Install latest dependencies" - run: "composer update ${{ env.COMPOSER_FLAGS }}" - - - name: "Initialize PHPUnit sources" - run: "vendor/bin/simple-phpunit --filter NO_TEST_JUST_AUTOLOAD_THANKS" + dependency-versions: highest - - name: "Run PHPStan" - run: "composer phpstan" + - name: Run PHPStan + run: composer phpstan diff --git a/composer.json b/composer.json index c2ed5ac..c2ce2bb 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "php": "^7.2 || ^8.0" }, "require-dev": { - "symfony/phpunit-bridge": "^4.2 || ^5", + "phpunit/phpunit": "^8 || ^9", "phpstan/phpstan": "^1.10", "psr/log": "^1.0 || ^2.0 || ^3.0", "symfony/process": "^4.0 || ^5.0 || ^6.0 || ^7.0" @@ -48,7 +48,7 @@ } }, "scripts": { - "test": "vendor/bin/simple-phpunit", - "phpstan": "vendor/bin/phpstan analyse" + "test": "@php phpunit", + "phpstan": "@php phpstan analyse" } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 7fd4775..f3723a4 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,34 +1,24 @@ - - - - - - - + processIsolation="false" + stopOnFailure="false" + bootstrap="vendor/autoload.php" + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" +> - - ./tests/ + + ./tests/ - - - - ./src - - - - - - - - + + + ./src/ + +