Skip to content

Commit 998c726

Browse files
authored
Merge pull request #633 from Automattic/fix/628-switch-ci-to-gh-actions
2 parents 8c887b6 + 7b04b16 commit 998c726

File tree

5 files changed

+163
-121
lines changed

5 files changed

+163
-121
lines changed

.gitattributes

-1
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/basics.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: BasicQA
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+
checkcs:
15+
name: 'Basic CS and QA checks'
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v2
21+
22+
- name: Install PHP
23+
uses: shivammathur/setup-php@v2
24+
with:
25+
php-version: '7.4'
26+
coverage: none
27+
tools: cs2pr
28+
29+
- name: 'Lint PHP against parse errors'
30+
run: ./bin/php-lint
31+
32+
- name: Install xmllint
33+
run: sudo apt-get install --no-install-recommends -y libxml2-utils
34+
35+
# Show XML violations inline in the file diff.
36+
# @link https://github.com/marketplace/actions/xmllint-problem-matcher
37+
- uses: korelstar/xmllint-problem-matcher@v1
38+
39+
# Validate the composer.json file.
40+
# @link https://getcomposer.org/doc/03-cli.md#validate
41+
- name: Validate Composer installation
42+
run: composer validate --no-check-all --strict
43+
44+
- name: 'Composer: adjust dependencies'
45+
# Using PHPCS `master` as an early detection system for bugs upstream.
46+
run: composer require --no-update --no-scripts squizlabs/php_codesniffer:"dev-master"
47+
48+
# Install dependencies and handle caching in one go.
49+
# @link https://github.com/marketplace/actions/install-composer-dependencies
50+
- name: Install Composer dependencies
51+
uses: "ramsey/composer-install@v1"
52+
53+
- name: 'Validate XML against schema and check code style'
54+
run: ./bin/xml-lint
55+
56+
# Check the code-style consistency of the PHP files.
57+
- name: Check PHP code style
58+
continue-on-error: true
59+
run: vendor/bin/phpcs --report-full --report-checkstyle=./phpcs-report.xml
60+
61+
- name: Show PHPCS results in PR
62+
run: cs2pr ./phpcs-report.xml

.github/workflows/test.yml

+101
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

-119
This file was deleted.

bin/xml-lint

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
# ./bin/xml-lint
1010

1111
# Validate the ruleset XML files.
12-
#xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./*/ruleset.xml
1312
xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./*/ruleset.xml
1413

1514
# Check the code-style consistency of the XML files.

0 commit comments

Comments
 (0)