forked from lightdash/lightdash
-
Notifications
You must be signed in to change notification settings - Fork 0
249 lines (241 loc) · 8.99 KB
/
e2e-tests.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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
name: End-to-end tests
on: [ deployment_status ]
jobs:
files-changed:
if: github.ref != 'refs/heads/main'
name: Detect what files changed
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
frontend: ${{ steps.changes.outputs.frontend == 'true' || steps.overrides.outputs.frontend == 'true' }}
backend: ${{ steps.changes.outputs.backend == 'true' || steps.overrides.outputs.backend == 'true' }}
steps:
- uses: actions/checkout@v4
- name: Check for files changes
uses: dorny/paths-filter@v3
id: changes
with:
token: ${{ github.token }}
filters: .github/file-filters.yml
- uses: 8BitJonny/[email protected]
id: PR
- name: Check for keyword overrides
id: overrides
run: |
echo "PR ${{ steps.PR.outputs.number }}"
echo "Frontend override: ${{contains(steps.PR.outputs.pr_body, 'test-frontend')}}"
echo "Backend override: ${{contains(steps.PR.outputs.pr_body, 'test-backend')}}"
echo "frontend=${{ contains(steps.PR.outputs.pr_body, 'test-frontend') }}" >> "$GITHUB_OUTPUT"
echo "backend=${{ contains(steps.PR.outputs.pr_body, 'test-backend') }}" >> "$GITHUB_OUTPUT"
prepare-preview:
# Only trigger for correct environment and status
runs-on: ubuntu-latest
if: needs.files-changed.outputs.frontend == 'true' || needs.files-changed.outputs.backend == 'true'
needs: files-changed
outputs:
url: ${{ github.event.deployment_status.environment_url }}
steps:
- name: is render ready
if: ${{ !(github.event.deployment_status.state == 'success' && github.event.deployment_status.environment_url != null) }}
run: |
echo "Render environment ${{ github.event.deployment.environment }} is not ready: ${{ github.event.deployment_status.state }} ${{ github.event.deployment_status.environment_url }}"
exit 1
api-tests:
if: needs.files-changed.outputs.backend == 'true'
timeout-minutes: 30
runs-on: ubuntu-latest
needs: prepare-preview
name: API tests
steps:
- name: Checkout
uses: actions/checkout@v4
# Install packages
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
- name: Install packages
run: yarn install --frozen-lockfile
# Build packages
- name: Build packages/common module
run: yarn common-build
- name: create-json
id: create-json
uses: jsdaniell/[email protected]
with:
name: "credentials.json"
json: ${{ secrets.GCP_CREDENTIALS }}
dir: "./packages/e2e/cypress/fixtures/"
# Run API tests
- name: Cypress run
uses: cypress-io/github-action@v6
with:
project: ./packages/e2e
spec: packages/e2e/cypress/e2e/api/**/*
# Set the PR deployment url and disable video recording
config: 'baseUrl=${{needs.prepare-preview.outputs.url}},video=false'
env:
CYPRESS_PGHOST: ${{secrets.PGHOST}}
CYPRESS_PGPASSWORD: ${{secrets.PGPASSWORD}}
CYPRESS_DATABRICKS_HOST: ${{secrets.DATABRICKS_HOST}}
CYPRESS_DATABRICKS_PATH: ${{secrets.DATABRICKS_PATH}}
CYPRESS_DATABRICKS_TOKEN: ${{secrets.DATABRICKS_TOKEN}}
CYPRESS_SNOWFLAKE_ACCOUNT: ${{secrets.SNOWFLAKE_ACCOUNT}}
CYPRESS_SNOWFLAKE_USER: ${{secrets.SNOWFLAKE_USER}}
CYPRESS_SNOWFLAKE_PASSWORD: ${{secrets.SNOWFLAKE_PASSWORD}}
CYPRESS_TRINO_HOST: ${{secrets.TRINO_HOST}}
CYPRESS_TRINO_PORT: ${{secrets.TRINO_PORT}}
CYPRESS_TRINO_USER: ${{secrets.TRINO_USER}}
CYPRESS_TRINO_PASSWORD: ${{secrets.TRINO_PASSWORD}}
TZ: 'UTC'
CYPRESS_TZ: 'UTC'
build-cypress-e2e-image:
runs-on: ubuntu-latest
name: Build cypress e2e image
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: GitHub Registry Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v5
with:
file: ./packages/e2e/dockerfile
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ghcr.io/lightdash/lightdash-cypress-e2e:latest
push: true
app-tests:
if: needs.files-changed.outputs.frontend == 'true'
timeout-minutes: 30
runs-on: ubuntu-latest
needs: prepare-preview
container:
image: ghcr.io/lightdash/lightdash-cypress-e2e:latest
options: --user 1001
strategy:
fail-fast: false
matrix:
containers: [ 1, 2, 3 ]
name: App (${{ matrix.containers }}/${{ strategy.job-total }})
steps:
- name: Checkout
uses: actions/checkout@v4
# Install packages
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
- name: Install packages
run: yarn install --frozen-lockfile
# Build packages
- name: Build packages/common module
run: yarn common-build
# Prepare bigquery credentials for Cypress
- name: create-json
id: create-json
uses: jsdaniell/[email protected]
with:
name: "credentials.json"
json: ${{ secrets.GCP_CREDENTIALS }}
dir: "./packages/e2e/cypress/fixtures/"
# Run E2E tests
- name: Cypress run
uses: cypress-io/github-action@v6
with:
browser: firefox
project: ./packages/e2e
# Set the PR deployment url and disable video recording
config: 'baseUrl=${{needs.prepare-preview.outputs.url}},specPattern=cypress/e2e/app/**/*.cy.{js,jsx,ts,tsx},video=false'
env:
SPLIT: ${{ strategy.job-total }}
SPLIT_INDEX: ${{ strategy.job-index }}
CYPRESS_PGHOST: ${{secrets.PGHOST}}
CYPRESS_PGPASSWORD: ${{secrets.PGPASSWORD}}
CYPRESS_DATABRICKS_HOST: ${{secrets.DATABRICKS_HOST}}
CYPRESS_DATABRICKS_PATH: ${{secrets.DATABRICKS_PATH}}
CYPRESS_DATABRICKS_TOKEN: ${{secrets.DATABRICKS_TOKEN}}
CYPRESS_SNOWFLAKE_ACCOUNT: ${{secrets.SNOWFLAKE_ACCOUNT}}
CYPRESS_SNOWFLAKE_USER: ${{secrets.SNOWFLAKE_USER}}
CYPRESS_SNOWFLAKE_PASSWORD: ${{secrets.SNOWFLAKE_PASSWORD}}
CYPRESS_TRINO_HOST: ${{secrets.TRINO_HOST}}
CYPRESS_TRINO_PORT: ${{secrets.TRINO_PORT}}
CYPRESS_TRINO_USER: ${{secrets.TRINO_USER}}
CYPRESS_TRINO_PASSWORD: ${{secrets.TRINO_PASSWORD}}
TZ: 'UTC'
CYPRESS_TZ: 'UTC'
# After the test run completes
# store videos and any screenshots
- uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots-and-videos-${{ strategy.job-index }}
path: |
packages/e2e/cypress/screenshots
packages/e2e/cypress/videos
if-no-files-found: ignore
timezone-tests:
if: needs.files-changed.outputs.frontend == 'true'
timeout-minutes: 30
runs-on: ubuntu-latest
needs: prepare-preview
container:
image: ghcr.io/lightdash/lightdash-cypress-e2e:latest
options: --user 1001
strategy:
fail-fast: false
matrix:
timezone: ['America/New_York', 'Europe/Madrid', 'Asia/Tokyo' ]
name: Timezone (${{ matrix.timezone }})
steps:
- name: Checkout
uses: actions/checkout@v4
# Install packages
- uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'yarn'
- name: Install packages
run: yarn install --frozen-lockfile
# Build packages
- name: Build packages/common module
run: yarn common-build
# Prepare bigquery credentials for Cypress
- name: create-json
id: create-json
uses: jsdaniell/[email protected]
with:
name: "credentials.json"
json: ${{ secrets.GCP_CREDENTIALS }}
dir: "./packages/e2e/cypress/fixtures/"
# Run E2E tests
- name: Cypress run
uses: cypress-io/github-action@v6
with:
browser: firefox
project: ./packages/e2e
spec: packages/e2e/cypress/e2e/app/dates.cy.ts
# Set the PR deployment url and disable video recording
config: 'baseUrl=${{needs.prepare-preview.outputs.url}},video=false'
env:
TZ: ${{ matrix.timezone }}
CYPRESS_TZ: ${{ matrix.timezone }}
# After the test run completes
# store videos and any screenshots
- uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots-and-videos-timezone-${{ strategy.job-index }}
path: |
packages/e2e/cypress/screenshots
packages/e2e/cypress/videos
if-no-files-found: ignore