-
Notifications
You must be signed in to change notification settings - Fork 1
357 lines (307 loc) · 12.5 KB
/
pr.yaml
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
on: pull_request
name: PR Review
jobs:
fail-for-do-not-merge:
if: contains(github.event.pull_request.labels.*.name, 'not ready for merge')
runs-on: ubuntu-latest
steps:
- name: Fail if PR is labeled with not ready for merge
run: |
echo "This PR can't be merged, due to the 'not ready for merge' label."
exit 1
changelog:
runs-on: ubuntu-latest
name: Changelog should be updated
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Git fetch
run: git fetch
- name: Check that changelog has been updated.
run: git diff --exit-code origin/${{ github.base_ref }} -- CHANGELOG.md && exit 1 || exit 0
test-composer-files:
name: Validate composer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
extensions: ctype, dom, iconv, json, zip, gd, soap
coverage: none
tools: composer:v2
# https://github.com/shivammathur/setup-php#cache-composer-dependencies
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Validate composer files
run: |
composer validate composer.json
- name: Check composer file is normalized
run: |
composer install --no-interaction --no-progress
composer normalize composer.json --dry-run
coding-standards-phpcs:
name: PHP - Check Coding Standards
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
extensions: ctype, dom, iconv, json, zip, gd, soap
coverage: none
tools: composer:v2
# https://github.com/shivammathur/setup-php#cache-composer-dependencies
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Dependencies
run: |
composer install --no-interaction --no-progress --no-scripts
# @see https://github.com/Dealerdirect/phpcodesniffer-composer-installer#calling-the-plugin-directly
composer run-script install-codestandards
- name: PHPCS
run: |
composer coding-standards-check/phpcs
coding-standards-twig-cs-fixer:
name: Twig - Check Coding Standards
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
extensions: ctype, dom, iconv, json, zip, gd, soap
coverage: none
tools: composer:v2
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Dependencies
run: |
composer install --no-interaction --no-progress --no-scripts
# @see https://github.com/Dealerdirect/phpcodesniffer-composer-installer#calling-the-plugin-directly
composer run-script install-codestandards
- name: TwigCS
run: |
composer coding-standards-check/twig-cs-fixer
coding-standards-markdown:
name: Yarn - Check Coding Standards (Node ${{ matrix.node }})
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '16' ]
steps:
- uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- run: |
yarn install
yarn coding-standards-check
code-analysis:
name: PHP - Code analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
extensions: ctype, dom, iconv, json, zip, gd, soap
coverage: none
tools: composer:v2
# https://github.com/shivammathur/setup-php#cache-composer-dependencies
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Dependencies
run: |
# Using `--no-scripts` breaks something with mglaman/drupal-check.
composer install --no-interaction --no-progress --no-scripts
- name: code-analysis
run: |
composer code-analysis
coding-standards-custom-themes:
name: Yarn - Check Coding Standards in custom themes
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup docker network
run: docker network create frontend
- name: Install build dependencies
run: docker compose run --rm node yarn --cwd /app/web/themes/custom/hoeringsportal install
- name: Check coding standards
run: docker compose run --rm node yarn --cwd /app/web/themes/custom/hoeringsportal check-coding-standards
check-custom-theme-assets:
name: Check custom theme assets are up to date
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup docker network
run: docker network create frontend
- name: Install build dependencies
run: docker compose run --rm node yarn --cwd /app/web/themes/custom/hoeringsportal install
- name: Build theme assets
run: docker compose run --rm node yarn --cwd /app/web/themes/custom/hoeringsportal build
- name: Check for changes in built css
run: git diff --diff-filter=ACMRT --exit-code web/themes/custom/hoeringsportal/build
install-site:
name: Check that site can be installed
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install site
run: |
docker network create frontend
docker compose pull
docker compose up --detach
# Important: Use --no-interaction to make https://getcomposer.org/doc/06-config.md#discard-changes have effect.
docker compose exec --user root phpfpm composer install --no-interaction
# Install the site
docker compose exec --user root phpfpm vendor/bin/drush site:install minimal --existing-config --yes
# Build theme assets
docker compose run --rm node yarn --cwd /app/web/themes/custom/hoeringsportal install
docker compose run --rm node yarn --cwd /app/web/themes/custom/hoeringsportal build
- name: Open site
run: |
# Open the site
echo $(docker compose exec phpfpm vendor/bin/drush --uri=http://$(docker compose port nginx 8080) user:login)
config-check:
name: Check that config is up to date
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install site
run: |
docker network create frontend
docker compose pull
docker compose up --detach
# Important: Use --no-interaction to make https://getcomposer.org/doc/06-config.md#discard-changes have effect.
docker compose exec --user root phpfpm composer install --no-interaction
# Install the site
docker compose exec --user root phpfpm vendor/bin/drush site:install --existing-config --yes
- name: Export config
run: docker compose exec --user root phpfpm vendor/bin/drush config:export --yes
- name: Check for changes in config
run: git diff --diff-filter=ACMRT --exit-code config/
playwright-tests:
if: false # Disabled due to timeout issues when running on GitHub.
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install site
run: |
docker network create frontend
docker compose pull
docker compose --profile test up --detach
cat > web/sites/default/settings.local.php <<'EOL'
<?php
$settings['hoeringsportal_openid_connect']['openid_connect'] = [
'clientId' => 'client-id',
'clientSecret' => 'client-secret',
'openIDConnectMetadataUrl' => 'http://idp-citizen.hoeringsportal.local.itkdev.dk/.well-known/openid-configuration',
];
EOL
# Important: Use --no-interaction to make https://getcomposer.org/doc/06-config.md#discard-changes have effect.
docker compose exec --user root phpfpm composer install --no-interaction
# Install the site
docker compose exec --user root phpfpm vendor/bin/drush site:install minimal --existing-config --yes
# Build theme assets
docker compose run --rm node yarn --cwd /app/web/themes/custom/hoeringsportal install
docker compose run --rm node yarn --cwd /app/web/themes/custom/hoeringsportal build
- name: Run Playwright
run: |
docker compose run --rm node yarn install
docker compose run --rm playwright npx playwright install
docker compose run --rm playwright npx playwright test --retries 3
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
update-site:
name: Check that site can be updated
runs-on: ubuntu-latest
steps:
# Install site from our base ref
- uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}
- name: setup-docker-and-composer
run: |
docker network create frontend
docker compose pull
docker compose up --detach
# Important: Use --no-interaction to make https://getcomposer.org/doc/06-config.md#discard-changes have effect.
docker compose exec --user root phpfpm composer install --no-interaction
- name: Install site
run: |
# Add some local settings.
cat > web/sites/default/settings.local.php <<'EOF'
<?php
$settings['hash_salt'] = '${{ github.head_ref }}';
EOF
cat web/sites/default/settings.local.php
# Install the site from config
docker compose exec --user root phpfpm vendor/bin/drush site:install --existing-config --yes
- name: Clean up root stuff
run: |
sudo chown -Rv $USER:$USER vendor/ web/ private-files/ || true
sudo chmod -Rv a+w web/sites/default || true
# Install site with our current ref
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
# Keep our local settings (cf.
# https://github.com/actions/checkout?tab=readme-ov-file#usage)
clean: false
# - run: |
# sudo git fetch
# sudo git checkout ${{ github.head_ref }}
- name: setup-docker-and-composer
run: |
docker compose pull
docker compose up --detach
# Important: Use --no-interaction to make https://getcomposer.org/doc/06-config.md#discard-changes have effect.
docker compose exec --user root phpfpm composer install --no-interaction
- name: Update site
run: |
docker compose exec --user root phpfpm vendor/bin/drush deploy --yes