Skip to content

Commit d018e58

Browse files
authored
Merge pull request #239 from PHPCSStandards/feature/move-to-gh-actions
CI: switch to GitHub Actions
2 parents 1572bc4 + 846075c commit d018e58

File tree

10 files changed

+457
-288
lines changed

10 files changed

+457
-288
lines changed

.coveralls.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
coverage_clover: build/logs/clover.xml
22
json_path: build/logs/coveralls-upload.json
3-
service_name: travis-ci

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/.coveralls.yml export-ignore
99
/.gitattributes export-ignore
1010
/.gitignore export-ignore
11-
/.travis.yml export-ignore
11+
/.github/ export-ignore
1212
/phpcs.xml.dist export-ignore
1313
/phpdoc.xml.dist export-ignore
1414
/phpunit.xml.dist export-ignore

.github/workflows/basics.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
- 'docs/**'
10+
pull_request:
11+
paths-ignore:
12+
- '**.md'
13+
- 'docs/**'
14+
15+
jobs:
16+
checkcs:
17+
name: 'Basic CS and QA checks'
18+
runs-on: ubuntu-latest
19+
20+
env:
21+
XMLLINT_INDENT: ' '
22+
# - COMPOSER_ROOT_VERSION is needed to get round the recursive dependency when using CI.
23+
COMPOSER_ROOT_VERSION: '1.99.99'
24+
25+
steps:
26+
- name: Checkout code
27+
uses: actions/checkout@v2
28+
29+
- name: Install PHP
30+
uses: shivammathur/setup-php@v2
31+
with:
32+
php-version: '7.4'
33+
coverage: none
34+
35+
- name: 'Composer: adjust dependencies'
36+
run: |
37+
# The sniff stage doesn't run the unit tests, so no need for PHPUnit.
38+
composer remove --no-update --dev phpunit/phpunit --no-scripts
39+
# Using PHPCS `master` as an early detection system for bugs upstream.
40+
composer require --no-update squizlabs/php_codesniffer:"dev-master"
41+
# Add PHPCSDevCS - this is the CS ruleset we use.
42+
# This is not in the composer.json as it has different minimum PHPCS reqs and would conflict.
43+
composer require --no-update --dev phpcsstandards/phpcsdevcs:"^1.1.2"
44+
45+
# Install dependencies and handle caching in one go.
46+
# @link https://github.com/marketplace/actions/install-composer-dependencies
47+
- name: Install Composer dependencies
48+
uses: "ramsey/composer-install@v1"
49+
50+
- name: Install xmllint
51+
run: sudo apt-get install --no-install-recommends -y libxml2-utils
52+
53+
# Show XML violations inline in the file diff.
54+
# @link https://github.com/marketplace/actions/xmllint-problem-matcher
55+
- uses: korelstar/xmllint-problem-matcher@v1
56+
57+
# Validate the XML file.
58+
# @link http://xmlsoft.org/xmllint.html
59+
- name: Validate rulesets against schema
60+
run: xmllint --noout --schema vendor/squizlabs/php_codesniffer/phpcs.xsd ./*/ruleset.xml
61+
62+
# Check the code-style consistency of the XML file.
63+
- name: Check XML code style
64+
run: |
65+
diff -B ./PHPCSUtils/ruleset.xml <(xmllint --format "./PHPCSUtils/ruleset.xml")
66+
diff -B ./PHPCS23Utils/ruleset.xml <(xmllint --format "./PHPCS23Utils/ruleset.xml")
67+
68+
# Check the code-style consistency of the PHP files.
69+
- name: Check PHP code style
70+
run: vendor/bin/phpcs
71+
72+
# Validate the composer.json file.
73+
# @link https://getcomposer.org/doc/03-cli.md#validate
74+
- name: Validate Composer installation
75+
run: composer validate --no-check-all --strict

.github/workflows/ghpages.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Docs
2+
3+
on:
4+
push:
5+
paths:
6+
- 'docs/**'
7+
pull_request:
8+
paths:
9+
- 'docs/**'
10+
11+
jobs:
12+
#### TEST DOCUMENTATION SITE GENERATION ####
13+
test:
14+
runs-on: ubuntu-latest
15+
16+
name: "Test build GHPages site"
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v2
21+
22+
- name: Set up Ruby
23+
uses: ruby/setup-ruby@v1
24+
with:
25+
# Use the version as per https://pages.github.com/versions/
26+
ruby-version: 2.7.1
27+
bundler-cache: true
28+
working-directory: docs
29+
30+
- name: Test building the GH Pages site
31+
run: |
32+
cd docs
33+
bundle exec jekyll build

.github/workflows/quicktest.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
- 'docs/**'
11+
12+
jobs:
13+
#### QUICK TEST STAGE ####
14+
# This is a much quicker test which only runs the unit tests and linting against the low/high
15+
# supported PHP/PHPCS combinations.
16+
# These are basically the same builds as in the Test->Coverage workflow, but then without doing
17+
# the code-coverage.
18+
quicktest:
19+
runs-on: ubuntu-latest
20+
21+
strategy:
22+
matrix:
23+
php: ['5.4', 'latest']
24+
phpcs_version: ['dev-master']
25+
26+
include:
27+
- php: '7.3'
28+
phpcs_version: '2.9.2'
29+
- php: '5.4'
30+
phpcs_version: '2.6.0'
31+
32+
name: "QTest${{ matrix.phpcs_version == 'dev-master' && ' + 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: set PHPCS version for tests'
57+
run: composer require --no-update squizlabs/php_codesniffer:"${{ matrix.phpcs_version }}"
58+
59+
# Install dependencies and handle caching in one go.
60+
# @link https://github.com/marketplace/actions/install-composer-dependencies
61+
- name: Install Composer dependencies
62+
uses: "ramsey/composer-install@v1"
63+
64+
- name: Lint against parse errors
65+
if: matrix.phpcs_version == 'dev-master'
66+
run: composer lint
67+
68+
- name: Run the unit tests
69+
run: vendor/bin/phpunit --no-coverage

0 commit comments

Comments
 (0)