Skip to content

build: add description for the generate-docs script. #16

build: add description for the generate-docs script.

build: add description for the generate-docs script. #16

Workflow file for this run

name: Unit Tests
on:
# Run on pushes to `master` and on all pull requests.
push:
branches:
- master
paths-ignore:
- "**.md"
- "**.xml"
pull_request:
# Allow manually triggering the workflow.
workflow_dispatch:
# Cancels all previous workflow runs for the same branch that have not yet completed.
concurrency:
# The concurrency group contains the workflow name and the branch name.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
if: ${{ github.ref == 'refs/heads/master' }}
runs-on: ubuntu-latest
strategy:
matrix:
php: ["7.2", "7.4", "8.0", "8.2", "8.4"]
name: "Lint: PHP ${{ matrix.php }}"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-file: "development"
coverage: none
tools: cs2pr
- 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: "Lint against parse errors"
run: composer lint -- --checkstyle | cs2pr
#### TEST STAGE ####
test:
if: ${{ github.ref == 'refs/heads/master' }}
runs-on: ubuntu-latest
strategy:
matrix:
# The GHA matrix works different from Travis.
# You can define jobs here and then augment them with extra variables in `include`,
# as well as add extra jobs in `include`.
# @link https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix
#
# The matrix is set up so as not to duplicate the builds which are run for code coverage.
php: ["7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4"]
phpcs_version: ["4.x-dev"]
name: "Test: PHP ${{ matrix.php }}"
steps:
- name: Checkout code
uses: actions/checkout@v4
# On stable PHPCS versions, allow for PHP deprecation notices.
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
- name: Setup ini config
id: set_ini
run: |
if [[ "${{ contains( matrix.phpcs_version, 'dev') }}" == "false" ]]; then
echo 'PHP_INI=error_reporting=E_ALL & ~E_DEPRECATED, display_errors=On, display_startup_errors=On' >> "$GITHUB_OUTPUT"
else
echo 'PHP_INI=error_reporting=-1, display_errors=On, display_startup_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
# 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: Composer info
run: composer info
- name: Grab PHPUnit version
id: phpunit_version
run: echo "VERSION=$(vendor/bin/phpunit --version | grep --only-matching --max-count=1 --extended-regexp '\b[0-9]+\.[0-9]+')" >> "$GITHUB_OUTPUT"
- name: "DEBUG: Show grabbed PHPUnit version"
run: echo ${{ steps.phpunit_version.outputs.VERSION }}
- name: Determine PHPUnit config file to use
id: phpunit_config
shell: bash
run: |
if [ "${{ startsWith( steps.phpunit_version.outputs.VERSION, '11.' ) }}" == "true" ]; then
echo 'FILE=phpunit.xml' >> "$GITHUB_OUTPUT"
elif [ "${{ startsWith( steps.phpunit_version.outputs.VERSION, '10.' ) }}" == "true" ]; then
echo 'FILE=phpunit.xml' >> "$GITHUB_OUTPUT"
else
echo 'FILE=phpunit-lte9.xml' >> "$GITHUB_OUTPUT"
fi
- name: Run the unit tests
run: composer test -- -c ${{ steps.phpunit_config.outputs.FILE }}
env:
PHPCS_VERSION: ${{ matrix.phpcs_version }}