Skip to content

Commit 7b04b16

Browse files
committed
CI: switch to GitHub Actions - step 2: test stage
This commit: * Adds a GH Actions workflow for the CI check which was previously run on Travis in the `test` stage. * Removes the, now redundant, `.travis.yml` configuration. * Updates the `.gitattributes` file. Notes: 1. For the time being, I've commented out the job against PHP 8.1/nightly as - no matter what I've tried - I can't even get the tests running at the moment, so they would only ever fail. Once PHP 8.1 starts to release alpha/beta/RC builds, further testing should be done to attempt to get this working. Notes/current findings: - With PHPUnit 7.x on PHP 8.1, using a configuration file will block the tests from running. - In some cases (PHPCS itself, PHPCSExtra), I managed to get the tests running by passing all relevant information via the command-line and actively ignoring the configuration file using `--no-configuration`. Unfortunately, that does not seem to work in this case. Further investigation is needed. - Based on the (running) tests for PHPCSExtra on PHP 8.1, an incompatibility with PHP 8.1 in PHPCS itself has already been discovered. A fix for this has been pulled, but not yet merged: squizlabs/php_codesniffer 3250
1 parent 65143ee commit 7b04b16

File tree

3 files changed

+101
-77
lines changed

3 files changed

+101
-77
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
/.gitattributes export-ignore
99
/.gitignore export-ignore
1010
/.phpcs.xml.dist export-ignore
11-
/.travis.yml export-ignore
1211
/phpunit.xml.dist export-ignore
1312
/.github export-ignore
1413
/bin export-ignore

.github/workflows/test.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Test
2+
3+
on:
4+
# Run on all pushes and on all pull requests.
5+
# Prevent the "push" build from running when there are only irrelevant changes.
6+
push:
7+
paths-ignore:
8+
- '**.md'
9+
pull_request:
10+
# Allow manually triggering the workflow.
11+
workflow_dispatch:
12+
13+
jobs:
14+
test:
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
# Keys:
19+
# - php: The PHP versions to test against.
20+
# - phpcs_version: The PHPCS versions to test against.
21+
# IMPORTANT: test runs shouldn't fail because of PHPCS being incompatible with a PHP version.
22+
# - PHPCS will run without errors on PHP 5.4 - 7.4 on any supported version.
23+
# - PHP 8.0 needs PHPCS 3.5.7+ to run without errors.
24+
# - The `wpcs_version` key is added to allow additional test builds when multiple WPCS versions
25+
# would be supported. As, at this time, only the latest stable release of WPCS is supported,
26+
# no additional versions are included in the array.
27+
# - experimental: Whether the build is "allowed to fail".
28+
matrix:
29+
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
30+
phpcs_version: ['3.5.5', 'dev-master']
31+
wpcs_version: ['2.3.*']
32+
experimental: [false]
33+
34+
include:
35+
# Complete the matrix by adding PHP 8.0, but only test against compatible PHPCS versions.
36+
- php: '8.0'
37+
phpcs_version: 'dev-master'
38+
wpcs_version: '2.3.*'
39+
experimental: false
40+
- php: '8.0'
41+
# PHPCS 3.5.7 is the lowest version of PHPCS which supports PHP 8.0.
42+
phpcs_version: '3.5.7'
43+
wpcs_version: '2.3.*'
44+
experimental: false
45+
46+
# Experimental builds. These are allowed to fail.
47+
#- php: '8.1'
48+
# phpcs_version: 'dev-master'
49+
# wpcs_version: '2.3.*'
50+
# experimental: true
51+
52+
name: "Test: PHP ${{ matrix.php }} - PHPCS ${{ matrix.phpcs_version }} - WPCS ${{ matrix.wpcs_version }}"
53+
54+
continue-on-error: ${{ matrix.experimental }}
55+
56+
steps:
57+
- name: Checkout code
58+
uses: actions/checkout@v2
59+
60+
# On stable PHPCS versions, allow for PHP deprecation notices.
61+
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
62+
- name: Setup ini config
63+
id: set_ini
64+
run: |
65+
if [[ "${{ matrix.phpcs_version }}" != "dev-master" ]]; then
66+
echo '::set-output name=PHP_INI::error_reporting=E_ALL & ~E_DEPRECATED'
67+
else
68+
echo '::set-output name=PHP_INI::error_reporting=E_ALL'
69+
fi
70+
71+
- name: Install PHP
72+
uses: shivammathur/setup-php@v2
73+
with:
74+
php-version: ${{ matrix.php }}
75+
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
76+
coverage: none
77+
78+
- name: 'Composer: set PHPCS and WPCS versions for tests'
79+
run: |
80+
composer require --no-update --no-scripts squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}"
81+
composer require --no-update --no-scripts wp-coding-standards/wpcs:"${{ matrix.wpcs_version }}"
82+
83+
# Install dependencies and handle caching in one go.
84+
# @link https://github.com/marketplace/actions/install-composer-dependencies
85+
- name: Install Composer dependencies - normal
86+
if: ${{ startsWith( matrix.php, '8' ) == false }}
87+
uses: "ramsey/composer-install@v1"
88+
89+
# PHPUnit 7.x does not allow for installation on PHP 8, so ignore platform
90+
# requirements to get PHPUnit 7.x to install on nightly.
91+
- name: Install Composer dependencies - with ignore platform
92+
if: ${{ startsWith( matrix.php, '8' ) }}
93+
uses: "ramsey/composer-install@v1"
94+
with:
95+
composer-options: --ignore-platform-reqs
96+
97+
- name: Run the unit tests
98+
run: ./bin/unit-tests
99+
100+
- name: Run the ruleset tests
101+
run: ./bin/ruleset-tests

.travis.yml

Lines changed: 0 additions & 76 deletions
This file was deleted.

0 commit comments

Comments
 (0)