-
Notifications
You must be signed in to change notification settings - Fork 0
183 lines (151 loc) · 5.21 KB
/
test.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
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
RAILS_ENV: e2e
SECRET_KEY_BASE: f54c9d76c42e397e17cbc0d0a024da5a762a7a0d934839b417a77dac6fda65a49a37b32bcd229ac5fd5c1fedef8ed6acf7a57ed6465d6339862cdc0dfab8886f
AUTH_SECRET: secret
CONTACT_EMAIL: [email protected]
RESPONSIBLE_EMAIL: [email protected]
FRONTEND_URL: http://localhost:4000
OBSERVATIONS_TOOL_URL: http://localhost:4200
CYPRESS_API_PATH: ../otp_api
CYPRESS_RECORD_HAR: true
ELECTRON_EXTRA_LAUNCH_ARGS: --remote-debugging-port=9222
name: Run tests
on: push
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Read .nvmrc
id: nvm
run: echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_OUTPUT
- uses: actions/setup-node@v2
with:
node-version: "${{ steps.nvm.outputs.NVMRC }}"
- name: Restore Observation Tool Node Modules Cache
id: cache-portal-modules
uses: actions/cache/restore@v3
with:
path: node_modules
key: node-modules-${{ hashFiles('yarn.lock') }}
- name: Install Observation Tool Dependencies
run: yarn install --immutable
- name: Save Observation Tool Node Modules Cache
uses: actions/cache/save@v3
with:
path: node_modules
key: node-modules-${{ hashFiles('yarn.lock') }}
- name: Run Build
run: yarn prod-build
test:
name: E2E Tests
runs-on: ubuntu-latest
services:
redis:
image: redis
ports: ["6379:6379"]
postgres:
image: postgis/postgis:12-3.1-alpine
env:
POSTGRES_USER: ${{ env.POSTGRES_USER }}
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }}
ports: ["5432:5432"]
steps:
- name: Checkout Observation Tool
uses: actions/checkout@v4
- name: Checkout OTP API
uses: actions/checkout@v4
with:
repository: wri/fti_api
ref: develop
path: otp_api
- name: Save OTP API Commit SHA
id: otp_api_commit_sha
working-directory: otp_api
run: echo "VALUE=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Install API dependencies
run: |
sudo apt update --fix-missing
sudo apt-get -yqq install libpq-dev build-essential libcurl4-openssl-dev gdal-bin
npm install -g mjml
- name: Setup API Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
working-directory: otp_api
- name: Restore API Precompiled Assets Cache
id: cache-api-precompiled-assets
uses: actions/cache/restore@v3
with:
path: otp_api/public/assets
key: api-precompiled-assets-${{ steps.otp_api_commit_sha.outputs.VALUE }}
- name: Setup API
working-directory: otp_api
env:
APP_URL: http://localhost:3000
run: |
bin/rails e2e:setup ${{ steps.cache-api-precompiled-assets.outputs.cache-hit == 'true' && 'SKIP_ASSETS_RESET=true' || '' }}
- name: Save API Precompiled Assets Cache
uses: actions/cache/save@v3
with:
path: otp_api/public/assets
key: api-precompiled-assets-${{ steps.otp_api_commit_sha.outputs.VALUE }}
- name: Read API Access Token
id: api_key
working-directory: otp_api
run: |
bin/rails runner 'puts "VALUE=#{User.find_by(email: "[email protected]").api_key.access_token}"' > $GITHUB_OUTPUT
- name: Run API Server
working-directory: otp_api
env:
APP_URL: http://localhost:3000
run: |
bin/rails s &
- name: Read .nvmrc
id: nvm
run: echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_OUTPUT
- uses: actions/setup-node@v2
with:
node-version: "${{ steps.nvm.outputs.NVMRC }}"
- name: Restore Observation Tool Node Modules Cache
id: cache-portal-modules
uses: actions/cache/restore@v3
with:
path: node_modules
key: node-modules-${{ hashFiles('yarn.lock') }}
- name: Install Observation Tool Dependencies
run: yarn install --immutable
- name: Save Observation Tool Node Modules Cache
uses: actions/cache/save@v3
with:
path: node_modules
key: node-modules-${{ hashFiles('yarn.lock') }}
- name: Install E2E Dependencies
working-directory: e2e
run: yarn install --immutable
- name: Set ENV Variables
run: |
sed -i "/OTP_API_KEY/c\ OTP_API_KEY: 'Bearer ${{ steps.api_key.outputs.VALUE }}'," src/environments/environment.e2e.ts
- name: Run Observation Tool
run: |
yarn start:e2e &
npx --yes wait-on -t 80000 http://localhost:4200
- name: Run E2E Tests
working-directory: e2e
run: yarn cypress run
- name: Uploading Test Artifacts
uses: actions/upload-artifact@v2
if: failure()
with:
name: e2e-tests-artifacts
path: |
e2e/cypress/hars
e2e/cypress/screenshots
e2e/cypress/videos
e2e/cypress/e2e/__image_snapshots__
otp_api/log