From f5715d20bff1c6bc951654804307098b4ae548ed Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Mon, 26 Aug 2024 16:47:24 +0200 Subject: [PATCH] Update CI --- .github/workflows/continuous-integration.yml | 37 ++++++++------------ .github/workflows/lint.yml | 27 ++++++++++---- .github/workflows/phpstan.yml | 29 +++++---------- composer.json | 4 +-- 4 files changed, 44 insertions(+), 53 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 7bf2302e..35bc3a29 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -5,9 +5,11 @@ on: - 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" @@ -30,33 +32,22 @@ jobs: - "8.1" - "8.2" - "8.3" + - "8.4" 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: "Remove PHPStan as it requires a newer PHP" + run: composer remove phpstan/phpstan --dev --no-update - - 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: vendor/bin/simple-phpunit --verbose diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 82848976..3b5daab6 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" @@ -15,17 +18,27 @@ jobs: php-version: - "5.3" - "7.4" - - "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 f9cf1f9e..8121fe6b 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: @@ -23,30 +22,18 @@ jobs: phpunit-version-constraint: "^9.6" 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 }}" + dependency-versions: highest - name: Run PHPStan run: | - composer require --dev phpunit/phpunit:"${{ matrix.phpunit-version-constraint }}" --with-all-dependencies ${{ env.COMPOSER_FLAGS }} + composer require --dev phpunit/phpunit:"${{ matrix.phpunit-version-constraint }}" --with-all-dependencies -n vendor/bin/phpstan analyse diff --git a/composer.json b/composer.json index f3a6f4cc..1fad9e54 100644 --- a/composer.json +++ b/composer.json @@ -34,8 +34,8 @@ "php": "^5.3.2 || ^7.0 || ^8.0" }, "require-dev": { - "symfony/phpunit-bridge": "^4.2 || ^5", - "phpstan/phpstan": "^1.4" + "symfony/phpunit-bridge": "^3 || ^7", + "phpstan/phpstan": "^1.11" }, "autoload": { "psr-4": {