-
Notifications
You must be signed in to change notification settings - Fork 6
194 lines (190 loc) · 7.24 KB
/
approve-playwright-snapshots.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
name: Update Snapshots on Comment
on:
issue_comment:
types: [created]
jobs:
comment-action-start:
name: Comment action started
runs-on: ubuntu-latest
if: github.event.issue.pull_request && contains(github.event.comment.body, '/approve-snapshots') && github.event.comment.author_association == 'MEMBER'
outputs:
pr_head: ${{ steps.comment-branch.outputs.head_ref }}
steps:
- name: Get branch of PR
uses: xt0rted/pull-request-comment-branch@v3
id: comment-branch
- name: Get Thymis App Token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.THYMIS_APP_ID }}
private-key: ${{ secrets.THYMIS_APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
token: ${{ steps.generate-token.outputs.token }}
ref: ${{ steps.comment-branch.outputs.head_ref }}
- name: Comment action started
uses: thollander/actions-comment-pull-request@v3
with:
message: |
### Updating snapshots. Click [here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) to see the status.
comment-tag: playwright-snapshots-update
github-token: ${{ steps.generate-token.outputs.token }}
update-snapshots-aarch64:
name: Update Snapshots aarch64
if: github.event.issue.pull_request && contains(github.event.comment.body, '/approve-snapshots') && github.event.comment.author_association == 'MEMBER'
runs-on: ubuntu-22.04-arm
permissions:
contents: write
pull-requests: write
steps:
- name: Get branch of PR
uses: xt0rted/pull-request-comment-branch@v3
id: comment-branch
- name: Get Thymis App Token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.THYMIS_APP_ID }}
private-key: ${{ secrets.THYMIS_APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
token: ${{ steps.generate-token.outputs.token }}
ref: ${{ steps.comment-branch.outputs.head_ref }}
- uses: ./.github/actions/setup-nix
with:
attic_token: ${{ secrets.ATTIC_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install dependencies
run: |
npm ci
working-directory: frontend
- name: Build application
run: |
nix build .#thymis-controller
- name: Run tests
run: |
export THYMIS_FLAKE_ROOT='..'
nix develop .#forNpmTesting --command npm run test:integration -- --update-snapshots
working-directory: frontend
- name: Upload Playwright report
uses: actions/upload-artifact@v4
id: artifact-upload-aarch64
if: always()
with:
name: playwright-report-aarch64
path: frontend/playwright-report/
retention-days: 30
- name: Upload snapshots screencaps
uses: actions/upload-artifact@v4
with:
name: updated-snapshots-aarch64-screencaps
path: frontend/tests/screencaps.spec.ts-snapshots/
- name: Upload snapshots unauthenticated
uses: actions/upload-artifact@v4
with:
name: updated-snapshots-aarch64-unauthenticated
path: frontend/tests/unauthenticated.spec.ts-snapshots/
update-snapshots-x86_64:
name: Update Snapshots x86_64
if: github.event.issue.pull_request && contains(github.event.comment.body, '/approve-snapshots') && github.event.comment.author_association == 'MEMBER'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Get branch of PR
uses: xt0rted/pull-request-comment-branch@v3
id: comment-branch
- name: Get Thymis App Token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.THYMIS_APP_ID }}
private-key: ${{ secrets.THYMIS_APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
token: ${{ steps.generate-token.outputs.token }}
ref: ${{ steps.comment-branch.outputs.head_ref }}
- uses: ./.github/actions/setup-nix
with:
attic_token: ${{ secrets.ATTIC_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install dependencies
run: |
npm ci
working-directory: frontend
- name: Build application
run: |
nix build .#thymis-controller
- name: Run tests
run: |
if [ -f "tests/x86_vm.spec.ts" ]; then
export THYMIS_FLAKE_ROOT='..'
nix develop .#forNpmTesting --command npm run test:integration -- --update-snapshots "tests/x86_vm.spec.ts"
fi
working-directory: frontend
- name: Upload Playwright report
uses: actions/upload-artifact@v4
id: artifact-upload-x86_64
if: always()
with:
name: playwright-report-x86_64
path: frontend/playwright-report/
retention-days: 30
- name: Upload updated snapshots
uses: actions/upload-artifact@v4
with:
name: updated-snapshots-x86_vm
path: frontend/tests/x86_vm.spec.ts-snapshots/
upload-artifacts:
name: Upload Artifacts
runs-on: ubuntu-latest
needs: [comment-action-start, update-snapshots-aarch64, update-snapshots-x86_64]
steps:
- name: Get Thymis App Token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.THYMIS_APP_ID }}
private-key: ${{ secrets.THYMIS_APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
token: ${{ steps.generate-token.outputs.token }}
ref: ${{ needs.comment-action-start.outputs.pr_head }}
- name: Download updated snapshots aarch64-screencaps
uses: actions/download-artifact@v4
with:
name: updated-snapshots-aarch64-screencaps
path: frontend/tests/screencaps.spec.ts-snapshots/
- name: Download updated snapshots aarch64-unauthenticated
uses: actions/download-artifact@v4
with:
name: updated-snapshots-aarch64-unauthenticated
path: frontend/tests/unauthenticated.spec.ts-snapshots/
- name: Download updated snapshots x86_vm
uses: actions/download-artifact@v4
with:
name: updated-snapshots-x86_vm
path: frontend/tests/x86_vm.spec.ts-snapshots/
- name: commit and push
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
BRANCH_NAME: ${{ needs.comment-action-start.outputs.pr_head }}
run: |
USER_NAME=${{ steps.generate-token.outputs.app-slug }}[bot]
USER_ID=$(gh api "/users/${USER_NAME}" --jq '.id')
USER_EMAIL="${USER_ID}+${{ steps.generate-token.outputs.app-slug }}[bot]@users.noreply.github.com"
git config user.email $USER_EMAIL
git config user.name $USER_NAME
git add .
git commit -m "Update e2e snapshots"
git push