Skip to content

Commit

Permalink
ADD TO: workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfnl committed Nov 30, 2024
1 parent 605e5a9 commit a49ac45
Showing 1 changed file with 40 additions and 29 deletions.
69 changes: 40 additions & 29 deletions .github/workflows/test-requirements-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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' && matrix.expect == 'fail' }}
run: exit 1

- name: Check the result of a failed test against expectation
if: ${{ steps.check.outcome != 'success' && matrix.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]

Expand All @@ -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

Expand All @@ -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' && matrix.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' && matrix.expect == 'success' }}
run: exit 1

0 comments on commit a49ac45

Please sign in to comment.