Skip to content

Commit

Permalink
TEMP/TESTING - slim down the build
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfnl committed Feb 5, 2025
1 parent 872f8f8 commit 94315c5
Showing 1 changed file with 6 additions and 176 deletions.
182 changes: 6 additions & 176 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ on:
# Run on pushes to `master` and on all pull requests.
# Prevent the build from running when there are only irrelevant changes.
push:
branches:
- master
tags:
- '**'
# branches:
# - master
# tags:
# - '**'
paths-ignore:
- '**.md'
pull_request:
Expand Down Expand Up @@ -51,9 +51,10 @@ jobs:
# Keys:
# - custom_ini: Whether to run with specific custom ini settings to hit very specific
# code conditions.
fail-fast: false
matrix:
os: ['ubuntu-latest', 'windows-latest']
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
php: ['5.4', '8.1', '8.2', '8.3', '8.4', '8.5']
custom_ini: [false]

exclude:
Expand All @@ -67,20 +68,9 @@ jobs:
- php: '5.4'
os: 'ubuntu-latest'
skip_tests: true
- php: '5.5'
os: 'windows-latest'
skip_tests: true
- php: '8.4'
skip_tests: true

# Extra builds running only the unit tests with different PHP ini settings.
- php: '5.5'
os: 'ubuntu-latest'
custom_ini: true
- php: '7.0'
os: 'ubuntu-latest'
custom_ini: true

# yamllint disable-line rule:line-length
name: "PHP: ${{ matrix.php }} ${{ matrix.custom_ini && ' with custom ini settings' || '' }} (${{ matrix.os == 'ubuntu-latest' && 'Linux' || 'Win' }})"

Expand Down Expand Up @@ -183,163 +173,3 @@ jobs:
- name: 'PHPCS: check code style using the Phar file'
if: ${{ matrix.custom_ini == false }}
run: php phpcs.phar

coverage:
# Explicitly *NOT* setting "concurrency" for this job to allow for monitoring code coverage for all merges.

runs-on: ${{ matrix.os }}

strategy:
matrix:
os: ['ubuntu-latest', 'windows-latest']
php: ['8.4']
custom_ini: [false]

include:
- php: '5.4'
os: 'ubuntu-latest'
custom_ini: false
# Installing on Windows with PHP 5.4 runs into all sorts of problems with Composer.
# Considering PHP 5.4 is ancient, I deem it acceptable to run coverage on Windows on PHP 5.5.
# See this issue for more context (yes, I've seen this problem before):
# @link https://github.com/PHPCSStandards/composer-installer/pull/213
- php: '5.5'
os: 'windows-latest'
custom_ini: false

# Also run one coverage build with custom ini settings.
- php: '7.2'
os: 'ubuntu-latest'
custom_ini: true

# yamllint disable-line rule:line-length
name: "Coverage: ${{ matrix.php }} ${{ matrix.custom_ini && ' with custom ini settings' || '' }} (${{ matrix.os == 'ubuntu-latest' && 'Linux' || 'Win' }})"

steps:
- name: Prepare git to leave line endings alone
run: git config --global core.autocrlf input

- name: Checkout code
uses: actions/checkout@v4

- name: Setup ini config
if: ${{ matrix.os != 'windows-latest' }}
id: set_ini
shell: bash
run: |
# Set the "short_open_tag" ini to make sure specific conditions are tested.
if [[ ${{ matrix.custom_ini }} == true && "${{ matrix.php }}" == '7.2' ]]; then
echo 'PHP_INI=, date.timezone=Australia/Sydney, short_open_tag=On' >> "$GITHUB_OUTPUT"
fi
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: error_reporting=-1, display_errors=On${{ steps.set_ini.outputs.PHP_INI }}
coverage: xdebug

# This action also handles the caching of the dependencies.
- name: Set up node
if: ${{ matrix.custom_ini == false }}
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install external tools used in tests
if: ${{ matrix.custom_ini == false }}
run: >
npm install -g --fund false
csslint
eslint
jshint
# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
- name: Install Composer dependencies
uses: "ramsey/composer-install@v3"
with:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")

- name: Grab PHPUnit version
id: phpunit_version
shell: bash
# yamllint disable-line rule:line-length
run: echo "VERSION=$(php "vendor/bin/phpunit" --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> "$GITHUB_OUTPUT"

- name: "DEBUG: Show grabbed version"
run: echo ${{ steps.phpunit_version.outputs.VERSION }}

- name: 'PHPCS: set the path to PHP'
run: php "bin/phpcs" --config-set php_path php

# PHPUnit 9.3 started using PHP-Parser for code coverage, which can cause issues due to Parser
# also polyfilling PHP tokens.
# As of PHPUnit 9.3.4, a cache warming option is available.
# Using that option prevents issues with PHP-Parser backfilling PHP tokens during our test runs.
- name: "Warm the PHPUnit cache (PHPUnit 9.3+)"
if: ${{ steps.phpunit_version.outputs.VERSION >= '9.3' }}
run: php "vendor/bin/phpunit" --coverage-cache ./build/phpunit-cache --warm-coverage-cache

- name: "Run the unit tests with code coverage (PHPUnit < 9.3)"
if: ${{ matrix.os != 'windows-latest' && steps.phpunit_version.outputs.VERSION < '9.3' }}
run: php "vendor/bin/phpunit" tests/AllTests.php

- name: "Run the unit tests with code coverage (PHPUnit 9.3+)"
if: ${{ matrix.os != 'windows-latest' && steps.phpunit_version.outputs.VERSION >= '9.3' }}
run: php "vendor/bin/phpunit" tests/AllTests.php --coverage-cache ./build/phpunit-cache

- name: "Run select tests in CBF mode with code coverage (PHPUnit < 9.3)"
if: ${{ matrix.os != 'windows-latest' && steps.phpunit_version.outputs.VERSION < '9.3' }}
run: >
php "vendor/bin/phpunit" tests/AllTests.php
--group CBF --exclude-group nothing --coverage-clover build/logs/clover-cbf.xml
env:
PHP_CODESNIFFER_CBF: '1'

- name: "Run select tests in CBF mode with code coverage (PHPUnit 9.3+)"
if: ${{ matrix.os != 'windows-latest' && steps.phpunit_version.outputs.VERSION >= '9.3' }}
run: >
php "vendor/bin/phpunit" tests/AllTests.php --coverage-cache ./build/phpunit-cache
--group CBF --exclude-group nothing --coverage-clover build/logs/clover-cbf.xml
env:
PHP_CODESNIFFER_CBF: '1'

- name: "Run the unit tests which may have different outcomes on Windows with code coverage (PHPUnit < 9.3)"
if: ${{ matrix.os == 'windows-latest' && steps.phpunit_version.outputs.VERSION < '9.3' }}
run: php "vendor/bin/phpunit" tests/AllTests.php --group Windows

- name: "Run the unit tests which may have different outcomes on Windows with code coverage (PHPUnit 9.3+)"
if: ${{ matrix.os == 'windows-latest' && steps.phpunit_version.outputs.VERSION >= '9.3' }}
run: php "vendor/bin/phpunit" tests/AllTests.php --group Windows --coverage-cache ./build/phpunit-cache

- name: "Upload coverage results to Coveralls (normal run)"
if: ${{ success() }}
uses: coverallsapp/github-action@v2
with:
format: clover
file: build/logs/clover.xml
flag-name: os-${{ matrix.os }}-php-${{ matrix.php }}-custom-ini-${{ matrix.custom_ini }}
parallel: true

- name: "Upload coverage results to Coveralls (CBF run)"
if: ${{ matrix.os != 'windows-latest' && success() }}
uses: coverallsapp/github-action@v2
with:
format: clover
file: build/logs/clover-cbf.xml
flag-name: cbf-os-${{ matrix.os }}-ubuntu-latest-php-${{ matrix.php }}-custom-ini-${{ matrix.custom_ini }}
parallel: true

coveralls-finish:
needs: coverage
if: always() && needs.coverage.result == 'success'

runs-on: ubuntu-latest

steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
parallel-finished: true

0 comments on commit 94315c5

Please sign in to comment.