Skip to content

Commit 65143ee

Browse files
committed
CI: switch to GitHub Actions - step 1: sniff and lint stage
This commit: * Adds a GH Actions workflow for the CI checks which were previously run on Travis in the `sniff` and `lint` stages. For the badge and workflow display, the name `BasicQA` seems an appropriately descriptive name. * Removes that part of the `.travis.yml` configuration. * Removes a duplicate line in the `bin/xml-lint` script used by this workflow. Notes: 1. In the Travis script, these checks were in two separate stages. I've now combined them into one workflow `job`. In GH Actions, the environment has to be setup as part of the workflow. And as the environment needed for these checks is largely the same, combining the checks into one workflow simplifies the script and reduced duplication. 2. Builds will run on all pushes and on pull requests, with the exception of pushes just modifying files which are irrelevant to this workflow. 3. The workflow can be manually (re-)triggered if needs be. 4. Any violations reported by the XML validation against the XSD schema, as well as coming from the PHPCS run, are set up to be shown in-line in the pull request to easily see what line in the pull request causes a build to fail.
1 parent 8c887b6 commit 65143ee

File tree

3 files changed

+63
-45
lines changed

3 files changed

+63
-45
lines changed

.github/workflows/basics.yml

Lines changed: 62 additions & 0 deletions
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

.travis.yml

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -21,54 +21,11 @@ php:
2121
- 7.4
2222
- "nightly"
2323

24-
# Rather than a `matrix` property, we use build stages. This allows early
25-
# build failure for basic linting and sniffing issues.
26-
# @link https://docs.travis-ci.com/user/build-stages/
27-
28-
stages:
29-
- lint
30-
- sniff
31-
- test
32-
3324
jobs:
3425
allow_failures:
3526
- php: "nightly"
3627
include:
37-
38-
- stage: lint
39-
php: 7.4
40-
env: PHPCS_BRANCH="dev-master"
41-
before_install: phpenv config-rm xdebug.ini || echo 'No xdebug config.'
42-
install: skip
43-
cache: skip
44-
script:
45-
# Lint the PHP files against parse errors.
46-
- ./bin/php-lint
47-
48-
# Add PHPCS locally for the XSD.
49-
- travis_retry composer require squizlabs/php_codesniffer
50-
# Validate the XML files and check the code-style consistency of the XML files.
51-
- ./bin/xml-lint
52-
53-
# Validate the composer.json file.
54-
# @link https://getcomposer.org/doc/03-cli.md#validate
55-
- composer validate --no-check-all --strict
56-
addons:
57-
apt:
58-
packages:
59-
- libxml2-utils
60-
61-
- stage: sniff
62-
php: 7.4
63-
env: PHPCS_BRANCH="dev-master"
64-
before_install: phpenv config-rm xdebug.ini || echo 'No xdebug config.'
65-
install: travis_retry composer install --no-suggest
66-
script:
67-
# Run PHPCS against VIPCS.
68-
- ./bin/phpcs
69-
7028
# Builds which need a different distro or specific PHPCS version.
71-
- stage: test
7229
- php: 8.0
7330
env: PHPCS_BRANCH="dev-master"
7431
- php: 8.0
@@ -96,7 +53,7 @@ before_install:
9653
# On stable PHPCS versions, allow for PHP deprecation notices.
9754
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
9855
- |
99-
if [[ "$TRAVIS_BUILD_STAGE_NAME" != "Sniff" && $PHPCS_BRANCH != "dev-master" ]]; then
56+
if [[ $PHPCS_BRANCH != "dev-master" ]]; then
10057
echo 'error_reporting = E_ALL & ~E_DEPRECATED' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
10158
fi
10259

bin/xml-lint

Lines changed: 0 additions & 1 deletion
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)