Skip to content

Commit 32bc26c

Browse files
jakejackson1claude
andcommitted
Run a smaller PHP matrix on pull requests and cancel runs a newer push replaces
A pull request runs Tests on PHP 5.6 and 8.5 on Ubuntu and Windows, and on 7.4 and 8.0 on Ubuntu: 6 of the 24 jobs. The label full-ci gives it the full matrix, which pushes to gravitypdf, a nightly schedule and a manual dispatch always run. A newer push to a pull request cancels the run it replaces; pushes to gravitypdf never cancel each other. The coding standard and PHPStan run as one Lint workflow. The e-invoice interop and PDF/X-4 policy workflows run on a pull request only when it changes the code they cover, and on every push to gravitypdf. Tests run with opcache.enable_cli. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 09e26ea commit 32bc26c

7 files changed

Lines changed: 101 additions & 81 deletions

File tree

‎.github/workflows/conformance.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ on:
1111
- "test"
1212
- "gravitypdf"
1313

14+
# A push to a pull request cancels the run it replaces. Other events run in a group of their own
15+
concurrency:
16+
group: "${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}"
17+
cancel-in-progress: true
18+
1419
jobs:
1520

1621
tests:

‎.github/workflows/cs.yml‎

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

‎.github/workflows/einvoice-interop.yml‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,35 @@
33
name: "E-invoice interop"
44

55
on:
6+
# Pull requests run this only when they change one of these paths
67
pull_request:
8+
paths:
9+
- ".github/workflows/einvoice-interop.yml"
10+
- "composer.json"
11+
- "phpunit.xml"
12+
- "src/Invoice/**"
13+
- "src/Pdf/**"
14+
- "src/Utils/**"
15+
- "src/Writer/**"
16+
- "src/Xmp/**"
17+
- "tests/Mpdf/Invoice/**"
18+
- "tests/Mpdf/InteropPackage.php"
19+
- "tests/Mpdf/InvoiceFixtures.php"
20+
- "tests/Mpdf/PageStreams.php"
21+
- "tests/data/invoice/**"
22+
workflow_dispatch:
723
push:
824
branches:
925
- "master"
1026
- "development"
1127
- "test"
1228
- "gravitypdf"
1329

30+
# A push to a pull request cancels the run it replaces. Other events run in a group of their own
31+
concurrency:
32+
group: "${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}"
33+
cancel-in-progress: true
34+
1435
jobs:
1536

1637
interop:
@@ -56,7 +77,7 @@ jobs:
5677
restore-keys: "composer-${{ runner.os }}-php${{ matrix.php-version }}-einvoice-"
5778

5879
- name: "Install dependencies"
59-
run: "composer install --no-interaction --no-progress && composer require --dev ${{ matrix.packages }} --no-interaction --no-progress"
80+
run: "composer require --dev ${{ matrix.packages }} --no-update && composer install --no-interaction --no-progress"
6081

6182
- name: "Tests"
6283
run: composer test -- --group=interop
Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
22

3-
name: "Static Analysis check"
3+
name: "Lint"
44

55
on:
66
pull_request:
@@ -11,22 +11,27 @@ on:
1111
- "test"
1212
- "gravitypdf"
1313

14+
# A push to a pull request cancels the run it replaces. Other events run in a group of their own
15+
concurrency:
16+
group: "${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}"
17+
cancel-in-progress: true
18+
1419
jobs:
1520

16-
stan:
21+
lint:
1722

18-
name: "Static Analysis check"
23+
name: "Lint"
1924

20-
runs-on: ${{ matrix.operating-system }}
25+
runs-on: ubuntu-latest
2126

2227
strategy:
28+
fail-fast: false
2329
matrix:
30+
# PHPStan reports differ between PHP versions, so it runs on both
2431
php-version:
2532
- "8.2"
2633
- "8.5"
2734

28-
operating-system: [ubuntu-latest]
29-
3035
steps:
3136
- name: "Checkout"
3237
uses: "actions/checkout@v7"
@@ -52,7 +57,13 @@ jobs:
5257
restore-keys: "composer-${{ runner.os }}-php${{ matrix.php-version }}-phpstan-"
5358

5459
- name: "Install dependencies"
55-
run: "composer install --no-interaction --no-progress && composer require \"phpstan/phpstan:^2.0\""
60+
id: install
61+
run: "composer require \"phpstan/phpstan:^2.0\" --no-update && composer install --no-interaction --no-progress"
62+
63+
- name: "Coding standard"
64+
if: matrix.php-version == '8.2'
65+
run: composer cs
5666

57-
- name: "Static Analysis check"
67+
- name: "Static analysis"
68+
if: "!cancelled() && steps.install.outcome == 'success'"
5869
run: vendor/bin/phpstan --no-progress

‎.github/workflows/pdfx4-policy.yml‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,34 @@
66
name: "PDF/X-4 Policy"
77

88
on:
9+
# Pull requests run this only when they change one of these paths
910
pull_request:
11+
paths:
12+
- ".github/workflows/pdfx4-policy.yml"
13+
- "composer.json"
14+
- "data/iccprofiles/**"
15+
- "src/Color/**"
16+
- "src/Fonts/Color/**"
17+
- "src/Gradient.php"
18+
- "src/Image/**"
19+
- "src/Pdf/**"
20+
- "src/Writer/**"
21+
- "src/Xmp/**"
22+
- "tests/data/icc/**"
23+
- "utils/verapdf/**"
24+
workflow_dispatch:
1025
push:
1126
branches:
1227
- "master"
1328
- "development"
1429
- "test"
1530
- "gravitypdf"
1631

32+
# A push to a pull request cancels the run it replaces. Other events run in a group of their own
33+
concurrency:
34+
group: "${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}"
35+
cancel-in-progress: true
36+
1737
jobs:
1838

1939
policy:

‎.github/workflows/snapshots.yml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ on:
1111
- "test"
1212
- "gravitypdf"
1313

14+
# A push to a pull request cancels the run it replaces. Other events run in a group of their own
15+
concurrency:
16+
group: "${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}"
17+
cancel-in-progress: true
18+
1419
jobs:
1520

1621
tests:
@@ -43,6 +48,7 @@ jobs:
4348
run: |
4449
# Older policies forbid the PDF coder. Snapshots only rasterise when they differ, so read one now to fail early
4550
sudo sed -i 's/rights="none" pattern="PDF"/rights="read|write" pattern="PDF"/' /etc/ImageMagick-*/policy.xml
51+
# shellcheck disable=SC2016
4652
php -r '$i = new Imagick(); $i->setResolution(120, 120); $i->readImage("tests/data/snapshots/fixed-position-html.pdf"); printf("%s read %d page of %dx%d px\n", Imagick::getVersion()["versionString"], $i->getNumberImages(), $i->getImageWidth(), $i->getImageHeight());'
4753
4854
- name: "Locate Composer cache"

‎.github/workflows/tests.yml‎

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,51 @@ name: "Tests"
44

55
on:
66
pull_request:
7+
types: [opened, synchronize, reopened, labeled]
78
push:
89
branches:
910
- "master"
1011
- "development"
1112
- "test"
1213
- "gravitypdf"
14+
schedule:
15+
- cron: "0 17 * * *"
16+
workflow_dispatch:
17+
18+
# A push to a pull request cancels the run it replaces. Other events, and a label other than full-ci, run in a group of their own
19+
concurrency:
20+
group: "${{ github.workflow }}-${{ (github.event.action != 'labeled' || github.event.label.name == 'full-ci') && github.event.pull_request.number || github.run_id }}"
21+
cancel-in-progress: true
1322

1423
jobs:
1524

1625
tests:
1726

1827
name: "Tests"
1928

29+
if: github.event.action != 'labeled' || github.event.label.name == 'full-ci'
30+
2031
runs-on: ${{ matrix.operating-system }}
2132

2233
strategy:
2334
fail-fast: false
24-
matrix:
25-
php-version:
26-
- "5.6"
27-
- "7.0"
28-
- "7.1"
29-
- "7.2"
30-
- "7.3"
31-
- "7.4"
32-
- "8.0"
33-
- "8.1"
34-
- "8.2"
35-
- "8.3"
36-
- "8.4"
37-
- "8.5"
38-
operating-system: [ubuntu-latest, windows-latest]
35+
# A pull request without the full-ci label runs 5.6 and 8.5 on both systems, and 7.4 and 8.0 on Ubuntu
36+
matrix: >-
37+
${{ fromJSON(
38+
(github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'full-ci'))
39+
&& '{
40+
"php-version": ["5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3", "8.4", "8.5"],
41+
"operating-system": ["ubuntu-latest", "windows-latest"]
42+
}'
43+
|| '{
44+
"php-version": ["5.6", "7.4", "8.0", "8.5"],
45+
"operating-system": ["ubuntu-latest", "windows-latest"],
46+
"exclude": [
47+
{"php-version": "7.4", "operating-system": "windows-latest"},
48+
{"php-version": "8.0", "operating-system": "windows-latest"}
49+
]
50+
}'
51+
) }}
3952
4053
steps:
4154
- name: "Checkout"
@@ -48,7 +61,7 @@ jobs:
4861
php-version: "${{ matrix.php-version }}"
4962
extensions: "mbstring, gd, bcmath, bz2, fileinfo"
5063
tools: composer:v2
51-
ini-values: error_reporting=-1
64+
ini-values: error_reporting=-1, opcache.enable_cli=1
5265

5366
- name: "Locate Composer cache"
5467
id: composer-cache

0 commit comments

Comments
 (0)