Skip to content

Commit 89d563a

Browse files
committed
CI: switch to GitHub Actions - step 1: sniff stage
This commit: * Adds a GH Actions workflow for the CI checks which were previously run on Travis in the `sniff` stage. While these aren't 100% CS (= code style) checks, for the badge and workflow display, `CS` still seemed the most descriptive name. * Removes that part of the `.travis.yml` configuration. * Adds a "Build Status" badge in the Readme to use the results from this particular GH Actions runs. Notes: Builds will run on all pushes and on pull requests, with the exception of those just modifying files which are irrelevant to this workflow.
1 parent 35b074d commit 89d563a

File tree

3 files changed

+67
-34
lines changed

3 files changed

+67
-34
lines changed

.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

.travis.yml

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ env:
2929
# Note: for pull requests, "develop" is the base branch name.
3030
# See: https://docs.travis-ci.com/user/conditions-v1
3131
stages:
32-
- name: sniff
3332
- name: quicktest
3433
if: type = push AND branch NOT IN (stable, develop)
3534
- name: test
@@ -38,39 +37,6 @@ stages:
3837
jobs:
3938
fast_finish: true
4039
include:
41-
#### SNIFF STAGE ####
42-
- stage: sniff
43-
php: 7.4
44-
addons:
45-
apt:
46-
packages:
47-
- libxml2-utils
48-
49-
before_install:
50-
- phpenv config-rm xdebug.ini || echo 'No xdebug config.'
51-
- export XMLLINT_INDENT=" "
52-
# Set up CS check.
53-
# - Using PHPCS `master` as an early detection system for bugs upstream.
54-
# - The sniff stage doesn't run the unit tests, so no need for PHPUnit.
55-
- travis_retry composer remove --dev phpunit/phpunit --no-update --no-scripts
56-
- travis_retry composer require --no-update squizlabs/php_codesniffer:"dev-master"
57-
- travis_retry composer install --no-interaction
58-
59-
script:
60-
# Check the code style of the code base.
61-
- composer check-cs
62-
63-
# Validate the xml file.
64-
# @link http://xmlsoft.org/xmllint.html
65-
- xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./PHPCSDebug/ruleset.xml
66-
67-
# Check the code-style consistency of the xml files.
68-
- diff -B ./PHPCSDebug/ruleset.xml <(xmllint --format "./PHPCSDebug/ruleset.xml")
69-
70-
# Validate the composer.json file.
71-
# @link https://getcomposer.org/doc/03-cli.md#validate
72-
- composer validate --no-check-all --strict
73-
7440
#### QUICK TEST STAGE ####
7541
# This is a much quicker test which only runs the unit tests and linting against the low/high
7642
# supported PHP/PHPCS combinations.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ PHPCSDevTools for developers of PHP_CodeSniffer sniffs
1010
[![Last Commit to Unstable](https://img.shields.io/github/last-commit/PHPCSStandards/PHPCSDevTools/develop.svg)](https://github.com/PHPCSStandards/PHPCSDevTools/commits/develop)
1111

1212
[![Minimum PHP Version](https://img.shields.io/packagist/php-v/phpcsstandards/phpcsdevtools.svg?maxAge=3600)](https://packagist.org/packages/phpcsstandards/phpcsdevtools)
13+
[![Build Status CS](https://github.com/PHPCSStandards/PHPCSDevTools/workflows/CS/badge.svg?branch=develop)](https://github.com/PHPCSStandards/PHPCSDevTools/actions)
1314
[![Tested on PHP 5.4 to nightly](https://img.shields.io/badge/tested%20on-PHP%205.4%20|%205.5%20|%205.6%20|%207.0%20|%207.1%20|%207.2%20|%207.3%20|%207.4%20|%20nightly-brightgreen.svg?maxAge=2419200)](https://travis-ci.com/PHPCSStandards/PHPCSDevTools)
1415

1516
[![License: LGPLv3](https://poser.pugx.org/phpcsstandards/phpcsdevtools/license)](https://github.com/PHPCSStandards/PHPCSDevTools/blob/stable/LICENSE)

0 commit comments

Comments
 (0)