3
3
issue_comment :
4
4
types : [created]
5
5
jobs :
6
- chromatic :
6
+ vrt :
7
+ # Only run when a "/vrt" comment is posted on a PR
7
8
if : ${{ github.event.issue.pull_request && github.event.comment.body == '/vrt' }}
8
9
runs-on : ubuntu-latest
9
10
permissions :
10
11
pull-requests : write
11
12
statuses : write
13
+ checks : write # Required for creating and updating check runs
12
14
steps :
13
- - name : Set pending status
15
+ # Create a required check to block merging until VRT passes
16
+ - name : Create Required Check
14
17
uses : actions/github-script@v7
15
18
with :
16
19
script : |
17
20
const { owner, repo } = context.repo;
18
- await github.rest.repos.createCommitStatus({
21
+ // Create initial check run
22
+ const check = await github.rest.checks.create({
19
23
owner,
20
24
repo,
21
- sha: context.sha,
22
- state: 'pending',
23
- context: 'VRT',
24
- description: 'VRT is running'
25
+ name: 'VRT Status',
26
+ head_sha: context.sha,
27
+ status: 'in_progress',
28
+ output: {
29
+ title: 'VRT Required',
30
+ summary: 'Visual Regression Test is now required for this PR'
31
+ }
25
32
});
26
33
- name : Checkout repository
27
34
uses : actions/checkout@v4
28
35
with :
29
- fetch-depth : 0
36
+ fetch-depth : 0 # Required for Chromatic to access git history
30
37
- name : Setup Node
31
38
uses : actions/setup-node@v4
32
39
with :
@@ -35,26 +42,36 @@ jobs:
35
42
cache-dependency-path : " **/package-lock.json"
36
43
- name : Install dependencies
37
44
run : npm ci
38
- - name : Publish to Chromatic
45
+ - name : Build @vfx-js/core
46
+ run : npm --workspace @vfx-js/core run build
47
+ # Run Chromatic VRT
48
+ - name : Run Chromatic
39
49
id : chromatic
40
50
uses : chromaui/action@latest
41
51
with :
42
52
projectToken : ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
43
- workingDir : packages/storybook
44
- buildScriptName : build-storybook
45
- - name : Update status
46
- if : always()
53
+ workingDir : packages/storybook # Specify Storybook directory in workspace
54
+ # Update check result based on Chromatic outcome
55
+ - name : Update Check Result
56
+ if : always() # Run this step even if previous steps fail
47
57
uses : actions/github-script@v7
48
58
with :
49
59
script : |-
50
60
const { owner, repo } = context.repo;
51
- await github.rest.repos.createCommitStatus({
61
+ const conclusion = '${{ steps.chromatic.outcome }}' === 'success' ? 'success' : 'failure';
62
+
63
+ // Update check run with final result
64
+ await github.rest.checks.create({
52
65
owner,
53
66
repo,
54
- sha: context.sha,
55
- state: '${{ steps.chromatic.outcome }}' === 'success' ? 'success' : 'failure',
56
- context: 'Chromatic',
57
- description: '${{ steps.chromatic.outcome }}' === 'success'
58
- ? 'VRT passed'
59
- : 'VRT failed'
67
+ name: 'VRT Status',
68
+ head_sha: context.sha,
69
+ status: 'completed',
70
+ conclusion: conclusion,
71
+ output: {
72
+ title: conclusion === 'success' ? 'VRT Passed' : 'VRT Failed',
73
+ summary: conclusion === 'success'
74
+ ? 'Visual Regression Test passed successfully'
75
+ : 'Visual Regression Test failed - please check the results'
76
+ }
60
77
});
0 commit comments