From ef7e0af881a30f0520cb12d8977b77d57a9f3a95 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 28 Aug 2024 10:45:41 +0200 Subject: [PATCH] Update CI --- .github/workflows/continuous-integration.yml | 36 +++++++------------- .github/workflows/lint.yml | 33 ++++++++++++------ .github/workflows/phpstan.yml | 26 ++++---------- 3 files changed, 41 insertions(+), 54 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index e89d10d..138577a 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -4,8 +4,8 @@ on: - push - pull_request -env: - COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist" +permissions: + contents: read jobs: tests: @@ -31,31 +31,19 @@ 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: "Remove PHPStan as it requires a newer PHP" + run: composer remove phpstan/phpstan --dev --no-update - - name: Cache dependencies - uses: actions/cache@v3 + - 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: "composer test" + dependency-versions: highest + + - name: Run tests + run: composer test diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9742671..d01ff2f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,8 +1,11 @@ name: "PHP Lint" on: - push: - pull_request: + - push + - pull_request + +permissions: + contents: read jobs: tests: @@ -14,19 +17,27 @@ jobs: matrix: php-version: - "5.3" - - "7.4" + - "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" - extensions: "intl" - ini-values: "memory_limit=-1" 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 503e11c..86b443f 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -4,8 +4,8 @@ on: - push - pull_request -env: - COMPOSER_FLAGS: "--ansi --no-interaction --no-progress --prefer-dist" +permissions: + contents: read jobs: tests: @@ -19,28 +19,16 @@ jobs: - "8.0" 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@v3 + - 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 phpstan