Skip to content

Commit b8a08c9

Browse files
committed
GH Actions: split PHAR building task off to own script
While it is still a good idea to make sure the PHAR building script works on all supported PHP versions, it is not necessary to run this task against all PHP versions on all pushes, nor to have the test runs wait until all PHAR building builds are done, as for the tests we only need the PHARs generated on PHP 8.0, which are the ones used in a release. This commit splits the PHAR building job off to its own script, only keeping the PHAR build against PHP 8.0 in the `test` workflow. While this does mean there is now some duplication in the scripts, I find it more relevant to make the builds faster.
1 parent d900658 commit b8a08c9

File tree

2 files changed

+57
-12
lines changed

2 files changed

+57
-12
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/test.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,7 @@ concurrency:
1919
jobs:
2020
build:
2121
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' }}
22+
name: "Build Phar on PHP: 8.0"
3023

3124
steps:
3225
- name: Checkout code
@@ -35,7 +28,7 @@ jobs:
3528
- name: Setup PHP
3629
uses: shivammathur/setup-php@v2
3730
with:
38-
php-version: ${{ matrix.php }}
31+
php-version: '8.0'
3932
coverage: none
4033
ini-values: phar.readonly=Off, error_reporting=-1, display_errors=On
4134

@@ -44,7 +37,6 @@ jobs:
4437

4538
- name: Upload the PHPCS phar
4639
uses: actions/upload-artifact@v3
47-
if: ${{ success() && matrix.php == '8.0' }}
4840
with:
4941
name: phpcs-phar
5042
path: ./phpcs.phar
@@ -53,14 +45,13 @@ jobs:
5345

5446
- name: Upload the PHPCBF phar
5547
uses: actions/upload-artifact@v3
56-
if: ${{ success() && matrix.php == '8.0' }}
5748
with:
5849
name: phpcbf-phar
5950
path: ./phpcbf.phar
6051
if-no-files-found: error
6152
retention-days: 28
6253

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

0 commit comments

Comments
 (0)