Skip to content

Commit

Permalink
CI: switch to GitHub Actions - step 3: test stage
Browse files Browse the repository at this point in the history
This commit:
* Adds a GH Actions workflow for the CI checks which were previously run on Travis in the `test` stage.
* Removes the, now redundant, `.travis.yml` configuration.
* Updates the `.gitattributes` file.

Notes:
1. Previously, this "stage" would run on all `pull requests` events.
    The current set-up still does so, with one addition: pushes to `master` (merges) will now also use this workflow instead of the quicktest.
    This replaces the full run on tagging a release, meaning that things will essentially be the same.
2. As there are a couple of jobs which are "allowed to fail" (`experimental` = true), the build status may unfortunately show as "failed", even though all non-experimental jobs have succeeded.
     This is a known issue in GHA: https://github.com/actions/toolkit/issues/399
  • Loading branch information
jrfnl committed Jun 19, 2021
1 parent de656d3 commit dbe7f42
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 119 deletions.
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
/.gitignore export-ignore
/.phpcs.xml export-ignore
/.phpcs.xml.dist export-ignore
/.travis.yml export-ignore
/phpcs.xml export-ignore
/phpcs.xml.dist export-ignore
/phpunit.xml export-ignore
Expand Down
133 changes: 133 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: Test

on:
# Run on pushes to `master` and on all pull requests.
push:
branches:
- master
paths-ignore:
- '**.md'
pull_request:
# Allow manually triggering the workflow.
workflow_dispatch:

jobs:
#### TEST STAGE ####
test:
runs-on: ubuntu-latest

strategy:
# Keys:
# - experimental: Whether the build is "allowed to fail".
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
#
# Note: while WPCS 3.0.0 is under development, the matrix will use `dev-master`.
# Once it has been released and YoastCS has been made compatible, the matrix should switch (back)
# WPCS `dev-master` to `dev-develop`.
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
phpcs_version: ['3.6.0', 'dev-master']
wpcs_version: ['2.3.0', 'dev-master']
experimental: [false]

include:
# Experimental builds. These are allowed to fail.

# PHP nightly
- php: '8.1'
phpcs_version: 'dev-master'
wpcs_version: 'dev-master'
experimental: true
# Test against WPCS unstable. Re-enable when WPCS is not in dev for the next major.
#- php: '8.0'
# phpcs_version: 'dev-master'
# wpcs_version: 'dev-develop'
# experimental: true

# Test against the next major of PHPCS. Temporarily disabled due to upstream bugs.
#- php: '7.4'
# phpcs_version: '4.0.x-dev'
# wpcs_version: 'dev-develop'
# experimental: true

name: "Test${{ matrix.phpcs_version == 'dev-master' && matrix.wpcs_version == 'dev-master' && ' + Lint' || '' }}: PHP ${{ matrix.php }} - PHPCS ${{ matrix.phpcs_version }} - WPCS ${{ matrix.wpcs_version }}"

continue-on-error: ${{ matrix.experimental }}

steps:
- name: Checkout code
uses: actions/checkout@v2

# 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 [[ "${{ matrix.phpcs_version }}" != "dev-master" && "${{ matrix.phpcs_version }}" != "4.0.x-dev" ]]; then
echo '::set-output name=PHP_INI::error_reporting=E_ALL & ~E_DEPRECATED'
else
echo '::set-output name=PHP_INI::error_reporting=E_ALL'
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
env:
# Token is needed for the PHPCS 4.x run against source.
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Set Composer up to download only PHPCS from source for PHPCS 4.x.
# The source is needed to get the base testcase from PHPCS.
# All other jobs can use `auto`, which is Composer's default value.
- name: 'Composer: conditionally prefer source for PHPCS'
if: ${{ startsWith( matrix.phpcs_version, '4' ) }}
run: composer config preferred-install.squizlabs/php_codesniffer source

- name: 'Composer: adjust dependencies'
run: |
# Set the PHPCS version to test against.
composer require --no-update --no-scripts squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}"
# Set the WPCS version to test against.
composer require --no-update --no-scripts wp-coding-standards/wpcs:"${{ matrix.wpcs_version }}"
- name: 'Composer: conditionally remove PHPCSDevtools'
if: ${{ startsWith( matrix.phpcs_version, '4' ) }}
# Remove devtools as it will not (yet) install on PHPCS 4.x.
run: composer remove --no-update --dev phpcsstandards/phpcsdevtools

# Install dependencies and handle caching in one go.
# @link https://github.com/marketplace/actions/install-composer-dependencies
- name: Install Composer dependencies - normal
if: ${{ startsWith( matrix.php, '8' ) == false }}
uses: ramsey/composer-install@v1

# For the PHP 8/"nightly", we need to install with ignore platform reqs as we're still using PHPUnit 7.
- name: Install Composer dependencies - with ignore platform
if: ${{ startsWith( matrix.php, '8' ) }}
uses: ramsey/composer-install@v1
with:
composer-options: --ignore-platform-reqs

- name: Verify installed standards
run: vendor/bin/phpcs -i

- name: Lint against parse errors
if: ${{ matrix.phpcs_version == 'dev-master' && matrix.wpcs_version == 'dev-master' }}
run: composer lint -- --checkstyle | cs2pr

- name: Run the unit tests - PHP 5.4 - 8.0
if: ${{ matrix.php != '8.1' }}
run: composer test

- name: Run the unit tests - PHP 8.1
if: ${{ matrix.php == '8.1' }}
run: composer test -- --no-configuration --dont-report-useless-tests
env:
PHPCS_IGNORE_TESTS: 'PHPCompatibility,WordPress'
118 changes: 0 additions & 118 deletions .travis.yml

This file was deleted.

0 comments on commit dbe7f42

Please # to comment.