Skip to content

Commit

Permalink
Bring it all together
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfnl committed Nov 30, 2024
1 parent 9406f72 commit 8c13c41
Showing 1 changed file with 35 additions and 249 deletions.
284 changes: 35 additions & 249 deletions .github/workflows/test-requirements-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ on:
- 'bin/phpcs'
- 'bin/phpcbf'
- 'requirements.php'
- 'scripts/build-phar.php'
- 'scripts/**'
pull_request:
paths:
- '.github/workflows/test-requirements-check.yml'
- '.github/workflows/reusable-build-phar.yml'
- 'bin/phpcs'
- 'bin/phpcbf'
- 'requirements.php'
- 'scripts/build-phar.php'
- 'scripts/**'

# Allow manually triggering the workflow.
workflow_dispatch:
Expand Down Expand Up @@ -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' }}

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

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

0 comments on commit 8c13c41

Please sign in to comment.