Skip to content

Next iteration

Next iteration #2512

Workflow file for this run

name: Test
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:
# - '**'
paths-ignore:
- '**.md'
pull_request:
# Allow manually triggering the workflow.
workflow_dispatch:
jobs:
build:
# Cancels all previous runs of this particular job for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name, job name and the branch name.
group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }}
cancel-in-progress: true
name: "Build Phar on PHP: 8.0"
permissions:
id-token: write
contents: read
attestations: write
uses: ./.github/workflows/reusable-build-phar.yml
with:
uploadArtifacts: true
retentionDays: 28
# Only attests the build artifacts which will be used in the published releases as per the guidelines in "what to attest".
# https://docs.github.com/en/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds
createAttestations: ${{ github.ref_type == 'tag' }}
test:
# Cancels all previous runs of this particular job for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name, job name, job index and the branch name.
group: ${{ github.workflow }}-${{ github.job }}-${{ strategy.job-index }}-${{ github.ref }}
cancel-in-progress: true
runs-on: ubuntu-latest
needs: build
strategy:
# Keys:
# - custom_ini: Whether to run with specific custom ini settings to hit very specific
# code conditions.
fail-fast: false
matrix:
os: ['ubuntu-latest']
php: ['5.4', '8.1', '8.3', '8.5']
custom_ini: [false]
exclude:
# Installing on Windows with PHP 5.4 runs into all sorts of problems (which are not ours).
- php: '5.4'
os: 'windows-latest'
include:
# The default libxml library on Ubuntu images is a little out of date.
# To safeguard support for the latest libxml we need to update the library on the fly.
# This only applies to recent PHP versions (PHP 8.1+) and only needs to be tested with one
# PHP version for each libxml minor to be verify support.
# Testing against multiple PHP versions would not yield a difference in results.
- php: '8.2'
os: 'ubuntu-latest'
libxml_minor: '2.12'
- php: '8.3'
os: 'ubuntu-latest'
libxml_minor: '2.13'
# Skip test runs on builds which are also run in the coverage job.
# Note: the tests on PHP 7.2 will still be run as the coverage build uses custom_ini settings for that version.
- php: '5.4'
os: 'ubuntu-latest'
skip_tests: true
# yamllint disable-line rule:line-length
name: "PHP: ${{ matrix.php }} ${{ matrix.custom_ini && ' with custom ini settings' || '' }}${{ matrix.libxml_minor && format( ' with libxml {0}', matrix.libxml_minor ) || '' }} (${{ matrix.os == 'ubuntu-latest' && 'Linux' || 'Win' }})"
continue-on-error: ${{ matrix.php == '8.5' }}
steps:
- name: Prepare git to leave line endings alone
run: git config --global core.autocrlf input
- name: Checkout code
uses: actions/checkout@v4
# Updating the lists can fail intermittently, typically after Microsoft has released a new package.
# This should not be blocking for this job, so ignore any errors from this step.
# Ref: https://github.com/dotnet/core/issues/4167
- name: Update the available packages list
if: ${{ matrix.libxml_minor }}
continue-on-error: true
run: sudo apt-get update
- name: Find the latest relevant libxml2 tag
if: ${{ matrix.libxml_minor }}
id: libxml_version
uses: oprypin/find-latest-tag@v1
with:
repository: GNOME/libxml2
releases-only: false # This repository doesn't use GitHub's "release" feature.
prefix: 'v${{ matrix.libxml_minor }}' # Other kinds of tags are irrelevant; also limit to major version 7.
sort-tags: true # Find the greatest version based on semver.
- name: DEBUG Show found libxml release tag
if: ${{ matrix.libxml_minor }}
run: |
echo "${{ steps.libxml_version.outputs.tag }}"
- name: Get libxml patch version
id: libxml_patch_version
if: steps.libxml_version.outcome == 'success'
shell: bash
env:
TAG: ${{ steps.libxml_version.outputs.tag }}
run: echo "PATCH=${{ steps.libxml_version.outputs.tag | cut -b 2- }}" >> "$GITHUB_OUTPUT"

Check failure on line 125 in .github/workflows/test.yml

View workflow run for this annotation

GitHub Actions / Test

Invalid workflow file

The workflow is not valid. .github/workflows/test.yml (Line: 125, Col: 14): Unexpected symbol: '|'. Located at position 34 within expression: steps.libxml_version.outputs.tag | cut -b 2-
- name: DEBUG Check it
if: ${{ matrix.libxml_minor }}
run: |
echo "${{ steps.libxml_patch_version.outputs.PATCH }}"
# Once ubuntu-latest includes the latest libxml2 version, this step can be removed.
- name: Update libxml2 (linux only)
if: ${{ matrix.libxml_minor }}
run: |
sudo apt-get install -y wget build-essential
wget https://download.gnome.org/sources/libxml2/${{ matrix.libxml_minor }}/libxml2-${{ matrix.libxml_patch }}.tar.xz
tar -xf libxml2-${{ matrix.libxml_patch }}.tar.xz
cd libxml2-${{ matrix.libxml_patch }}
./configure --prefix=/usr/local
make
sudo make install
sudo ldconfig
- name: Setup ini config
id: set_ini
shell: bash
run: |
# Set the "short_open_tag" ini to make sure specific conditions are tested.
# Also turn on error_reporting to ensure all notices are shown.
if [[ ${{ matrix.custom_ini }} == true && "${{ matrix.php }}" == '5.5' ]]; then
echo 'PHP_INI=error_reporting=-1, display_errors=On, date.timezone=Australia/Sydney, short_open_tag=On, asp_tags=On' >> "$GITHUB_OUTPUT"
elif [[ ${{ matrix.custom_ini }} == true && "${{ matrix.php }}" == '7.0' ]]; then
echo 'PHP_INI=error_reporting=-1, display_errors=On, date.timezone=Australia/Sydney, short_open_tag=On' >> "$GITHUB_OUTPUT"
else
echo 'PHP_INI=error_reporting=-1, display_errors=On' >> "$GITHUB_OUTPUT"
fi
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
coverage: none
tools: cs2pr
- name: "DEBUG: show libxml loaded version (php)"
run: php -r 'echo "libxml loaded version = ", LIBXML_LOADED_VERSION, PHP_EOL;'
# 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:
composer-options: ${{ matrix.php == '8.5' && '--ignore-platform-req=php' || '' }}
custom-cache-suffix: $(date -u "+%Y-%m")
# Note: The code style check is run multiple times against every PHP version
# as it also acts as an integration test.
- name: 'PHPCS: set the path to PHP'
run: php "bin/phpcs" --config-set php_path php
- name: 'PHPUnit: run the full test suite without code coverage'
if: ${{ matrix.skip_tests != true }}
run: php "vendor/bin/phpunit" tests/AllTests.php --no-coverage
- name: 'PHPUnit: run select tests in CBF mode'
if: ${{ matrix.skip_tests != true }}
run: php "vendor/bin/phpunit" tests/AllTests.php --group CBF --exclude-group nothing --no-coverage
env:
PHP_CODESNIFFER_CBF: '1'
- name: 'PHPCS: check code style without cache, no parallel'
if: ${{ matrix.custom_ini == false && matrix.php != '7.4' }}
run: php "bin/phpcs" --no-cache --parallel=1
- name: 'PHPCS: check code style to show results in PR'
if: ${{ matrix.custom_ini == false && matrix.php == '7.4' }}
id: phpcs
run: php "bin/phpcs" --no-cache --parallel=1 --report-full --report-checkstyle=./phpcs-report.xml
- name: Show PHPCS results in PR
if: ${{ always() && steps.phpcs.outcome == 'failure' && matrix.php == '7.4' }}
run: cs2pr ./phpcs-report.xml
- name: Download the PHPCS phar
if: ${{ matrix.custom_ini == false }}
uses: actions/download-artifact@v4
with:
name: phpcs-phar
# This test specifically tests that the Phar which will be released works correctly on all PHP versions.
- name: 'PHPCS: check code style using the Phar file'
if: ${{ matrix.custom_ini == false }}
run: php phpcs.phar