-
Notifications
You must be signed in to change notification settings - Fork 1
173 lines (145 loc) · 4.97 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
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
name: Run tests
on: push
jobs:
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 Portal
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 libgdal-dev
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 Portal Node Modules Cache
id: cache-portal-modules
uses: actions/cache/restore@v3
with:
path: node_modules
key: node-modules-${{ hashFiles('yarn.lock') }}
- name: Install Portal Dependencies
run: yarn install --immutable
- name: Save Portal 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 Portal ENV Variables
run: |
echo "
PORT=4000
ENV=production
NODE_ENV=production
SECRET=946bd4887fa5eea44256377ca06fc798f431359e1b1885e0d9ac570c1f24d8fe3e5863855d02d61e375729a330f5c7d84606ca1bf735b0676eb368321a119637
OTP_COUNTRIES='COG,CMR,COD,CAF,GAB'
OTP_COUNTRIES_IDS='7,47,45,188,53'
APP_URL=http://localhost:4000
OTP_API=http://localhost:3000
OTP_API_KEY=Bearer ${{ steps.api_key.outputs.VALUE }}
DISABLE_HOTJAR=true
" > .env
- name: Restore Next.js Build Cache
id: cache-nextjs
uses: actions/cache/restore@v3
with:
path: .next/cache
key: nextjs-${{ hashFiles('yarn.lock') }}
- name: Build Portal
run: yarn build
- name: Save Next.js Build Cache
uses: actions/cache/save@v3
with:
path: .next/cache
key: nextjs-${{ hashFiles('yarn.lock') }}
- name: Start Portal
run: yarn start > otp-portal.log &
- name: Run E2E Tests
working-directory: e2e
run: yarn cypress run
- name: Uploading Test Artifacts
uses: actions/upload-artifact@v4
if: failure()
with:
name: e2e-tests-artifacts
path: |
otp-portal.log
e2e/cypress/screenshots
e2e/cypress/videos
e2e/cypress/e2e/__image_snapshots__
otp_api/log