Repository navigation
257 lines (215 loc) · 10.2 KB
/
Copy pathci.yml
File metadata and controls
257 lines (215 loc) · 10.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
name: Run tests
on:
push:
branches: [main]
pull_request:
branches: ["main"]
workflow_dispatch:
inputs:
google_docs_strict:
description: "Fail job if google:check reports gaps"
required: false
default: "false"
schedule:
- cron: "0 0 * * SUN"
permissions:
contents: read
jobs:
# Coding standards and static analysis are PHP-version agnostic here, so they run
# once, in a dedicated job. Keeping them out of the test matrix also keeps pcov
# disabled for them: setup-php enables coverage globally in php.ini, and pcov makes
# php-cs-fixer roughly four times slower.
qa:
name: Coding standards and static analysis
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup PHP
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0
with:
# Matches the platform the QA tooling is pinned to in tools/*/composer.json.
php-version: "8.4"
# Dependabot does not track tools installed by setup-php: bump these
# versions and their SHA-256 checksums by hand, in every job.
tools: >-
composer:2.11.1@sha256:6f1b891e1d4927d62740276c540fb490e47689e19e102c49e8da849794882f8c,
castor:1.9.1@sha256:3312568da9a593ad7d3ef6548f05c12d994dbc7140634e401531dc8d7de41764
coverage: none
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- name: Cache Composer downloads
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-qa-${{ runner.os }}-${{ hashFiles('composer.json', 'tools/*/composer.lock') }}
restore-keys: |
composer-qa-${{ runner.os }}-
- name: Cache QA tooling vendors
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: tools/*/vendor
key: tools-vendor-qa-${{ runner.os }}-${{ hashFiles('tools/*/composer.lock') }}
# PHP CS Fixer skips any file whose content hash is already known, so a restored
# cache turns the run into a no-op for everything the branch did not touch. The
# cache embeds the fixer version and the rule set, and invalidates itself when
# either changes.
- name: Cache the PHP CS Fixer result cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .php-cs-fixer.cache
key: php-cs-fixer-qa-${{ runner.os }}-${{ hashFiles('.php-cs-fixer.php', 'tools/php-cs-fixer/composer.lock') }}-${{ github.sha }}
restore-keys: |
php-cs-fixer-qa-${{ runner.os }}-${{ hashFiles('.php-cs-fixer.php', 'tools/php-cs-fixer/composer.lock') }}-
- name: Cache PHPStan result cache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: tools/phpstan/var
key: phpstan-${{ runner.os }}-${{ github.sha }}
restore-keys: |
phpstan-${{ runner.os }}-
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Install qa tooling
run: castor qa:install
- name: Check PHP coding standards
run: castor qa:cs --dry-run
- name: Run PHPStan
run: castor qa:phpstan
# The generators do not depend on the PHP version either, and regenerating the whole
# schema.org vocabulary is the slowest thing this workflow does, so it runs once here
# rather than inside the test matrix.
vocabularies:
name: Vocabulary generation
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup PHP
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0
with:
php-version: "8.4"
# Dependabot does not track tools installed by setup-php: bump these
# versions and their SHA-256 checksums by hand, in every job.
tools: >-
composer:2.11.1@sha256:6f1b891e1d4927d62740276c540fb490e47689e19e102c49e8da849794882f8c,
castor:1.9.1@sha256:3312568da9a593ad7d3ef6548f05c12d994dbc7140634e401531dc8d7de41764
coverage: none
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- name: Cache Composer downloads
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-vocabularies-${{ runner.os }}-${{ hashFiles('composer.json', 'tools/*/composer.lock') }}
restore-keys: |
composer-vocabularies-${{ runner.os }}-
- name: Cache QA tooling vendors
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: tools/*/vendor
key: tools-vendor-vocabularies-${{ runner.os }}-${{ hashFiles('tools/*/composer.lock') }}
# No PHP CS Fixer cache here on purpose: the generators emit code that still needs
# fixing, so every file they write misses the cache, which only knows the hashes of
# already fixed files.
# Keyed on the file holding SchemaOrg::VERSION, so bumping the vocabulary version
# is what triggers a fresh download of the definition file.
- name: Cache the schema.org definition file
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: var/cache/schema-org
key: schema-org-definition-${{ hashFiles('generators/SchemaOrg/SchemaOrg.php') }}
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Install qa tooling
run: castor qa:install
- name: Verify Google docs coverage (report-only by default)
continue-on-error: ${{ github.event_name != 'workflow_dispatch' || inputs.google_docs_strict != 'true' }}
run: castor google:check
- name: Check that schema.org types and properties classes can be generated
run: castor schema-org:generate
- name: Check that Google types and properties classes can be generated
run: castor google:generate
- name: Check that the committed generated classes match their vocabulary definitions
run: git diff --exit-code -- src/Vocabularies/Generated
ci:
name: Test with PHP ${{ matrix.php-version }}
strategy:
fail-fast: false
matrix:
php-version: ["8.4", "8.5"]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup PHP
uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0
with:
php-version: ${{ matrix.php-version }}
# Dependabot does not track tools installed by setup-php: bump these
# versions and their SHA-256 checksums by hand, in every job.
tools: >-
composer:2.11.1@sha256:6f1b891e1d4927d62740276c540fb490e47689e19e102c49e8da849794882f8c,
castor:1.9.1@sha256:3312568da9a593ad7d3ef6548f05c12d994dbc7140634e401531dc8d7de41764
coverage: pcov
- name: Get Composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- name: Cache Composer downloads
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.json', 'tools/*/composer.lock') }}
restore-keys: |
composer-${{ runner.os }}-${{ matrix.php-version }}-
- name: Cache QA tooling vendors
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: tools/*/vendor
key: tools-vendor-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('tools/*/composer.lock') }}
- name: Cache the W3C test suite (pinned commit)
# Skipped on the weekly scheduled run, which re-downloads the suite from the
# upstream main branch to surface W3C drift.
if: github.event_name != 'schedule'
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: var/cache/w3c-json-ld-api
key: w3c-test-suite-${{ hashFiles('.castor/qa.php') }}
- name: Validate composer.json and composer.lock
run: composer validate --strict
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Check platform requirements
run: composer check-platform-reqs
- name: Install qa tooling
run: castor qa:install
- name: Prepare the W3C test suite from upstream main (drift check)
if: github.event_name == 'schedule'
run: castor qa:phpunit:prepare --force --ref main
- name: Run the tests with coverage
run: castor qa:phpunit:coverage
- name: Upload coverage report
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: coverage-clover-php${{ matrix.php-version }}
path: var/cache/coverage/clover.xml
- name: Download the benchmark fixtures (weekly)
if: github.event_name == 'schedule'
run: castor qa:phpunit:download-fixtures
- name: Run the benchmarks (weekly, for the record)
if: github.event_name == 'schedule'
run: castor qa:bench:all
- name: Upload benchmark reports
if: github.event_name == 'schedule'
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: benchmark-reports-php${{ matrix.php-version }}
path: var/cache/benchmark-results-*.html