ci: adopt org reusable workflows, drop intra-org SHA pin (#83) #143
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| tests: | |
| name: PHP ${{ matrix.php }} - Symfony ${{ matrix.symfony }} - Composer ${{ matrix.composer }}${{ matrix.prefer-lowest && ' (lowest)' || '' }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| php: ['8.4', '8.5'] | |
| symfony: ['5.4.*', '6.4.*', '7.4.*', '8.0.*'] | |
| composer: ['2.2', '2.9'] | |
| include: | |
| # Validate declared dependency minimums (lowest stable resolution) | |
| # against Composer LTS — catches under-constrained requires. | |
| - php: '8.4' | |
| symfony: '5.4.*' | |
| composer: '2.2' | |
| prefer-lowest: true | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@7c071dfe9dc99bdf297fa79cb49ea005b9fcadbc # v2 | |
| with: | |
| php-version: ${{ matrix.php }} | |
| tools: composer:${{ matrix.composer }} | |
| extensions: mbstring, xml, ctype, iconv | |
| coverage: none | |
| - name: Validate composer.json | |
| run: composer validate --strict | |
| - name: Get Composer cache directory | |
| id: composer-cache | |
| run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
| - name: Cache Composer packages | |
| uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5 | |
| with: | |
| path: ${{ steps.composer-cache.outputs.dir }} | |
| key: ${{ runner.os }}-php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-composer-${{ matrix.composer }}-${{ matrix.prefer-lowest && 'low' || 'high' }}-${{ hashFiles('**/composer.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-php-${{ matrix.php }}-symfony-${{ matrix.symfony }}-composer-${{ matrix.composer }}- | |
| ${{ runner.os }}-php-${{ matrix.php }}-symfony-${{ matrix.symfony }}- | |
| ${{ runner.os }}-php-${{ matrix.php }}- | |
| ${{ runner.os }}-php- | |
| - name: Install dependencies | |
| env: | |
| SYMFONY_VERSION: ${{ matrix.symfony }} | |
| UPDATE_FLAGS: ${{ matrix.prefer-lowest && '--prefer-lowest --prefer-stable' || '' }} | |
| run: | | |
| composer require "symfony/yaml:${SYMFONY_VERSION}" "symfony/console:${SYMFONY_VERSION}" --no-update --no-interaction | |
| # shellcheck disable=SC2086 | |
| composer update --prefer-dist --no-progress ${UPDATE_FLAGS} | |
| - name: Run tests (incl. @group network — GitHub + git) | |
| env: | |
| # Set to 1 only in air-gapped environments; default runs live clone tests. | |
| SKIP_NETWORK_TESTS: ${{ vars.SKIP_NETWORK_TESTS }} | |
| # The @group network tests clone PUBLIC repos and need no GitHub auth. | |
| # Clear any configured token so the composer/composer 2.2.0 library | |
| # (installed in the prefer-lowest cell) does not reject the modern | |
| # GitHub token format with "github oauth token … contains invalid | |
| # characters". The composer binary is unaffected — this only concerns | |
| # the library instantiated by the tests. | |
| COMPOSER_AUTH: "{}" | |
| GITHUB_TOKEN: "" | |
| run: | | |
| composer config --global --unset github-oauth.github.com 2>/dev/null || true | |
| vendor/bin/phpunit --testdox | |
| # PHPStan + PHP-CS-Fixer + PHPUnit-with-coverage + Codecov upload, via | |
| # the org-standard reusable. The bespoke `tests` job above stays inline | |
| # because the reusable matrices on PHP version only and cannot express | |
| # this plugin's Symfony x Composer x prefer-lowest matrix or its | |
| # network-test env. Folding these checks into the reusable removes the | |
| # per-repo codecov-action reference that Renovate kept bumping. | |
| checks: | |
| name: Checks | |
| uses: netresearch/.github/.github/workflows/php-ci.yml@main | |
| permissions: | |
| contents: read | |
| with: | |
| php-versions: '["8.4"]' | |
| extensions: "mbstring, xml, ctype, iconv" | |
| extra-tools: "php-cs-fixer" | |
| coverage: "xdebug" | |
| run-phpstan: true | |
| phpstan-cmd: "vendor/bin/phpstan analyse --error-format=github" | |
| run-cs-fixer: true | |
| cs-fixer-cmd: "php-cs-fixer fix --dry-run --diff --allow-risky=yes" | |
| run-phpunit: true | |
| phpunit-cmd: "vendor/bin/phpunit --coverage-clover=coverage.xml" | |
| upload-coverage-codecov: true | |
| coverage-php-version: "8.4" | |
| secrets: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |