diff --git a/.github/workflows/test-requirements-check.yml b/.github/workflows/test-requirements-check.yml index d48bcbdb51..f7de79ffb3 100644 --- a/.github/workflows/test-requirements-check.yml +++ b/.github/workflows/test-requirements-check.yml @@ -35,9 +35,10 @@ concurrency: cancel-in-progress: true jobs: - # Make sure that the files involved don't contain parse errors on the PHP versions - # supported by the requirements check to prevent the tests being run failing on the - # parse errors instead of on the requirements check (which would easily go unnoticed). + # Make sure that the files involved in the requirements check don't contain parse errors + # for the PHP versions supported by the requirements check to prevent the tests being run + # failing on the parse errors instead of on the requirements check + # (which would easily go unnoticed). lint: runs-on: ubuntu-latest @@ -66,6 +67,20 @@ jobs: - name: "Lint requirements.php" run: php -l ./requirements.php + # The matrix for these tests should be the same for the "plain" file test as for the PHAR test. + # This matrix, however, is quite complex, so maintaining it manually would be pretty error prone. + # So this job uses a PHP script to generate the matrix based on a fixed set of variables. + # + # The resulting matrix contains builds which combine the following variables: + # - os: ubuntu / windows + # - cmd: phpcs / phpcbf + # - php: 7.2 (minimum PHP version for 4.x), latest and nightly with the required extensions (should pass the check). + # - php: 5.3 (minimum for the requirements check) and 7.1 with the required extension (should fail the PHP version check). + # - php: 7.2 (minimum PHP version for 4.x), latest and nightly WITHOUT the required extension (should fail the check for extensions). + # + # Each combination also contains a "expect" key to set the expectations for success / failure. + # + # The scripts involved in generating the matrix can be found in the `/scripts/` directory. prepare-matrix: needs: lint @@ -90,6 +105,10 @@ jobs: id: set-matrix run: echo "MATRIX=$(php scripts/get-requirements-check-matrix.php)" >> "$GITHUB_OUTPUT" + - name: "DEBUG: show generated matrix" + run: echo ${{ steps.set-matrix.outputs.MATRIX }} + + # Test that the requirements check works correctly when using a Composer install or git clone of PHPCS. test-plain: needs: prepare-matrix @@ -104,9 +123,6 @@ jobs: runs-on: ${{ matrix.os }} steps: - - name: Prepare git to leave line endings alone - run: git config --global core.autocrlf input - - name: Checkout code uses: actions/checkout@v4 @@ -122,28 +138,27 @@ jobs: - name: Run the test id: check -# continue-on-error: true - run: php "bin/${{ matrix.cmd }}" ./scripts + continue-on-error: true + run: php "bin/${{ matrix.cmd }}" --version -# TEMPORARY -# - name: Check the result of a successful test against expectation -# if: ${{ steps.check.outcome == 'success' && expect == 'fail' }} -# run: exit 1 - -# - name: Check the result of a failed test against expectation -# if: ${{ steps.check.outcome != 'success' && expect == 'success' }} -# run: exit 1 + - name: Check the result of a successful test against expectation + if: ${{ steps.check.outcome == 'success' && expect == 'fail' }} + run: exit 1 + - name: Check the result of a failed test against expectation + if: ${{ steps.check.outcome != 'success' && expect == 'success' }} + run: exit 1 build-phars: needs: lint - name: "Build Phar on PHP: 8.0" + name: "Build Phar on PHP 8.0" uses: ./.github/workflows/reusable-build-phar.yml with: uploadArtifacts: true + # Test that the requirements check works correctly when using a PHPCS/PHPCBF PHAR file. test-phar: needs: [prepare-matrix, build-phars] @@ -158,9 +173,6 @@ jobs: runs-on: ${{ matrix.os }} steps: - - name: Prepare git to leave line endings alone - run: git config --global core.autocrlf input - - name: Checkout code uses: actions/checkout@v4 @@ -181,14 +193,13 @@ jobs: - name: Run the test id: check -# continue-on-error: true - run: php ${{ matrix.cmd }}.phar ./scripts + continue-on-error: true + run: php ${{ matrix.cmd }}.phar --version -# TEMPORARY -# - name: Check the result of a successful test against expectation -# if: ${{ steps.check.outcome == 'success' && expect == 'fail' }} -# run: exit 1 + - name: Check the result of a successful test against expectation + if: ${{ steps.check.outcome == 'success' && expect == 'fail' }} + run: exit 1 -# - name: Check the result of a failed test against expectation -# if: ${{ steps.check.outcome != 'success' && expect == 'success' }} -# run: exit 1 + - name: Check the result of a failed test against expectation + if: ${{ steps.check.outcome != 'success' && expect == 'success' }} + run: exit 1