From 86ed063cc48584519a3c1a9bff4b7e6c70ddad22 Mon Sep 17 00:00:00 2001 From: Yoanm <4410697+yoanm@users.noreply.github.com> Date: Wed, 3 Sep 2025 10:57:12 +0200 Subject: [PATCH] Harmonize CI --- .github/workflows/CI.yml | 12 ++++ ...erge-dependabot.yml => dependabot-PRs.yml} | 5 +- .github/workflows/reusable-CI-workflow.yml | 56 +++++++++++-------- 3 files changed, 47 insertions(+), 26 deletions(-) rename .github/workflows/{auto-merge-dependabot.yml => dependabot-PRs.yml} (95%) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index b262c39..454e83f 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -7,11 +7,23 @@ on: # Build any PRs and main branch changes - opened - synchronize paths-ignore: + # >>> CI Pre-check # In case of updates to those workflows, they must be pre-checked by `pre-check-CI-updates.yml` rather than this workflow ! # Any updates on those workflows are expected to be restricted to those workflows only ! (no update on code for instance) - '.github/workflows/pre-check-CI-updates.yml' - '.github/workflows/reusable-CI-workflow.yml' - '.github/workflows/reusable-coverage-upload-workflow.yml' + # <<< CI Pre-check + # >>> Irrelevant files (no impact whatsoever on this GHWorkflow) + - '.github/workflows/coverage-upload.yml' # Executed for on master (workflow_run), no impact here + - '.github/workflows/dependabot-PRs.yml' # Executed for dependabot PRs, no impact here + - '**/*.md' + - '**/LICENSE' + - '**/CODEOWNERS' + - '**/.remarkrc*' + - '**/.editorconfig' + - '**/.scrutinizer.yml' + # <<< Irrelevant files push: branches: [ master ] schedule: diff --git a/.github/workflows/auto-merge-dependabot.yml b/.github/workflows/dependabot-PRs.yml similarity index 95% rename from .github/workflows/auto-merge-dependabot.yml rename to .github/workflows/dependabot-PRs.yml index 59465c1..edaec38 100644 --- a/.github/workflows/auto-merge-dependabot.yml +++ b/.github/workflows/dependabot-PRs.yml @@ -1,4 +1,4 @@ -name: PR auto-merge +name: Dependabot PRs on: pull_request permissions: @@ -7,11 +7,12 @@ permissions: jobs: dependabot: + name: Auto-merge & Labels + if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'yoanm/symfony-jsonrpc-http-server-doc' runs-on: ubuntu-latest permissions: contents: write pull-requests: write - if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'yoanm/symfony-jsonrpc-http-server-doc' steps: - name: Dependabot metadata id: metadata diff --git a/.github/workflows/reusable-CI-workflow.yml b/.github/workflows/reusable-CI-workflow.yml index 8c72116..4d5c60c 100644 --- a/.github/workflows/reusable-CI-workflow.yml +++ b/.github/workflows/reusable-CI-workflow.yml @@ -45,7 +45,7 @@ jobs: dependency: symfony tests: - name: ${{ matrix.job-name }} + name: PHP ${{ matrix.php-version }} & Sf ${{ matrix.symfony-version }} - ${{ matrix.job-name }} needs: [fetch-supported-versions] runs-on: ubuntu-latest permissions: @@ -61,27 +61,27 @@ jobs: php-version: '${{ needs.fetch-supported-versions.outputs.php-max }}' symfony-version: '${{ needs.fetch-supported-versions.outputs.symfony-max }}' # Fix - behat/gherkin => Avoid issue with behat <-> gherkin packages (See https://github.com/Behat/Gherkin/issues/317) - pkg-extra-constraints: behat/gherkin:~4.12.0 - - job-name: Up to date versions - Special case - Symfony 5.4 + pkg-extra-constraints: --with 'behat/gherkin:~4.12.0' + - job-name: Up to date versions - Sf 5.4 case php-version: '${{ needs.fetch-supported-versions.outputs.php-max }}' symfony-version: '5.4' # Fix - behat/gherkin => Avoid issue with behat <-> gherkin packages (See https://github.com/Behat/Gherkin/issues/317) - pkg-extra-constraints: behat/gherkin:~4.12.0 + pkg-extra-constraints: --with 'behat/gherkin:~4.12.0' - job-name: Bare minimum # => Lowest versions allowed by composer config php-version: '${{ needs.fetch-supported-versions.outputs.php-min }}' symfony-version: '${{ needs.fetch-supported-versions.outputs.symfony-min }}' - - job-name: Bare minimum - Special case - Symfony 5.4 + - job-name: Bare minimum - Sf 5.4 case php-version: '${{ needs.fetch-supported-versions.outputs.php-min }}' symfony-version: '5.4' - - job-name: Late migration - PHP # => Highest symfony version with lowest php version allowed by composer config + - job-name: Late PHP migration # => Highest symfony version with lowest php version allowed by composer config # Fix - Sf 6.4 require php 8.1 minimum ! php-version: ${{ ( needs.fetch-supported-versions.outputs.symfony-max == '6.4' && needs.fetch-supported-versions.outputs.php-min == '8.0' ) && '8.1' || needs.fetch-supported-versions.outputs.php-min }} symfony-version: '${{ needs.fetch-supported-versions.outputs.symfony-max }}' - - job-name: Late migration - Symfony # => Lowest symfony version with highest php version allowed by composer config + - job-name: Late Symfony migration # => Lowest symfony version with highest php version allowed by composer config php-version: '${{ needs.fetch-supported-versions.outputs.php-max }}' symfony-version: '${{ needs.fetch-supported-versions.outputs.symfony-min }}' # Fix - behat/gherkin => Avoid issue with behat <-> gherkin packages (See https://github.com/Behat/Gherkin/issues/317) - pkg-extra-constraints: behat/gherkin:~4.12.0 + pkg-extra-constraints: --with 'behat/gherkin:~4.12.0' steps: - name: Check out code uses: actions/checkout@v5 @@ -118,12 +118,15 @@ jobs: - name: Build with PHP ${{ steps.setup-php.outputs.php-version }} & Symfony ${{ matrix.symfony-version }} run: | + # Rely on "composer update --with" rather than "composer require" ! + # => it ensures the tested version is actually allowed by constraints + # ("composer require" would override those constraints, which may not produce something actually installable by end-user) SF_CONSTRAINT="~${{ matrix.symfony-version }}.0" - composer require -W \ - symfony/config:${SF_CONSTRAINT} \ - symfony/dependency-injection:${SF_CONSTRAINT} \ - symfony/http-foundation:${SF_CONSTRAINT} \ - symfony/http-kernel:${SF_CONSTRAINT} \ + composer update --no-install --with-all-dependencies --minimal-changes \ + --with "symfony/config:${SF_CONSTRAINT}" \ + --with "symfony/dependency-injection:${SF_CONSTRAINT}" \ + --with "symfony/http-foundation:${SF_CONSTRAINT}" \ + --with "symfony/http-kernel:${SF_CONSTRAINT}" \ ${{ matrix.pkg-extra-constraints }} \ && make build @@ -203,12 +206,15 @@ jobs: - name: Build with PHP ${{ steps.setup-php.outputs.php-version }} & Symfony ${{ env.SYMFONY_VERSION }} run: | + # Rely on "composer update --with" rather than "composer require" ! + # => it ensures the tested version is actually allowed by constraints + # ("composer require" would override those constraints, which may not produce something actually installable by end-user) SF_CONSTRAINT="~${{ env.SYMFONY_VERSION }}.0" - composer require -W \ - symfony/config:${SF_CONSTRAINT} \ - symfony/dependency-injection:${SF_CONSTRAINT} \ - symfony/http-foundation:${SF_CONSTRAINT} \ - symfony/http-kernel:${SF_CONSTRAINT} \ + composer update --no-install --with-all-dependencies --minimal-changes \ + --with "symfony/config:${SF_CONSTRAINT}" \ + --with "symfony/dependency-injection:${SF_CONSTRAINT}" \ + --with "symfony/http-foundation:${SF_CONSTRAINT}" \ + --with "symfony/http-kernel:${SF_CONSTRAINT}" \ && make build - name: ComposerRequireChecker @@ -219,7 +225,7 @@ jobs: uses: actions/dependency-review-action@v4 nightly-tests: - name: Nightly - ${{ matrix.job-name }} + name: Nightly - PHP ${{ matrix.php-version }} & Sf ${{ matrix.symfony-version }} - ${{ matrix.job-name }} needs: [ fetch-supported-versions, tests ] if: ${{ github.event_name == 'push' || ( github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'with-nightly-tests') ) }} runs-on: ubuntu-latest @@ -232,23 +238,23 @@ jobs: fail-fast: false matrix: include: - - job-name: PHP - With highest supported Symfony versions + - job-name: PHP with highest supported Symfony versions php-version: ${{ needs.fetch-supported-versions.outputs.php-next }} symfony-version: ${{ needs.fetch-supported-versions.outputs.symfony-max }} # Fix - behat/gherkin => Avoid issue with behat <-> gherkin packages (See https://github.com/Behat/Gherkin/issues/317) pkg-extra-constraints: behat/gherkin:~4.12.0 - - job-name: PHP - With lowest supported Symfony versions + - job-name: PHP with lowest supported Symfony versions php-version: ${{ needs.fetch-supported-versions.outputs.php-next }} symfony-version: ${{ needs.fetch-supported-versions.outputs.symfony-min }} # Fix - behat/gherkin => Avoid issue with behat <-> gherkin packages (See https://github.com/Behat/Gherkin/issues/317) pkg-extra-constraints: behat/gherkin:~4.12.0 - - job-name: Symfony - With highest supported PHP version + - job-name: Symfony with highest supported PHP version php-version: ${{ needs.fetch-supported-versions.outputs.php-max }} symfony-version: ${{ needs.fetch-supported-versions.outputs.symfony-next }} # Fix - behat/gherkin => Avoid issue with behat <-> gherkin packages (See https://github.com/Behat/Gherkin/issues/317) # Fix - symfony/framework-bundle - Framework bundle <7.0 require php 8.1 minimum ! pkg-extra-constraints: behat/gherkin:~4.12.0 ${{ ( needs.fetch-supported-versions.outputs.symfony-next == '7.0' && needs.fetch-supported-versions.outputs.php-max == '8.4' ) && 'symfony/framework-bundle:~7.0.0@dev' || '' }} - - job-name: Symfony - With lowest supported PHP version + - job-name: Symfony with lowest supported PHP version # Fix - Sf 7.0 require php 8.1 minimum, most of deps require 8.2 ! php-version: ${{ ( needs.fetch-supported-versions.outputs.symfony-next == '7.0' && needs.fetch-supported-versions.outputs.php-min == '8.0' ) && '8.2' || needs.fetch-supported-versions.outputs.php-min }} symfony-version: ${{ needs.fetch-supported-versions.outputs.symfony-next }} @@ -285,9 +291,11 @@ jobs: - name: Build with PHP ${{ steps.setup-php.outputs.php-version }} & Symfony ${{ matrix.symfony-version }} run: | + # For nightly builds, rely on "composer require" rather than "composer update --with" ! + # => tested version is likely outside of constraints, in that case "composer update --with" would fail SF_CONSTRAINT="~${{ matrix.symfony-version }}.0@dev" composer config minimum-stability dev \ - && composer require -W \ + && composer require --no-install --with-all-dependencies --minimal-changes \ symfony/config:${SF_CONSTRAINT} \ symfony/dependency-injection:${SF_CONSTRAINT} \ symfony/http-foundation:${SF_CONSTRAINT} \