This repository has been archived by the owner on Jun 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 299
233 lines (223 loc) · 8.11 KB
/
generate-screenshots.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
name: "Generate | Screenshots"
on:
issue_comment:
types: [created]
workflow_dispatch:
inputs:
pr:
description: pr number
required: true
jobs:
check-if-fork:
runs-on: ubuntu-20.04
outputs:
forked: ${{ steps.forked.outputs.forked }}
steps:
- name: check if we are on a forked repo
id: forked
run: echo "::set-output name=forked::$(${{github.event.issue.pull_request != '' && github.event.issue.pull_request.head.repo.full_name != github.repository || false }})"
add-reaction:
needs: [check-if-fork]
name: "[Reaction] 🚀"
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/generate-screenshots') && !needs.check-if-fork.outputs.forked
runs-on: ubuntu-latest
steps:
- name: add reaction to PR
uses: actions/github-script@v6
with:
script: |
github.rest.reactions.createForIssueComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: context.payload.comment.id,
content: 'rocket'
})
const body = `
[Generating new screenshots](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
`
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
start-runner:
name: "[Runner] start ec2 instance"
# needs: [add-reaction]
uses: ledgerhq/actions/.github/workflows/start-linux-runner.yml@main
with:
instance-type: c5.4xlarge
secrets:
CI_BOT_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
stop-runner:
name: "[Runner] stop ec2 instance"
if: always() && github.event.issue.pull_request != ''
needs: [start-runner, generate-screenshots-linux]
uses: ledgerhq/actions/.github/workflows/stop-linux-runner.yml@main
with:
label: ${{ needs.start-runner.outputs.label }}
ec2-instance-id: ${{ needs.start-runner.outputs.ec2-instance-id }}
secrets:
CI_BOT_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
generate-screenshots-linux:
name: "[Linux] Screenshots"
needs: [start-runner]
runs-on: ${{ needs.start-runner.outputs.label }}
steps:
- name: prepare runner
run: |
sudo growpart /dev/nvme0n1 1
sudo resize2fs /dev/nvme0n1p1
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: set git user
run: |
git config user.email "team-live@ledger.fr"
git config user.name "Team Live"
- name: kill apt-get
run: sudo killall -w apt-get apt || echo OK
- name: install gh
run: |
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt-get update
sudo apt-get install -y gh
- name: checkout PR
run: gh pr checkout ${{ github.event.issue.number || github.event.inputs.pr }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v2
with:
node-version: 14.x
- name: install yarn
run: npm i -g yarn
- uses: ledgerhq/actions/packages/has-hash-commit-deps@main
id: has-hash-commit-deps
with:
workspace: ${{ github.workspace }}
- name: install dependencies
if: ${{ steps.has-hash-commit-deps.outputs.has-hash-commit-deps == 'true' }}
env:
JOBS: max
run: yarn --frozen-lockfile --network-timeout 100000 --network-concurrency 1
- name: install dependencies
if: ${{ steps.has-hash-commit-deps.outputs.has-hash-commit-deps == 'false' }}
env:
JOBS: max
run: yarn --frozen-lockfile --network-timeout 100000
- name: install operating system dependencies
run: npx playwright install-deps
- name: build electron app
run: yarn build:testing
- name: generate new screenshots (Linux)
run: xvfb-run --auto-servernum -- yarn playwright-update-snapshots --retries 0
- name: status
id: status
run: echo "::set-output name=status::$(git status --porcelain | wc -l)"
- name: commit
if: steps.status.outputs.status != 0
run: |
git add .
git commit -m 'update screenshots (linux)'
git pull --rebase
git push
generate-screenshots-windows:
# needs: [add-reaction]
name: "[Windows] Screenshots"
# strategy:
# fail-fast: false
# matrix:
# # os: [macos-latest, windows-latest]
# os: [windows-latest]
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: set git user
run: |
git config user.email "team-live@ledger.fr"
git config user.name "Team Live"
- name: checkout PR
run: gh pr checkout ${{ github.event.issue.number || github.event.inputs.pr }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v2
with:
node-version: 14.x
- name: install yarn
run: npm i -g yarn
- uses: ledgerhq/actions/packages/has-hash-commit-deps@main
id: has-hash-commit-deps
with:
workspace: ${{ github.workspace }}
- name: install dependencies
if: ${{ steps.has-hash-commit-deps.outputs.has-hash-commit-deps == 'true' }}
env:
JOBS: max
run: yarn --frozen-lockfile --network-timeout 100000 --network-concurrency 1
- name: install dependencies
if: ${{ steps.has-hash-commit-deps.outputs.has-hash-commit-deps == 'false' }}
env:
JOBS: max
run: yarn --frozen-lockfile --network-timeout 100000
- name: install operating system dependencies
run: npx playwright install-deps
- name: build electron app
run: yarn build:testing
- name: generate new screenshots (windows)
run: yarn playwright-update-snapshots --retries 0
- name: status
id: status
run: echo "::set-output name=status::$(git status --porcelain | wc -l)"
- name: commit
if: steps.status.outputs.status != 0
run: |
git add .
git commit -m 'update screenshots (windows)'
git pull --rebase
git push
# generate-screenshots-macos:
# # needs: [add-reaction]
# name: "[macOS] Screenshots"
# runs-on: [ledger-live, macos]
# steps:
# - uses: actions/checkout@v2
# with:
# fetch-depth: 0
# - name: set git user
# run: |
# git config user.email "team-live@ledger.fr"
# git config user.name "Team Live"
# - name: install gh
# run: brew install gh
# - name: checkout PR
# run: gh pr checkout ${{ github.event.issue.number || github.event.inputs.pr }}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# - uses: actions/setup-node@v2
# with:
# node-version: 14.x
# - name: install yarn
# run: npm i -g yarn
# - name: install dependencies
# env:
# JOBS: max
# run: yarn --frozen-lockfile --network-timeout 100000
# - name: install operating system dependencies
# run: npx playwright install-deps
# - name: build electron app
# run: yarn build:testing
# - name: generate new screenshots (macOS)
# run: yarn playwright-update-snapshots --retries 0
# - name: status
# id: status
# run: echo "::set-output name=status::$(git status --porcelain | wc -l)"
# - name: commit
# if: steps.status.outputs.status != 0
# run: |
# git add .
# git commit -m 'update screenshots (macOs)'
# git pull --rebase
# git push