From b306e422bcb0a5cc645d3f1978403eec2831fa07 Mon Sep 17 00:00:00 2001 From: Yoanm <4410697+yoanm@users.noreply.github.com> Date: Sat, 30 Aug 2025 21:45:09 +0200 Subject: [PATCH 1/2] Improve CI --- .github/workflows/reusable-CI-workflow.yml | 157 ++++++++++++--------- 1 file changed, 89 insertions(+), 68 deletions(-) diff --git a/.github/workflows/reusable-CI-workflow.yml b/.github/workflows/reusable-CI-workflow.yml index 5cc5b02d..ce79acb5 100644 --- a/.github/workflows/reusable-CI-workflow.yml +++ b/.github/workflows/reusable-CI-workflow.yml @@ -2,70 +2,88 @@ name: 'CI reusable workflow' on: workflow_call: - + inputs: + # >>>> Dummy env-inputs + # Goal here is just to have access to variable values + # in order to build job matrix as `env` variable is not available there + php-min-version: + default: '8.0' + description: Lowest PHP version to assess (e.g Lowest supported version including security support) + required: false + type: string + php-max-version: + default: '8.2' + description: Highest PHP version to assess (e.g Highest supported version) + required: false + type: string + php-next-version: + default: '8.3' + description: Next (currently not supported) PHP version to assess (e.g Current dev version) + required: false + type: string + # <<<< Dummy env-inputs env: + COMPOSER_PREFER_STABLE: '1' TEST_OUTPUT_STYLE: pretty - COMPOSER_OPTIONS: --optimize-autoloader jobs: tests: - name: PHP ${{ matrix.php-version }} + name: ${{ matrix.job-name }} runs-on: ubuntu-latest env: - COVERAGE_TYPE: xdebug + COVERAGE_TYPE: none COVERAGE_OUTPUT_STYLE: clover strategy: fail-fast: true - max-parallel: 4 matrix: include: - # Bare minimum => Lowest versions allowed by composer config - - php-version: '8.0' - composer-flag: --prefer-lowest - # Up-to-date versions => Latest versions allowed by composer config - - php-version: '8.2' + - job-name: Up to date versions # => Highest versions allowed by composer config + php-version: '${{ inputs.php-max-version }}' + - job-name: Bare minimum # => Lowest versions allowed by composer config + php-version: '${{ inputs.php-min-version }}' steps: - name: Check out code - uses: actions/checkout@v5 + uses: actions/checkout@v4 -# @TODO Figure out if coverage for every version is actually useful or not -# - name: Enable coverage -# if: ${{ matrix.php-version == '8.2' }} -# run: | -# echo "COVERAGE_OUTPUT_STYLE=clover" >> $GITHUB_ENV -# echo "COVERAGE_TYPE=xdebug" >> $GITHUB_ENV + # Enable coverage only for specific version(s) ! + # Usually highest version(s), plus additional ones in case of code used only with specific versions + - name: Enable coverage + if: ${{ matrix.php-version == inputs.php-max-version }} + run: | + echo "COVERAGE_TYPE=xdebug" >> $GITHUB_ENV - name: Setup PHP ${{ matrix.php-version }} + id: setup-php uses: shivammathur/setup-php@v2 env: - update: true # Always use latest available patch for the version + update: true # whether to use latest available patch for the version or not fail-fast: true # step will fail if an extension or tool fails to set up with: - php-version: '${{ matrix.php-version }}' + php-version: ${{ matrix.php-version }} tools: composer coverage: ${{ env.COVERAGE_TYPE }} - - name: Setup cache - id: cache + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Setup cache for PHP ${{ steps.setup-php.outputs.php-version }} uses: actions/cache@v4 with: path: | - ~/.composer - ./vendor - # Clear the cache if composer json (as composer.lock is in the repo) has been updated - key: tests-${{ matrix.php-version }}-${{ matrix.composer-flag }}-${{ hashFiles('composer.json') }} + ${{ steps.composer-cache.outputs.dir }} + # Clear the cache if composer.json (as composer.lock is not available) has been updated + key: tests-php${{ steps.setup-php.outputs.php-version }}-${{ hashFiles('composer.json') }} - - name: Build - run: | - make build + - name: Build with PHP ${{ steps.setup-php.outputs.php-version }} + run: make build - name: Tests run: make test-unit && make test-functional - - name: Create "unit tests" reports directory + - name: Create "unit tests" reports group if: ${{ env.COVERAGE_TYPE == 'xdebug' }} - id: unit-tests-coverage-group uses: yoanm/temp-reports-group-workspace/create-group@v0 with: name: unit-tests @@ -76,9 +94,8 @@ jobs: php-${{ matrix.php-version }} path: build/coverage-groups - - name: Create "functional tests" coverage group + - name: Create "functional tests" reports group if: ${{ env.COVERAGE_TYPE == 'xdebug' }} - id: functional-tests-coverage-group uses: yoanm/temp-reports-group-workspace/create-group@v0 with: name: functional-tests @@ -95,36 +112,42 @@ jobs: if: ${{ env.COVERAGE_TYPE == 'xdebug' }} uses: actions/upload-artifact@v4 with: - name: coverage-groups-php${{ matrix.php-version }} + name: coverage-groups-php${{ steps.setup-php.outputs.php-version }} path: build/coverage-groups if-no-files-found: error static-checks: name: Static analysis runs-on: ubuntu-latest + env: + PHP_VERSION: ${{ inputs.php-max-version }} steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v4 - - name: Setup PHP 8.2 + - name: Setup PHP ${{ env.PHP_VERSION }} + id: setup-php uses: shivammathur/setup-php@v2 + env: + update: true # Always use latest available patch for the version + fail-fast: true # step will fail if an extension or tool fails to set up with: - php-version: 8.2 # Latest supported + php-version: ${{ env.PHP_VERSION }} tools: composer coverage: none - env: - # Always use latest available patch for the version - update: true - - name: Setup cache - id: cache + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Setup cache for PHP ${{ steps.setup-php.outputs.php-version }} uses: actions/cache@v4 with: path: | - ~/.composer - # Clear the cache if composer json (as composer.lock is in the repo) has been updated - key: tests-${{ env.PHP_VERSION }}-${{ hashFiles('composer.json') }} + ${{ steps.composer-cache.outputs.dir }} + # Clear the cache if composer.json (as composer.lock is not available) has been updated + key: tests-php${{ steps.setup-php.outputs.php-version }}-${{ hashFiles('composer.json') }} - - name: Build + - name: Build with PHP ${{ steps.setup-php.outputs.php-version }} run: make build - name: ComposerRequireChecker @@ -135,46 +158,44 @@ jobs: uses: actions/dependency-review-action@v4 nightly-tests: - name: Nightly - PHP ${{ matrix.php-version }} + name: Nightly runs-on: ubuntu-latest env: - COMPOSER_OPTIONS: '--optimize-autoloader --ignore-platform-req=php+' + PHP_VERSION: ${{ inputs.php-next-version }} + COMPOSER_IGNORE_PLATFORM_REQ: 'php+' continue-on-error: true - needs: [ static-checks, tests ] - strategy: - fail-fast: false - max-parallel: 4 - matrix: - php-version: - - '8.3' # Current php dev version - + needs: [ tests ] steps: - name: Check out code uses: actions/checkout@v5 - - name: Setup PHP ${{ matrix.php-version }} + - name: Setup PHP ${{ env.PHP_VERSION }} + id: setup-php uses: shivammathur/setup-php@v2 + env: + update: true # whether to use latest available patch for the version or not + fail-fast: true # step will fail if an extension or tool fails to set up with: - php-version: '${{ matrix.php-version }}' + php-version: ${{ env.PHP_VERSION }} tools: composer coverage: none - env: - # Always use latest available patch for the version - update: true - - name: Setup cache - id: cache + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Setup cache for PHP ${{ steps.setup-php.outputs.php-version }} uses: actions/cache@v4 with: path: | - ~/.composer - ./vendor - # Clear the cache if composer json (as composer.lock is in the repo) has been updated - key: tests-${{ matrix.php-version }}-${{ hashFiles('composer.json') }} + ${{ steps.composer-cache.outputs.dir }} + # Clear the cache if composer.json (as composer.lock is not available) has been updated + key: tests-php${{ steps.setup-php.outputs.php-version }}-${{ hashFiles('composer.json') }} - - name: Build + - name: Build with PHP ${{ steps.setup-php.outputs.php-version }} run: | - make build + composer config minimum-stability dev \ + && make build - name: Test run: make test-unit && make test-functional From 3b608f6adb739064ac1433c147bc6c9b0fe0b5f7 Mon Sep 17 00:00:00 2001 From: Yoanm <4410697+yoanm@users.noreply.github.com> Date: Sat, 30 Aug 2025 21:48:29 +0200 Subject: [PATCH 2/2] Improve --- .github/workflows/reusable-CI-workflow.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/reusable-CI-workflow.yml b/.github/workflows/reusable-CI-workflow.yml index ce79acb5..76d6ea62 100644 --- a/.github/workflows/reusable-CI-workflow.yml +++ b/.github/workflows/reusable-CI-workflow.yml @@ -44,7 +44,7 @@ jobs: php-version: '${{ inputs.php-min-version }}' steps: - name: Check out code - uses: actions/checkout@v4 + uses: actions/checkout@v5 # Enable coverage only for specific version(s) ! # Usually highest version(s), plus additional ones in case of code used only with specific versions @@ -122,7 +122,7 @@ jobs: env: PHP_VERSION: ${{ inputs.php-max-version }} steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v5 - name: Setup PHP ${{ env.PHP_VERSION }} id: setup-php @@ -193,9 +193,7 @@ jobs: key: tests-php${{ steps.setup-php.outputs.php-version }}-${{ hashFiles('composer.json') }} - name: Build with PHP ${{ steps.setup-php.outputs.php-version }} - run: | - composer config minimum-stability dev \ - && make build + run: make build - name: Test run: make test-unit && make test-functional