-
Notifications
You must be signed in to change notification settings - Fork 1
181 lines (177 loc) · 6.41 KB
/
test.yaml
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
name: test
# Actions for any push (PR) onto (into) to master
# -----------------
# Control variables (GitHub Secrets)
# -----------------
#
# At the GitHub 'organisation' or 'project' level you must have the following
# GitHub 'Repository Secrets' defined (i.e. via 'Settings -> Secrets'): -
#
# AUTH0_CLIENT_ID
# AUTH0_CLIENT_SECRET
# DMIT_USER_A_PASSWORD
# DMIT_USER_A_PASSWORD
#
# -----------
# Environment (GitHub Environments)
# -----------
#
# Environment (n/a)
on:
push:
jobs:
# check that both APIs are responding normally before running tests
check-api:
runs-on: ubuntu-latest
steps:
- name: Get DM Version
run: |
curl -f -X 'GET' \
'https://data-manager-test.xchem-dev.diamond.ac.uk/data-manager-api/version' \
-H 'accept: application/json'
- name: Get AS Version
run: |
curl -f -X 'GET' \
'https://account-server-test.xchem-dev.diamond.ac.uk/account-server-api/version' \
-H 'accept: application/json'
test-base-path:
needs: check-api # tests are skipped if APIs are down to avoid false negatives
# Setup
runs-on: ubuntu-latest
environment: data-manager-ui/test
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: pnpm/action-setup@v3.0.0
with:
version: 8.15.4
run_install: false
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- run: node -v
- name: Setup Playwright
run: pnpm exec playwright install --with-deps
- name: Load cached build for speed
uses: actions/cache@v4
with:
path: |
${{ github.workspace }}/.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
# Test WITH base path set
- name: Build with base path
run: pnpm build
env:
BASE_PATH: "/data-manager-ui"
# Ok for tests/dev but we don't do this on prod. This is to prevent some flakely tests from causing problems
- name: Disable strict SSL
run: npm config set strict-ssl=false
# Manually add a "test concurrency"
# This ensures only one test job runs at a time (across all workflows)
# If this workflow is billed by the elapsed time, this will add a lot to this cost
- name: Turnstyle
uses: softprops/turnstyle@v1
with:
abort-after-seconds: 600
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Test with base path
env:
AUTH0_CLIENT_ID: "${{ secrets.AUTH0_CLIENT_ID }}"
AUTH0_CLIENT_SECRET: "${{ secrets.AUTH0_CLIENT_SECRET }}"
DMIT_USER_A_PASSWORD: "${{ secrets.DMIT_USER_A_PASSWORD }}"
AUTH0_SECRET: "LONG_RANDOM_VALUE"
BASE_URL: "http://localhost:3000"
BASE_PATH: "/data-manager-ui"
DONT_USE_STANDALONE_OUTPUT: true
DANGEROUS__DISABLE_SSL_CERT_CHECK_IN_API_PROXY: 1
DATA_MANAGER_API_SERVER: "https://data-manager-test.xchem-dev.diamond.ac.uk/data-manager-api"
ACCOUNT_SERVER_API_SERVER: "https://account-server-test.xchem-dev.diamond.ac.uk/account-server-api"
KEYCLOAK_URL: "https://keycloak-test.xchem-dev.diamond.ac.uk/auth/realms/squonk"
PW_USERNAME: "dmit-user-a"
PW_PASSWORD: "${{ secrets.DMIT_USER_A_PASSWORD }}"
TEST_PORT: 3000
run: pnpm test:ci
- name: Upload results for bath path
if: always()
uses: actions/upload-artifact@v4
with:
name: Base Path Results
path: test-results
test-no-base-path:
needs: check-api # tests are skipped if APIs are down to avoid false negatives
# Setup
runs-on: ubuntu-latest
environment: data-manager-ui/test
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: pnpm/action-setup@v3.0.0
with:
version: 8.15.4
run_install: false
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- run: node -v
- name: Setup Playwright
run: pnpm exec playwright install --with-deps
- name: Load cached build for speed
uses: actions/cache@v4
with:
path: |
${{ github.workspace }}/.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-
# Test withOUT base path set
- name: Build without base path
run: pnpm build
env:
BASE_PATH: ""
# Ok for tests/dev but we don't do this on prod. This is to prevent some flakely tests from causing problems
- name: Disable strict SSL
run: npm config set strict-ssl=false
- name: Turnstyle
uses: softprops/turnstyle@v1
with:
abort-after-seconds: 600
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Test without base path
env:
AUTH0_CLIENT_ID: "${{ secrets.AUTH0_CLIENT_ID }}"
AUTH0_CLIENT_SECRET: "${{ secrets.AUTH0_CLIENT_SECRET }}"
DMIT_USER_A_PASSWORD: "${{ secrets.DMIT_USER_A_PASSWORD }}"
AUTH0_SECRET: "LONG_RANDOM_VALUE"
BASE_URL: "http://localhost:3000"
DONT_USE_STANDALONE_OUTPUT: true
DANGEROUS__DISABLE_SSL_CERT_CHECK_IN_API_PROXY: 1
BASE_PATH: ""
DATA_MANAGER_API_SERVER: "https://data-manager-test.xchem-dev.diamond.ac.uk/data-manager-api"
ACCOUNT_SERVER_API_SERVER: "https://account-server-test.xchem-dev.diamond.ac.uk/account-server-api"
KEYCLOAK_URL: "https://keycloak-test.xchem-dev.diamond.ac.uk/auth/realms/squonk"
PW_USERNAME: "dmit-user-a"
PW_PASSWORD: "${{ secrets.DMIT_USER_A_PASSWORD }}"
TEST_PORT: 3000
run: pnpm test:ci
- name: Upload results for no bath path
if: always()
uses: actions/upload-artifact@v4
with:
name: No Base Path Results
path: test-results