Skip to content

Commit e844821

Browse files
authored
Merge pull request #142 from PHPCSStandards/feature/ghactions-test-workflow-improvements
GH Actions: test workflow improvements
2 parents d900658 + fb7390e commit e844821

File tree

3 files changed

+121
-13
lines changed

3 files changed

+121
-13
lines changed

.github/workflows/build-phar.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Build PHARs
2+
3+
on:
4+
# Run on pushes to master and on all pull requests.
5+
# Prevent the build from running when there are only irrelevant changes.
6+
push:
7+
branches:
8+
- master
9+
paths-ignore:
10+
- '**.md'
11+
pull_request:
12+
# Allow manually triggering the workflow.
13+
workflow_dispatch:
14+
15+
# Cancels all previous workflow runs for the same branch that have not yet completed.
16+
concurrency:
17+
# The concurrency group contains the workflow name and the branch name.
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
25+
strategy:
26+
matrix:
27+
# Deliberately missing PHP 8.0 as that PHAR is build and used in the test workflow.
28+
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.1', '8.2', '8.3', '8.4']
29+
30+
name: "Build Phar on PHP: ${{ matrix.php }}"
31+
32+
continue-on-error: ${{ matrix.php == '8.4' }}
33+
34+
steps:
35+
- name: Checkout code
36+
uses: actions/checkout@v4
37+
38+
- name: Setup PHP
39+
uses: shivammathur/setup-php@v2
40+
with:
41+
php-version: ${{ matrix.php }}
42+
coverage: none
43+
ini-values: phar.readonly=Off, error_reporting=-1, display_errors=On
44+
45+
- name: Build the phars
46+
run: php scripts/build-phar.php
47+
48+
# Both the below only check a file which is rarely changed and therefore unlikely to have issues.
49+
# This test is about testing that the phars are functional, *not* about whether the code style complies.
50+
- name: 'PHPCS: check code style using the Phar file to test the Phar is functional'
51+
run: php phpcs.phar ./scripts
52+
53+
- name: 'PHPCBF: fix code style using the Phar file to test the Phar is functional'
54+
run: php phpcbf.phar ./scripts

.github/workflows/quicktest.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Quicktest
2+
3+
on:
4+
# Run on pushes to all branches except for `master`.
5+
push:
6+
branches-ignore:
7+
- master
8+
paths-ignore:
9+
- '**.md'
10+
# Allow manually triggering the workflow.
11+
workflow_dispatch:
12+
13+
# Cancels all previous workflow runs for the same branch that have not yet completed.
14+
concurrency:
15+
# The concurrency group contains the workflow name and the branch name.
16+
group: ${{ github.workflow }}-${{ github.ref }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
#### QUICK TEST ####
21+
# This is a much quicker test run which only runs the unit tests against the low/medium/high
22+
# supported PHP versions and skips the PHAR test and the tests for external JS/CSS tooling.
23+
# These are basically the same builds as in the Test->Coverage workflow, but then without doing
24+
# the code-coverage.
25+
quicktest:
26+
runs-on: ubuntu-latest
27+
28+
strategy:
29+
matrix:
30+
php: ['5.4', '7.2', 'latest']
31+
32+
name: "QuickTest: PHP ${{ matrix.php }}"
33+
34+
steps:
35+
- name: Checkout code
36+
uses: actions/checkout@v4
37+
38+
- name: Install PHP
39+
uses: shivammathur/setup-php@v2
40+
with:
41+
php-version: ${{ matrix.php }}
42+
ini-values: 'error_reporting=-1, display_errors=On'
43+
coverage: none
44+
45+
# Install dependencies and handle caching in one go.
46+
# @link https://github.com/marketplace/actions/install-php-dependencies-with-composer
47+
- name: Install Composer dependencies
48+
uses: "ramsey/composer-install@v2"
49+
with:
50+
# Bust the cache at least once a month - output format: YYYY-MM.
51+
custom-cache-suffix: $(date -u "+%Y-%m")
52+
53+
- name: 'PHPCS: set the path to PHP'
54+
run: php bin/phpcs --config-set php_path php
55+
56+
- name: 'PHPUnit: run the tests'
57+
run: vendor/bin/phpunit tests/AllTests.php
58+
59+
# Note: The code style check is run as an integration test.
60+
- name: 'PHPCS: check code style without cache, no parallel'
61+
run: php bin/phpcs --no-cache --parallel=1

.github/workflows/test.yml

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
name: Test
22

33
on:
4-
# Run on all pushes and on all pull requests.
4+
# Run on pushes to `master` and on all pull requests.
55
# Prevent the build from running when there are only irrelevant changes.
66
push:
7+
branches:
8+
- master
79
paths-ignore:
810
- '**.md'
911
pull_request:
@@ -19,14 +21,7 @@ concurrency:
1921
jobs:
2022
build:
2123
runs-on: ubuntu-latest
22-
23-
strategy:
24-
matrix:
25-
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
26-
27-
name: "Build Phar on PHP: ${{ matrix.php }}"
28-
29-
continue-on-error: ${{ matrix.php == '8.2' }}
24+
name: "Build Phar on PHP: 8.0"
3025

3126
steps:
3227
- name: Checkout code
@@ -35,7 +30,7 @@ jobs:
3530
- name: Setup PHP
3631
uses: shivammathur/setup-php@v2
3732
with:
38-
php-version: ${{ matrix.php }}
33+
php-version: '8.0'
3934
coverage: none
4035
ini-values: phar.readonly=Off, error_reporting=-1, display_errors=On
4136

@@ -44,7 +39,6 @@ jobs:
4439

4540
- name: Upload the PHPCS phar
4641
uses: actions/upload-artifact@v3
47-
if: ${{ success() && matrix.php == '8.0' }}
4842
with:
4943
name: phpcs-phar
5044
path: ./phpcs.phar
@@ -53,14 +47,13 @@ jobs:
5347

5448
- name: Upload the PHPCBF phar
5549
uses: actions/upload-artifact@v3
56-
if: ${{ success() && matrix.php == '8.0' }}
5750
with:
5851
name: phpcbf-phar
5952
path: ./phpcbf.phar
6053
if-no-files-found: error
6154
retention-days: 28
6255

63-
# Both the below only check a few files which are rarely changed and therefore unlikely to have issues.
56+
# Both the below only check a file which is rarely changed and therefore unlikely to have issues.
6457
# This test is about testing that the phars are functional, *not* about whether the code style complies.
6558
- name: 'PHPCS: check code style using the Phar file to test the Phar is functional'
6659
run: php phpcs.phar ./scripts

0 commit comments

Comments
 (0)