Skip to content

Commit b1ed180

Browse files
committed
Merge branch 'feature/move-to-gh-actions' of https://github.com/jrfnl/PHP_CodeSniffer
2 parents f6a0cff + 2b20b56 commit b1ed180

File tree

8 files changed

+223
-140
lines changed

8 files changed

+223
-140
lines changed

.gitattributes

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
.travis.yml export-ignore
21
.cspell.json export-ignore
32
.gitattributes export-ignore
43
.gitignore export-ignore
54
phpcs.xml.dist export-ignore
65
phpstan.neon export-ignore
76
package.xml export-ignore
87
phpunit.xml.dist export-ignore
9-
php5-testingConfig.ini export-ignore
10-
php7-testingConfig.ini export-ignore
118
scripts/ export-ignore
129

1310
# Declare files that should always have CRLF line endings on checkout.

.github/workflows/phpstan.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: PHPStan
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+
phpstan:
15+
name: "PHP: 7.4 | PHPStan"
16+
17+
runs-on: "ubuntu-latest"
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v2
22+
23+
- name: Install PHP
24+
uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: '7.4'
27+
coverage: none
28+
29+
- name: 'Composer: require PHPStan'
30+
run: composer require --no-update --dev phpstan/phpstan
31+
32+
# Install dependencies and handle caching in one go.
33+
# @link https://github.com/marketplace/actions/install-composer-dependencies
34+
- name: Install Composer dependencies
35+
uses: "ramsey/composer-install@v1"
36+
37+
- name: Run PHPStan
38+
run: vendor/bin/phpstan analyse --configuration=phpstan.neon

.github/workflows/test.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: Test
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+
test:
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
# Keys:
19+
# - custom_ini: Whether to run with specific custom ini settings to hit very specific
20+
# code conditions.
21+
# - experimental: Whether the build is "allowed to fail".
22+
matrix:
23+
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
24+
custom_ini: [false]
25+
experimental: [false]
26+
27+
include:
28+
# Builds running the basic tests with different PHP ini settings.
29+
- php: '5.5'
30+
custom_ini: true
31+
experimental: false
32+
- php: '7.0'
33+
custom_ini: true
34+
experimental: false
35+
36+
# Nightly.
37+
- php: '8.1'
38+
custom_ini: false
39+
experimental: true
40+
41+
name: "PHP: ${{ matrix.php }} ${{ matrix.custom_ini && ' with custom ini settings' || '' }}"
42+
43+
continue-on-error: ${{ matrix.experimental }}
44+
45+
steps:
46+
- name: Checkout code
47+
uses: actions/checkout@v2
48+
49+
- name: Setup ini config
50+
id: set_ini
51+
run: |
52+
# On stable PHPCS versions, allow for PHP deprecation notices.
53+
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
54+
# Also set the "short_open_tag" ini to make sure specific conditions are tested.
55+
if [[ ${{ matrix.custom_ini }} == true && "${{ matrix.php }}" == '5.5' ]]; then
56+
echo '::set-output name=PHP_INI::phar.readonly=Off, date.timezone=Australia/Sydney, short_open_tag=On, asp_tags=On'
57+
elif [[ ${{ matrix.custom_ini }} == true && "${{ matrix.php }}" == '7.0' ]]; then
58+
echo '::set-output name=PHP_INI::phar.readonly=Off, date.timezone=Australia/Sydney, short_open_tag=On'
59+
else
60+
echo '::set-output name=PHP_INI::phar.readonly=Off'
61+
fi
62+
63+
- name: Install PHP
64+
uses: shivammathur/setup-php@v2
65+
with:
66+
php-version: ${{ matrix.php }}
67+
ini-values: ${{ steps.set_ini.outputs.PHP_INI }}
68+
coverage: none
69+
70+
# Install dependencies and handle caching in one go.
71+
# @link https://github.com/marketplace/actions/install-composer-dependencies
72+
- name: Install Composer dependencies - normal
73+
if: ${{ matrix.php < 8.0 }}
74+
uses: "ramsey/composer-install@v1"
75+
76+
# For PHP 8.0+, we need to install with ignore platform reqs as PHPUnit 7 is still used.
77+
- name: Install Composer dependencies - with ignore platform
78+
if: ${{ matrix.php >= 8.0 }}
79+
uses: "ramsey/composer-install@v1"
80+
with:
81+
composer-options: --ignore-platform-reqs
82+
83+
# Note: The code style check is run multiple times against every PHP version
84+
# as it also acts as an integration test.
85+
- name: 'PHPCS: set the path to PHP'
86+
run: php bin/phpcs --config-set php_path php
87+
88+
- name: 'PHPUnit: run the tests'
89+
run: vendor/bin/phpunit tests/AllTests.php
90+
91+
- name: 'PHPCS: check code style without cache, no parallel'
92+
if: ${{ matrix.custom_ini == false }}
93+
run: php bin/phpcs --no-cache --parallel=1
94+
95+
- name: 'Composer: validate config'
96+
if: ${{ matrix.custom_ini == false }}
97+
run: composer validate --no-check-all --strict
98+
99+
- name: Build the phar
100+
if: ${{ matrix.custom_ini == false }}
101+
run: php scripts/build-phar.php
102+
103+
- name: 'PHPCS: check code style using the Phar file'
104+
if: ${{ matrix.custom_ini == false }}
105+
run: php phpcs.phar

.github/workflows/validate.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Validate
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+
checkxml:
15+
name: Check XML files
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 xmllint
26+
run: sudo apt-get install --no-install-recommends -y libxml2-utils
27+
28+
- name: Retrieve XML Schema
29+
run: curl -O https://www.w3.org/2012/04/XMLSchema.xsd
30+
31+
# Show XML violations inline in the file diff.
32+
# @link https://github.com/marketplace/actions/xmllint-problem-matcher
33+
- uses: korelstar/xmllint-problem-matcher@v1
34+
35+
# Validate the XML ruleset files.
36+
# @link http://xmlsoft.org/xmllint.html
37+
- name: Validate rulesets against schema
38+
run: xmllint --noout --schema phpcs.xsd ./src/Standards/*/ruleset.xml
39+
40+
# Validate the XSD file.
41+
# @link http://xmlsoft.org/xmllint.html
42+
- name: Validate XSD against schema
43+
run: xmllint --noout --schema ./XMLSchema.xsd ./phpcs.xsd
44+
45+
# Check the code-style consistency of the XML files.
46+
- name: Check XML code style
47+
run: |
48+
diff -B ./phpcs.xml.dist <(xmllint --format "./phpcs.xml.dist")
49+
diff -B ./src/Standards/Generic/ruleset.xml <(xmllint --format "./src/Standards/Generic/ruleset.xml")
50+
diff -B ./src/Standards/MySource/ruleset.xml <(xmllint --format "./src/Standards/MySource/ruleset.xml")
51+
diff -B ./src/Standards/PEAR/ruleset.xml <(xmllint --format "./src/Standards/PEAR/ruleset.xml")
52+
diff -B ./src/Standards/PSR1/ruleset.xml <(xmllint --format "./src/Standards/PSR1/ruleset.xml")
53+
diff -B ./src/Standards/PSR2/ruleset.xml <(xmllint --format "./src/Standards/PSR2/ruleset.xml")
54+
diff -B ./src/Standards/PSR12/ruleset.xml <(xmllint --format "./src/Standards/PSR12/ruleset.xml")
55+
diff -B ./src/Standards/Squiz/ruleset.xml <(xmllint --format "./src/Standards/Squiz/ruleset.xml")
56+
diff -B ./src/Standards/Zend/ruleset.xml <(xmllint --format "./src/Standards/Zend/ruleset.xml")
57+
58+
pear:
59+
name: "PHP: 7.4 | PEAR package validation"
60+
runs-on: ubuntu-latest
61+
62+
steps:
63+
- name: Checkout code
64+
uses: actions/checkout@v2
65+
66+
- name: Install PHP
67+
uses: shivammathur/setup-php@v2
68+
with:
69+
php-version: '7.4'
70+
coverage: none
71+
72+
- name: Validate the PEAR package file contents
73+
run: php scripts/validate-pear-package.php
74+
75+
- name: Validate the PEAR package
76+
run: pear package-validate package.xml

.travis.yml

Lines changed: 0 additions & 116 deletions
This file was deleted.

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
PHP_CodeSniffer is a set of two PHP scripts; the main `phpcs` script that tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard, and a second `phpcbf` script to automatically correct coding standard violations. PHP_CodeSniffer is an essential development tool that ensures your code remains clean and consistent.
44

5-
[![Build Status](https://travis-ci.org/squizlabs/PHP_CodeSniffer.svg?branch=phpcs-fixer)](https://travis-ci.org/squizlabs/PHP_CodeSniffer) [![Code consistency](http://squizlabs.github.io/PHP_CodeSniffer/analysis/squizlabs/PHP_CodeSniffer/grade.svg)](http://squizlabs.github.io/PHP_CodeSniffer/analysis/squizlabs/PHP_CodeSniffer) [![Join the chat at https://gitter.im/squizlabs/PHP_CodeSniffer](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/squizlabs/PHP_CodeSniffer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
5+
[![Build Status](https://github.com/squizlabs/PHP_CodeSniffer/workflows/Validate/badge.svg?branch=master)](https://github.com/squizlabs/PHP_CodeSniffer/actions)
6+
[![Build Status](https://github.com/squizlabs/PHP_CodeSniffer/workflows/Test/badge.svg?branch=master)](https://github.com/squizlabs/PHP_CodeSniffer/actions)
7+
[![Code consistency](http://squizlabs.github.io/PHP_CodeSniffer/analysis/squizlabs/PHP_CodeSniffer/grade.svg)](http://squizlabs.github.io/PHP_CodeSniffer/analysis/squizlabs/PHP_CodeSniffer)
8+
[![Join the chat at https://gitter.im/squizlabs/PHP_CodeSniffer](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/squizlabs/PHP_CodeSniffer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
69

710
## Requirements
811

php5-testingConfig.ini

Lines changed: 0 additions & 12 deletions
This file was deleted.

php7-testingConfig.ini

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)