-
Notifications
You must be signed in to change notification settings - Fork 16
193 lines (191 loc) · 6.12 KB
/
test-and-deploy.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
name: Test & Deploy
on: [push]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install dependencies
uses: ./.github/actions/install-dependencies
- name: Current timestamp
uses: ./.github/actions/now
- name: Build
env:
REACT_APP_COMMIT_SHA: ${{ github.sha }}
REACT_APP_BUILD_TIMESTAMP: ${{ env.NOW }}
REACT_APP_ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_CLIENT_ACCESS_TOKEN }}
run: npm run build
- name: Upload build artifact
uses: actions/upload-artifact@master
with:
name: build
path: build/
test:
name: Test
needs: build
timeout-minutes: 60
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.40.0-focal
strategy:
fail-fast: false
matrix:
shardIndex: [1,2,3,4,5,6,7,8,9,10]
shardTotal: [10]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '14'
- name: Install dependencies
uses: ./.github/actions/install-dependencies
- name: Download build artifact
uses: actions/download-artifact@master
with:
name: build
path: build
- name: Start app
run: npm run start:test &
- name: Run Playwright Tests
run: npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- name: Upload test screenshots artifact
uses: actions/upload-artifact@v3
if: always()
with:
name: test-screenshots
path: test/screenshots
retention-days: 14
- name: Upload test report artifact
uses: actions/upload-artifact@v3
if: always()
with:
name: test-blob-reports
path: test/report/
retention-days: 14
test-report:
name: Test report
needs: test
if: always()
environment:
name: test-report
url: ${{ steps.pages.outputs.url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install dependencies
uses: ./.github/actions/install-dependencies
- name: Download test screenshots artifact
uses: actions/download-artifact@master
with:
name: test-screenshots
path: test/screenshots
- name: Download test report artifact
uses: actions/download-artifact@master
with:
name: test-blob-reports
path: test/blob-reports
- name: Merge blob reports into HTML report
run: npx playwright merge-reports --config playwright.merge-reports.config.ts ./test/blob-reports
- name: Upload Argos screenshots
continue-on-error: true
env:
ARGOS_TOKEN: ${{ secrets.ARGOS_TOKEN }}
run: npx argos upload test/screenshots
- name: Deploy test report to Cloudflare Pages
id: pages
uses: ./.github/actions/deploy-cloudflare-pages
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
project: calamar-test-reports
branch: ${{ github.ref_name }}
path: test/report
preview:
name: Deploy / Preview
needs: test
environment:
name: development
url: ${{ steps.pages.outputs.url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download build artifact
uses: actions/download-artifact@master
with:
name: build
path: build
- name: Current timestamp
uses: ./.github/actions/now
- name: Generate client environment
uses: ./.github/actions/generate-client-env
env:
REACT_APP_PUBLISH_TIMESTAMP: ${{ env.NOW }}
REACT_APP_ROLLBAR_ENV: development
REACT_APP_ROLLBAR_ENABLED: ${{ github.ref_name == 'master' && 'true' || 'false' }}
with:
file: build/env.js
- name: Deploy to Cloudflare Pages
id: pages
uses: ./.github/actions/deploy-cloudflare-pages
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
project: calamar
branch: ${{ github.ref_name }}
path: build
- name: Deploy to Rollbar
if: github.ref_name == 'master'
uses: ./.github/actions/deploy-rollbar
with:
accessToken: ${{ secrets.ROLLBAR_SERVER_ACCESS_TOKEN }}
environment: development
urls: ${{ steps.pages.outputs.url }} ${{ steps.pages.outputs.aliases }}
path: build
deploy:
name: Deploy / Production
needs: test
if: github.ref_name == 'master' || github.ref_name == 'production-hotfix'
environment:
name: production
url: ${{ steps.pages.outputs.url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download build artifact
uses: actions/download-artifact@master
with:
name: build
path: build
- name: Current timestamp
uses: ./.github/actions/now
- name: Generate client environment
uses: ./.github/actions/generate-client-env
env:
REACT_APP_PUBLISH_TIMESTAMP: ${{ env.NOW }}
REACT_APP_ROLLBAR_ENV: production
REACT_APP_ROLLBAR_ENABLED: true
with:
file: build/env.js
- name: Deploy to Cloudflare Pages
id: pages
uses: ./.github/actions/deploy-cloudflare-pages
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
project: calamar
branch: production
path: build
- name: Deploy to Rollbar
uses: ./.github/actions/deploy-rollbar
with:
accessToken: ${{ secrets.ROLLBAR_SERVER_ACCESS_TOKEN }}
environment: production
urls: ${{ steps.pages.outputs.url }} ${{ steps.pages.outputs.aliases }}
path: build