-
Notifications
You must be signed in to change notification settings - Fork 0
504 lines (414 loc) · 17 KB
/
scoring.yml
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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
name: Scoring
on:
workflow_run:
workflows:
- Request
types:
- completed
env:
TZ: "Asia/Tokyo"
WSH_SCORING_DEBUG: "${{ secrets.WSH_SCORING_DEBUG }}"
WSH_SCORING_TARGET_PATHS: "${{ secrets.WSH_SCORING_TARGET_PATHS }}"
DISCORD_WEBHOOK_URL: "${{ secrets.DISCORD_WEBHOOK_URL }}"
jobs:
payload:
runs-on: ubuntu-20.04
if: ${{ github.event.workflow_run.conclusion == 'success' }}
outputs:
competition-status: ${{ steps.status.outputs.result }}
result: ${{ steps.payload.outputs.result }}
steps:
- name: Download payload
uses: dawidd6/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: .github/workflows/request.yml
run_id: ${{ github.event.workflow_run.id }}
name: payload.json
path: /tmp
- name: Read payload
uses: actions/[email protected]
id: payload
with:
result-encoding: json
script: |
const payload = require('/tmp/payload.json');
return payload;
- name: Check competition status
uses: actions/[email protected]
id: status
with:
result-encoding: string
script: |
const payload = require('/tmp/payload.json');
const startAt = new Date('2024-12-19T00:00:00.000+09:00');
const endAt = new Date('2025-01-31T23:59:59.000+09:00');
const requestedAt = new Date(payload.request_time);
if (requestedAt < startAt || endAt < requestedAt) {
return 'closed';
}
return 'opened';
vrt:
runs-on: ubuntu-20.04
needs:
- payload
if: needs.payload.outputs.competition-status == 'opened'
outputs:
details: ${{ steps.details.outputs.result }}
result: ${{ steps.result.outputs.result }}
concurrency: scoring-${{ fromJSON(needs.payload.outputs.result).id }}
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
node-version: "18"
cache: "yarn"
- run: yarn install --frozen-lockfile
- run: yarn build
- run: sudo apt-get install -y fonts-noto-cjk
- name: Run VRT
id: vrt
run: |
yarn run vrt:capture --url ${TARGET_URL}
yarn run vrt:detect
env:
TARGET_URL: ${{ fromJSON(needs.payload.outputs.result).url }}
- name: Upload payload
uses: actions/[email protected]
with:
name: screenshots
path: ./scripts/vrt/tmp/*
retention-days: 1
- name: Read details
uses: actions/[email protected]
id: details
with:
result-encoding: json
script: |
const payload = require('./scripts/vrt/tmp/reg.json');
return payload;
- name: Read result
uses: actions/[email protected]
id: result
with:
result-encoding: string
script: |
const payload = require('./scripts/vrt/tmp/reg.json');
return payload.failedItems.length === 0 ? 'success' : 'failed';
scoring:
runs-on: ubuntu-20.04
needs:
- payload
- vrt
outputs:
result: ${{ steps.scoring.outputs.export }}
concurrency: scoring-${{ fromJSON(needs.payload.outputs.result).id }}
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
node-version: "18"
cache: "yarn"
- run: yarn install --frozen-lockfile
- run: yarn build
- run: sudo apt-get install -y fonts-noto-cjk
- name: Scoring
id: scoring
run: |
yarn run scoring \
--id ${TARGET_ID} \
--url ${TARGET_URL}
env:
TARGET_ID: ${{ fromJSON(needs.payload.outputs.result).id }}
TARGET_URL: ${{ fromJSON(needs.payload.outputs.result).url }}
update:
runs-on: ubuntu-20.04
needs:
- payload
- vrt
- scoring
if: needs.vrt.outputs.result == 'success'
outputs:
result: ${{ steps.update.outputs.export }}
concurrency: update-leader-board
steps:
- uses: actions/[email protected]
with:
ref: main
- uses: actions/[email protected]
with:
node-version: "18"
cache: "yarn"
- run: yarn install --frozen-lockfile
- run: yarn build
- name: Update leader board
id: update
run: |
yarn run update \
--markdown ${GITHUB_WORKSPACE}/README.md \
--score-csv ${GITHUB_WORKSPACE}/score.csv \
--id ${TARGET_ID} \
--url ${TARGET_URL} \
--score ${TARGET_SCORE}
env:
TARGET_ID: ${{ fromJSON(needs.payload.outputs.result).id }}
TARGET_URL: ${{ fromJSON(needs.payload.outputs.result).url }}
TARGET_SCORE: ${{ fromJSON(needs.scoring.outputs.result).result.score }}
- name: Commit leader board
uses: stefanzweifel/[email protected]
with:
commit_user_name: "github-actions[bot]"
commit_user_email: "github-actions[bot]@users.noreply.github.com"
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
comment-payload:
runs-on: ubuntu-20.04
needs:
- payload
steps:
- name: Competition is Closed Comment
uses: peter-evans/[email protected]
if: needs.payload.outputs.competition-status != 'opened'
with:
comment-id: ${{ fromJSON(needs.payload.outputs.result).report_comment_id }}
edit-mode: replace
body: |
:warning: **スコアを計測できませんでした**
コンテスト開催前、もしくは、コンテストが終了しています
---
:information_source: `/retry` とコメントすると、もう一度計測ができます
:information_source: 登録内容を変更する場合は、issue を閉じて作り直してください
- name: Comment
uses: peter-evans/[email protected]
if: needs.payload.outputs.competition-status == 'opened'
with:
comment-id: ${{ fromJSON(needs.payload.outputs.result).report_comment_id }}
edit-mode: replace
body: |
## レギュレーションチェック
:hourglass_flowing_sand: **VRT を実行しています**
---
Actions: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
comment-failure-vrt:
runs-on: ubuntu-20.04
needs:
- payload
- vrt
- comment-payload
if: always() && needs.vrt.result == 'failure'
steps:
- name: Comment
uses: peter-evans/[email protected]
with:
comment-id: ${{ fromJSON(needs.payload.outputs.result).report_comment_id }}
edit-mode: replace
body: |
## レギュレーションチェック
:exclamation: **VRT が実行できませんでした**
次を確認してください
- URL が間違っていませんか
- API `POST /api/initialize` が実行できますか
- 計測対象のページは、誰でも閲覧できるようになっていますか
- エラーページ以外では、ステータスコードが 200 で返却されますか
---
Actions: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
:information_source: `/retry` とコメントすると、もう一度計測ができます
:information_source: 登録内容を変更する場合は、issue を閉じて作り直してください
comment-vrt:
runs-on: ubuntu-20.04
needs:
- payload
- vrt
- comment-payload
steps:
- name: Comment
uses: peter-evans/[email protected]
with:
comment-id: ${{ fromJSON(needs.payload.outputs.result).report_comment_id }}
edit-mode: replace
body: |
## レギュレーションチェック
${{ (needs.vrt.outputs.result == 'success' && '**差分はありませんでした**') || '**一部のページに差分があります**' }}
<details>
<summary>差分が見つかったページ</summary>
- :information_source: スクリーンショットは、スコア計測後に、Actions の Artifacts からダウンロードできます
```json
${{ toJSON(fromJSON(needs.vrt.outputs.details).failedItems) }}
```
</details>
## スコア
:hourglass_flowing_sand: **Lighthouse でスコアを計測しています**
---
Actions: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
comment-failure-scoring:
runs-on: ubuntu-20.04
needs:
- payload
- vrt
- scoring
- comment-vrt
if: always() && needs.scoring.result == 'failure'
steps:
- name: Comment
uses: peter-evans/[email protected]
with:
comment-id: ${{ fromJSON(needs.payload.outputs.result).report_comment_id }}
edit-mode: replace
body: |
## レギュレーションチェック
${{ (needs.vrt.outputs.result == 'success' && '**差分はありませんでした**') || '**一部のページに差分があります**' }}
<details>
<summary>差分が見つかったページ</summary>
- :information_source: スクリーンショットは、スコア計測後に、Actions の Artifacts からダウンロードできます
```json
${{ toJSON(fromJSON(needs.vrt.outputs.details).failedItems) }}
```
</details>
## スコア
:exclamation: **Lighthouse の計測ができませんでした**
次を確認してください
- URL が間違っていませんか
- 計測対象のページは、誰でも閲覧できるようになっていますか
- エラーページ以外では、ステータスコードが 200 で返却されますか
---
Actions: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
:information_source: `/retry` とコメントすると、もう一度計測ができます
:information_source: 登録内容を変更する場合は、issue を閉じて作り直してください
comment-scoring:
runs-on: ubuntu-20.04
needs:
- payload
- vrt
- scoring
- comment-vrt
steps:
- name: Comment
uses: peter-evans/[email protected]
if: needs.vrt.outputs.result == 'success'
with:
comment-id: ${{ fromJSON(needs.payload.outputs.result).report_comment_id }}
edit-mode: replace
body: |
## レギュレーションチェック
${{ (needs.vrt.outputs.result == 'success' && '**差分はありませんでした**') || '**一部のページに差分があります**' }}
<details>
<summary>差分が見つかったページ</summary>
- :information_source: スクリーンショットは、スコア計測後に、Actions の Artifacts からダウンロードできます
```json
${{ toJSON(fromJSON(needs.vrt.outputs.details).failedItems) }}
```
</details>
## スコア
スコアは **${{ fromJSON(needs.scoring.outputs.result).result.score }}** です
:hourglass_flowing_sand: リーダーボードを更新中です...
<details>
<summary>buildInfo</summary>
```json
${{ toJSON(fromJSON(needs.scoring.outputs.result).buildInfo) }}
```
</details>
---
Actions: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Comment
uses: peter-evans/[email protected]
if: needs.vrt.outputs.result != 'success'
with:
comment-id: ${{ fromJSON(needs.payload.outputs.result).report_comment_id }}
edit-mode: replace
body: |
## レギュレーションチェック
${{ (needs.vrt.outputs.result == 'success' && '**差分はありませんでした**') || '**一部のページに差分があります**' }}
<details>
<summary>差分が見つかったページ</summary>
- :information_source: スクリーンショットは、スコア計測後に、Actions の Artifacts からダウンロードできます
```json
${{ toJSON(fromJSON(needs.vrt.outputs.details).failedItems) }}
```
</details>
## スコア
スコアは **${{ fromJSON(needs.scoring.outputs.result).result.score }}** です
:warning: VRT で差分があったため、リーダーボードには反映されません
<details>
<summary>buildInfo</summary>
```json
${{ toJSON(fromJSON(needs.scoring.outputs.result).buildInfo) }}
```
</details>
---
Actions: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
:information_source: `/retry` とコメントすると、もう一度計測ができます
:information_source: 登録内容を変更する場合は、issue を閉じて作り直してください
comment-failure-update:
runs-on: ubuntu-20.04
needs:
- payload
- vrt
- scoring
- update
- comment-scoring
if: always() && needs.update.result == 'failure'
steps:
- name: Comment
uses: peter-evans/[email protected]
with:
comment-id: ${{ fromJSON(needs.payload.outputs.result).report_comment_id }}
edit-mode: replace
body: |
## レギュレーション
${{ (needs.vrt.outputs.result == 'success' && '**差分はありませんでした**') || '**一部のページに差分があります**' }}
<details>
<summary>差分が見つかったページ</summary>
- :information_source: スクリーンショットは、スコア計測後に、Actions の Artifacts からダウンロードできます
```json
${{ toJSON(fromJSON(needs.vrt.outputs.details).failedItems) }}
```
</details>
## スコア
スコアは **${{ fromJSON(needs.scoring.outputs.result).result.score }}** です
:exclamation: **リーダーボードが更新できませんでした**
<details>
<summary>buildInfo</summary>
```json
${{ toJSON(fromJSON(needs.scoring.outputs.result).buildInfo) }}
```
</details>
---
Actions: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
:information_source: `/retry` とコメントすると、もう一度計測ができます
:information_source: 登録内容を変更する場合は、issue を閉じて作り直してください
comment-update:
runs-on: ubuntu-20.04
needs:
- payload
- vrt
- scoring
- update
- comment-scoring
steps:
- name: Comment
uses: peter-evans/[email protected]
with:
comment-id: ${{ fromJSON(needs.payload.outputs.result).report_comment_id }}
edit-mode: replace
body: |
## レギュレーションチェック
${{ (needs.vrt.outputs.result == 'success' && '**差分はありませんでした**') || '**一部のページに差分があります**' }}
<details>
<summary>差分が見つかったページ</summary>
- :information_source: スクリーンショットは、スコア計測後に、Actions の Artifacts からダウンロードできます
```json
${{ toJSON(fromJSON(needs.vrt.outputs.details).failedItems) }}
```
</details>
## スコア
スコアは **${{ fromJSON(needs.scoring.outputs.result).result.score }}** です
現在、**${{ fromJSON(needs.update.outputs.result).rank }} 位**です
<details>
<summary>buildInfo</summary>
```json
${{ toJSON(fromJSON(needs.scoring.outputs.result).buildInfo) }}
```
</details>
---
Actions: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
:information_source: `/retry` とコメントすると、もう一度計測ができます
:information_source: 登録内容を変更する場合は、issue を閉じて作り直してください