From 8c13c41c2a13fbcf7acf61fe174fcc064efdaedf Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 30 Nov 2024 20:42:16 +0100 Subject: [PATCH] Bring it all together --- .github/workflows/test-requirements-check.yml | 284 +++--------------- 1 file changed, 35 insertions(+), 249 deletions(-) diff --git a/.github/workflows/test-requirements-check.yml b/.github/workflows/test-requirements-check.yml index 538b577671..13c8641f7e 100644 --- a/.github/workflows/test-requirements-check.yml +++ b/.github/workflows/test-requirements-check.yml @@ -15,7 +15,7 @@ on: - 'bin/phpcs' - 'bin/phpcbf' - 'requirements.php' - - 'scripts/build-phar.php' + - 'scripts/**' pull_request: paths: - '.github/workflows/test-requirements-check.yml' @@ -23,7 +23,7 @@ on: - 'bin/phpcs' - 'bin/phpcbf' - 'requirements.php' - - 'scripts/build-phar.php' + - 'scripts/**' # Allow manually triggering the workflow. workflow_dispatch: @@ -66,134 +66,28 @@ jobs: - name: "Lint requirements.php" run: php -l ./requirements.php - build: - name: "Build Phar on PHP: 8.0" + prepare-matrix: + needs: lint - uses: ./.github/workflows/reusable-build-phar.yml - with: - uploadArtifacts: true + name: Get test matrix + runs-on: ubuntu-latest - test-plain: - needs: lint -# if: ${{ needs.prepare-matrix.outputs.matrix != '' }} + outputs: + matrix: ${{ steps.set-matrix.outputs.MATRIX }} + + steps: + - name: Set matrix + id: set-matrix + run: echo "MATRIX=$(php scripts/get-requirements-check-matrix.php)" >> "$GITHUB_OUTPUT" -# strategy: -# fail-fast: false -# matrix: -# os: ['ubuntu-latest', 'windows-latest'] -# cmd: ['phpcs', 'phpcbf'] -# include: ${{ fromJson(needs.prepare-matrix.outputs.matrix_include) }} + test-plain: + needs: prepare-matrix strategy: fail-fast: false - matrix: - os: ['ubuntu-latest', 'windows-latest'] - cmd: ['phpcs', 'phpcbf'] - php: ['7.2', 'latest', 'nightly'] - extensions: [''] - - include: - # Test runs where the requirements check should pass. - - name: "extensions: default, expected: success" - expected: 'success' - - # Test runs where only the _minimum_ extension requirements are met should pass. - - name: "extensions: minimal, expected: success" - extensions: 'none, tokenizer, xmlwriter, SimpleXML' - expected: 'success' - - # Test failing the requirements check when the PHP version is too low. - - name: "PHP 5.3, fail on PHP too low" - os: 'ubuntu-latest' - cmd: 'phpcs' - php: '5.3' - extensions: '' - expected: 'fail' - - - name: "PHP 5.3, fail on PHP too low" - os: 'windows-latest' - cmd: 'phpcs' - php: '5.3' - extensions: '' - expected: 'fail' - - - name: "PHP 5.3, fail on PHP too low" - os: 'ubuntu-latest' - cmd: 'phpcbf' - php: '5.3' - extensions: '' - expected: 'fail' - - - name: "PHP 5.3, fail on PHP too low" - os: 'windows-latest' - cmd: 'phpcbf' - php: '5.3' - extensions: '' - expected: 'fail' - - - name: "PHP 7.1, fail on PHP too low" - os: 'ubuntu-latest' - cmd: 'phpcs' - php: '7.1' - extensions: '' - expected: 'fail' - - - name: "PHP 7.1, fail on PHP too low" - os: 'windows-latest' - cmd: 'phpcs' - php: '7.1' - extensions: '' - expected: 'fail' - - - name: "PHP 7.1, fail on PHP too low" - os: 'ubuntu-latest' - cmd: 'phpcbf' - php: '7.1' - extensions: '' - expected: 'fail' - - - name: "PHP 7.1, fail on PHP too low" - os: 'windows-latest' - cmd: 'phpcbf' - php: '7.1' - extensions: '' - expected: 'fail' - - - # Test failing the requirements check when a required extension is missing. - # Note: there are no tests disabling the tokenizer extension as it is impossible to disable - # as it is not a shared extension. - -# - name: "PHP 7.2, fail on missing tokenizer" -# php: '7.2' -# extensions: ':tokenizer' -# expected: 'fail' -# - name: "PHP latest, fail on missing tokenizer" -# php: 'latest' -# extensions: ':tokenizer' -# expected: 'fail' - -# TRY THIS, though probably won't work. - - name: "fail on missing tokenizer" - extensions: 'none, xmlwriter, SimpleXML' - expected: 'fail' - - - name: "fail on missing xmlwriter" - extensions: ':xmlwriter' - expected: 'fail' - - - name: "fail on missing SimpleXML" - extensions: ':SimpleXML' - expected: 'fail' - - - name: "fail on missing both required XML extensions" - extensions: ':xmlwriter, :SimpleXML' - expected: 'fail' - - - # yamllint disable-line rule:line-length -# TODO - name: "Plain: ${{ matrix.cmd }} PHP ${{ matrix.php }} (${{ matrix.os == 'ubuntu-latest' && 'Linux' || 'Win' }}) ${{ matrix.name }}" + matrix: ${{ fromJson(needs.prepare-matrix.outputs.matrix) }} + + name: "Plain: ${{ matrix.cmd }} PHP ${{ matrix.php }} (${{ matrix.os == 'ubuntu-latest' && 'nix' || 'Win' }}) ${{ matrix.name }}" continue-on-error: ${{ matrix.php == 'nightly' }} @@ -220,139 +114,31 @@ jobs: # TEMPORARY # - name: Check the result of a successful test against expectation -# if: ${{ steps.check.outcome == 'success' && expected == 'fail' }} +# 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' && expected == 'success' }} +# if: ${{ steps.check.outcome != 'success' && expect == 'success' }} # run: exit 1 - test-phar: - needs: [lint, build] -# if: ${{ needs.prepare-matrix.outputs.matrix != '' }} + build-phars: + needs: lint + + name: "Build Phar on PHP: 8.0" + + uses: ./.github/workflows/reusable-build-phar.yml + with: + uploadArtifacts: true -# strategy: -# fail-fast: false -# matrix: ${{ fromJson(needs.prepare-matrix.outputs.matrix) }} + test-phar: + needs: [prepare-matrix, build-phars] strategy: fail-fast: false - matrix: - os: ['ubuntu-latest', 'windows-latest'] - cmd: ['phpcs', 'phpcbf'] - - include: - # Test runs where the requirements check should pass. - - name: "PHP 7.2, extensions: default, expected: success" - php: '7.2' - extensions: '' - expected: 'success' - - - name: "PHP latest, extensions: default, expected: success" - php: 'latest' - extensions: '' - expected: 'success' - - # This test _should_ pass, but is allowed to continue-on-error in the actual workflows. - - name: "PHP nightly, extensions: default, expected: success" - php: 'nightly' - extensions: '' - expected: 'success' - - - # Test runs where only the _minimum_ extension requirements are met should pass. - - name: "PHP 7.2, extensions: minimal, expected: success" - php: '7.2' - extensions: 'none, tokenizer, xmlwriter, SimpleXML' - expected: 'success' - - - name: "PHP latest, extensions: minimal, expected: success" - php: 'latest' - extensions: 'none, tokenizer, xmlwriter, SimpleXML' - expected: 'success' - - # This test _should_ pass, but is allowed to continue-on-error in the actual workflows. - - name: "PHP nightly, extensions: minimal, expected: success" - php: 'nightly' - extensions: 'none, tokenizer, xmlwriter, SimpleXML' - expected: 'success' - - - # Test failing the requirements check when the PHP version is too low. - - name: "PHP 5.3, fail on PHP too low" - php: '5.3' - extensions: '' - expected: 'fail' - - - name: "PHP 7.1, fail on PHP too low" - php: '7.1' - extensions: '' - expected: 'fail' - - - # Test failing the requirements check when a required extension is missing. - # Note: there are no tests disabling the tokenizer extension as it is impossible to disable - # as it is not a shared extension. - -# - name: "PHP 7.2, fail on missing tokenizer" -# php: '7.2' -# extensions: ':tokenizer' -# expected: 'fail' -# - name: "PHP latest, fail on missing tokenizer" -# php: 'latest' -# extensions: ':tokenizer' -# expected: 'fail' - -# TRY THIS, though probably won't work. - - name: "PHP 7.2, fail on missing tokenizer" - php: '7.2' - extensions: 'none, xmlwriter, SimpleXML' - expected: 'fail' - - name: "PHP latest, fail on missing tokenizer" - php: 'latest' - extensions: 'none, xmlwriter, SimpleXML' - expected: 'fail' - - - name: "PHP 7.2, fail on missing tokenizer" - php: '7.2' - extensions: ':tokenizer' - expected: 'fail' - - name: "PHP latest, fail on missing tokenizer" - php: 'latest' - extensions: ':tokenizer' - expected: 'fail' - - - name: "PHP 7.2, fail on missing xmlwriter" - php: '7.2' - extensions: ':xmlwriter' - expected: 'fail' - - name: "PHP latest, fail on missing xmlwriter" - php: 'latest' - extensions: ':xmlwriter' - expected: 'fail' - - - name: "PHP 7.2, fail on missing SimpleXML" - php: '7.2' - extensions: ':SimpleXML' - expected: 'fail' - - name: "PHP latest, fail on missing SimpleXML" - php: 'latest' - extensions: ':SimpleXML' - expected: 'fail' - - - name: "PHP 7.2, fail on missing required XML extensions" - php: '7.2' - extensions: ':xmlwriter, :SimpleXML' - expected: 'fail' - - name: "PHP latest, fail on missing required XML extensions" - php: 'latest' - extensions: ':xmlwriter, :SimpleXML' - expected: 'fail' - - # yamllint disable-line rule:line-length -# TODO - name: "PHAR: ${{ matrix.cmd }} (${{ matrix.os == 'ubuntu-latest' && 'Linux' || 'Win' }}) ${{ matrix.name }}" + matrix: ${{ fromJson(needs.prepare-matrix.outputs.matrix) }} + + name: "PHAR: ${{ matrix.cmd }} PHP ${{ matrix.php }} (${{ matrix.os == 'ubuntu-latest' && 'nix' || 'Win' }}) ${{ matrix.name }}" continue-on-error: ${{ matrix.php == 'nightly' }} @@ -384,9 +170,9 @@ jobs: # TEMPORARY # - name: Check the result of a successful test against expectation -# if: ${{ steps.check.outcome == 'success' && expected == 'fail' }} +# 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' && expected == 'success' }} +# if: ${{ steps.check.outcome != 'success' && expect == 'success' }} # run: exit 1