-
Notifications
You must be signed in to change notification settings - Fork 0
170 lines (145 loc) · 4.4 KB
/
ci.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
name: CI
on:
push:
branches: [ main ]
paths-ignore:
- '**/*.md'
pull_request:
branches: [ main ]
paths-ignore:
- '**/*.md'
jobs:
cancel_redundant_runs:
name: Cancel Redundant Runs
if: "!contains(github.event.head_commit.message, '[skip ci]')"
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
build_app:
name: Build App
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
- name: Check out repository code
uses: actions/checkout@v3
- name: Cache node modules
uses: actions/cache@v3
with:
path: |
~/.cache/yarn
**/node_modules
key: ${{ runner.os }}-CI-${{ hashFiles('**/yarn.lock') }}
- name: Install App Dependencies
run: yarn --frozen-lockfile
working-directory: app
- name: Build App
run: yarn build
working-directory: app
- name: Upload the build output
uses: actions/upload-artifact@v3
with:
name: app_build
path: app/dist
integration_test:
name: Cypress E2E Tests
runs-on: ubuntu-latest
timeout-minutes: 20
needs: [build_app]
strategy:
fail-fast: false
matrix:
containers: [1, 2, 3, 4, 5, 6,7,8]
steps:
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 14
- name: Check out repository code
uses: actions/checkout@v3
- name: Cache node modules
uses: actions/cache@v3
with:
path: |
~/.cache/yarn
~/.cache/Cypress
**/node_modules
key: ${{ runner.os }}-CI-${{ hashFiles('**/yarn.lock') }}
- name: Install e2e Dependencies
run: yarn --frozen-lockfile
working-directory: e2e
- name: Download app build
uses: actions/download-artifact@v3
with:
name: app_build
path: dist
- name: Serve app
run: python -m http.server --cgi --directory dist --cgi 8000 &> /dev/null &
- name: Use private cypress director
working-directory: e2e
run: sed -i 's/api\.cypress\.io/asha-cypress\.fly\.dev/g' $(npx cypress cache path)/$(node -p "require('cypress/package.json').version")/Cypress/resources/app/packages/server/config/app.yml
- name: Run Cypress
uses: cypress-io/github-action@v2
if: "github.ref != 'refs/heads/staging' && !contains(github.event.issue.labels.*.name, 'Ready for Review') && !contains(github.event.issue.labels.*.name, 'Percy')"
with:
working-directory: e2e
wait-on: 'http://localhost:8000'
parallel: true
record: true
ci-build-id: '${{ github.sha }}-${{ github.workflow }}-${{ github.event_name }}'
install: false
env:
CYPRESS_RECORD_KEY: doesnt-matter
CYPRESS_VIDEO: true
CYPRESS_SCREENSHOT: true
- name: Run Cypress with Percy
uses: cypress-io/github-action@v2
if: "github.ref == 'refs/heads/main'"
with:
working-directory: e2e
wait-on: 'http://localhost:8000'
parallel: true
record: true
ci-build-id: '${{ github.sha }}-${{ github.workflow }}-${{ github.event_name }}'
install: false
command-prefix: 'percy exec --'
env:
CYPRESS_RECORD_KEY: doesnt-matter
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
PERCY_PARALLEL_NONCE: '${{ github.sha }}-${{ github.workflow }}-${{ github.event_name }}'
PERCY_PARALLEL_TOTAL: 6
- name: Save Recordings
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: cypress-recordings
path: |
e2e/cypress/videos/
e2e/cypress/screenshots/
finalize-percy:
name: Finalize Percy
needs: ['integration_test']
if: "github.ref == 'refs/heads/main'"
defaults:
run:
shell: bash
env:
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 14
- name: Add percy globally
run: yarn global add @percy/cli
- name: Run Percy build
run: npx percy build:finalize