Skip to content

Commit 0c7203f

Browse files
authored
Merge pull request #51 from PHPCSStandards/feature/move-to-gh-actions
CI: switch to GitHub Actions
2 parents 35b074d + 764203a commit 0c7203f

File tree

6 files changed

+269
-176
lines changed

6 files changed

+269
-176
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#
88
/.gitattributes export-ignore
99
/.gitignore export-ignore
10-
/.travis.yml export-ignore
1110
/phpcs.xml.dist export-ignore
1211
/phpunit.xml.dist export-ignore
1312
/phpunit-bootstrap.php export-ignore

.github/workflows/cs.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: CS
2+
3+
on:
4+
# Run on all pushes and on all pull requests.
5+
# Prevent the build from running when there are only irrelevant changes.
6+
push:
7+
paths-ignore:
8+
- '**.md'
9+
pull_request:
10+
paths-ignore:
11+
- '**.md'
12+
13+
jobs:
14+
checkcs:
15+
name: 'Basic CS and QA checks'
16+
runs-on: ubuntu-latest
17+
18+
env:
19+
XMLLINT_INDENT: ' '
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v2
24+
25+
- name: Install PHP
26+
uses: shivammathur/setup-php@v2
27+
with:
28+
php-version: '7.4'
29+
coverage: none
30+
31+
- name: 'Composer: adjust dependencies'
32+
run: |
33+
# The sniff stage doesn't run the unit tests, so no need for PHPUnit.
34+
composer remove --no-update --dev phpunit/phpunit --no-scripts
35+
# Using PHPCS `master` as an early detection system for bugs upstream.
36+
composer require --no-update squizlabs/php_codesniffer:"dev-master"
37+
38+
# Install dependencies and handle caching in one go.
39+
# @link https://github.com/marketplace/actions/install-composer-dependencies
40+
- name: Install Composer dependencies
41+
uses: "ramsey/composer-install@v1"
42+
43+
- name: Install xmllint
44+
run: sudo apt-get install --no-install-recommends -y libxml2-utils
45+
46+
# Show XML violations inline in the file diff.
47+
# @link https://github.com/marketplace/actions/xmllint-problem-matcher
48+
- uses: korelstar/xmllint-problem-matcher@v1
49+
50+
# Validate the XML file.
51+
# @link http://xmlsoft.org/xmllint.html
52+
- name: Validate ruleset against schema
53+
run: xmllint --noout --schema vendor/squizlabs/php_codesniffer/phpcs.xsd PHPCSDebug/ruleset.xml
54+
55+
# Check the code-style consistency of the XML file.
56+
- name: Check XML code style
57+
run: diff -B ./PHPCSDebug/ruleset.xml <(xmllint --format "./PHPCSDebug/ruleset.xml")
58+
59+
# Check the code-style consistency of the PHP files.
60+
- name: Check PHP code style
61+
run: composer check-cs
62+
63+
# Validate the composer.json file.
64+
# @link https://getcomposer.org/doc/03-cli.md#validate
65+
- name: Validate Composer installation
66+
run: composer validate --no-check-all --strict

.github/workflows/quicktest.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Quicktest
2+
3+
on:
4+
# Run on pushes, including merges, to all branches except `master`.
5+
push:
6+
branches-ignore:
7+
- master
8+
paths-ignore:
9+
- '**.md'
10+
11+
jobs:
12+
#### QUICK TEST STAGE ####
13+
# This is a much quicker test which only runs the unit tests and linting against the low/high
14+
# supported PHP/PHPCS combinations.
15+
quicktest:
16+
runs-on: ubuntu-latest
17+
18+
strategy:
19+
matrix:
20+
php: ['5.4', 'latest']
21+
phpcs_version: ['dev-master']
22+
lint: [true]
23+
24+
include:
25+
- php: '7.2'
26+
phpcs_version: '3.1.0'
27+
lint: false
28+
- php: '5.4'
29+
phpcs_version: '3.1.0'
30+
lint: false
31+
32+
name: "QTest${{ matrix.lint && ' + Lint' || '' }}: PHP ${{ matrix.php }} - PHPCS ${{ matrix.phpcs_version }}"
33+
34+
steps:
35+
- name: Checkout code
36+
uses: actions/checkout@v2
37+
38+
# On stable PHPCS versions, allow for PHP deprecation notices.
39+
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
40+
- name: Setup ini config
41+
id: set_ini
42+
run: |
43+
if [ "${{ matrix.phpcs_version }}" != "dev-master" ]; then
44+
echo '::set-output name=PHP_INI::error_reporting=E_ALL & ~E_DEPRECATED'
45+
else
46+
echo '::set-output name=PHP_INI::error_reporting=E_ALL'
47+
fi
48+
49+
- name: Install PHP
50+
uses: shivammathur/setup-php@v2
51+
with:
52+
php-version: ${{ matrix.php }}
53+
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
54+
coverage: none
55+
56+
- name: 'Composer: adjust dependencies'
57+
run: |
58+
# Set the PHPCS version to be used in the tests.
59+
composer require --no-update squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-scripts
60+
# Remove the PHPCSDevCS dependency as it has different PHPCS requirements and would block installs.
61+
composer remove --no-update --dev phpcsstandards/phpcsdevcs --no-scripts
62+
63+
# Install dependencies and handle caching in one go.
64+
# @link https://github.com/marketplace/actions/install-composer-dependencies
65+
- name: Install Composer dependencies
66+
uses: "ramsey/composer-install@v1"
67+
68+
- name: Lint against parse errors
69+
if: ${{ matrix.lint }}
70+
run: composer lint
71+
72+
# Check that any sniffs available are feature complete.
73+
# This also acts as an integration test for the feature completeness script,
74+
# which is why it is run against various PHP versions and not in the "Sniff" stage.
75+
- name: Check for feature completeness
76+
if: ${{ matrix.lint }}
77+
run: composer check-complete
78+
79+
- name: Run the unit tests
80+
run: composer run-tests

.github/workflows/test.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Test
2+
3+
on:
4+
# Run on pushes to `master` and on all pull requests.
5+
push:
6+
branches:
7+
- master
8+
pull_request:
9+
paths-ignore:
10+
- '**.md'
11+
12+
jobs:
13+
#### TEST STAGE ####
14+
test:
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
# Keys:
19+
# - experimental: Whether the build is "allowed to fail".
20+
matrix:
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.2 on any version.
23+
# - PHP 7.3 needs PHPCS 3.3.1+ to run without errors.
24+
# - PHP 7.4 needs PHPCS 3.5.0+ to run without errors.
25+
# - PHP 8.0 needs PHPCS 3.5.7+ to run without errors.
26+
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2']
27+
phpcs_version: ['3.1.0', 'dev-master']
28+
experimental: [false]
29+
30+
include:
31+
# Complete the matrix, while preventing issues with PHPCS versions incompatible with certain PHP versions.
32+
- php: '8.0'
33+
phpcs_version: 'dev-master'
34+
experimental: false
35+
- php: '8.0'
36+
phpcs_version: '3.5.7'
37+
experimental: false
38+
39+
- php: '7.4'
40+
phpcs_version: 'dev-master'
41+
experimental: false
42+
- php: '7.4'
43+
phpcs_version: '3.5.0'
44+
experimental: false
45+
46+
- php: '7.3'
47+
phpcs_version: 'dev-master'
48+
experimental: false
49+
- php: '7.3'
50+
phpcs_version: '3.3.1'
51+
experimental: false
52+
53+
# Experimental builds. These are allowed to fail.
54+
- php: '7.4'
55+
phpcs_version: '4.0.x-dev'
56+
experimental: true
57+
58+
- php: '8.1' # Nightly.
59+
phpcs_version: 'dev-master'
60+
experimental: true
61+
62+
name: "Test${{ matrix.phpcs_version == 'dev-master' && ' + Lint' || '' }}: PHP ${{ matrix.php }} - PHPCS ${{ matrix.phpcs_version }}"
63+
64+
continue-on-error: ${{ matrix.experimental }}
65+
66+
steps:
67+
- name: Checkout code
68+
uses: actions/checkout@v2
69+
70+
- name: Setup ini config
71+
id: set_ini
72+
run: |
73+
# On stable PHPCS versions, allow for PHP deprecation notices.
74+
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
75+
if [[ "${{ matrix.phpcs_version }}" != "dev-master" && "${{ matrix.phpcs_version }}" != "4.0.x-dev" ]]; then
76+
echo '::set-output name=PHP_INI::error_reporting=E_ALL & ~E_DEPRECATED'
77+
else
78+
echo '::set-output name=PHP_INI::error_reporting=E_ALL'
79+
fi
80+
81+
- name: Install PHP
82+
uses: shivammathur/setup-php@v2
83+
with:
84+
php-version: ${{ matrix.php }}
85+
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
86+
coverage: none
87+
88+
- name: 'Composer: adjust dependencies'
89+
run: |
90+
# Set the PHPCS version to be used in the tests.
91+
composer require --no-update squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}" --no-scripts
92+
# Remove the PHPCSDevCS dependency as it has different PHPCS requirements and would block installs.
93+
composer remove --no-update --dev phpcsstandards/phpcsdevcs --no-scripts
94+
95+
# Install dependencies and handle caching in one go.
96+
# @link https://github.com/marketplace/actions/install-composer-dependencies
97+
- name: Install Composer dependencies - normal
98+
if: ${{ matrix.php < 8.1 }}
99+
uses: "ramsey/composer-install@v1"
100+
101+
# For PHP "nightly", we need to install with ignore platform reqs as not all dependencies allow installation.
102+
- name: Install Composer dependencies - with ignore platform
103+
if: ${{ matrix.php >= 8.1 }}
104+
uses: "ramsey/composer-install@v1"
105+
with:
106+
composer-options: --ignore-platform-reqs
107+
108+
- name: Lint against parse errors
109+
if: matrix.phpcs_version == 'dev-master'
110+
run: composer lint
111+
112+
# Check that any sniffs available are feature complete.
113+
# This also acts as an integration test for the feature completeness script,
114+
# which is why it is run against various PHP versions and not in the "Sniff" stage.
115+
- name: Check for feature completeness
116+
if: matrix.phpcs_version == 'dev-master'
117+
run: composer check-complete
118+
119+
- name: Run the unit tests
120+
run: composer run-tests

0 commit comments

Comments
 (0)