-
Notifications
You must be signed in to change notification settings - Fork 5
237 lines (237 loc) · 8.22 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
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
---
name: Meadow Tests
on:
push:
branches-ignore:
- "main"
- "deploy/**"
- "build/**"
jobs:
dependencies:
runs-on: ubuntu-latest
env:
MIX_ENV: test
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version-file: ./.tool-versions
- uses: erlef/setup-beam@v1
with:
otp-version: "26"
elixir-version: "1.15.4"
- name: Cache Elixir dependencies
uses: actions/cache@v2
with:
path: |
app/deps
key: ${{ runner.os }}-hex-v6-${{ hashFiles('app/mix.lock') }}
restore-keys: |
${{ runner.os }}-hex-v6-${{ hashFiles('app/mix.lock') }}
${{ runner.os }}-hex-v6-
- name: Cache Elixir build
uses: actions/cache@v2
with:
path: |
app/_build
key: ${{ runner.os }}-hex-v6-${{ hashFiles('app/mix.lock') }}-${{ hashFiles('app/**/*.{ex,eex,exs}') }}
restore-keys: |
${{ runner.os }}-hex-v6-${{ hashFiles('app/mix.lock') }}-${{ hashFiles('app/**/*.{ex,eex,exs}') }}
${{ runner.os }}-hex-v6-${{ hashFiles('app/mix.lock') }}
${{ runner.os }}-hex-v6-
- name: Cache JS dependencies
uses: actions/cache@v2
with:
path: |
app/assets/node_modules
app/priv/nodejs/*/node_modules
lambdas/*/node_modules
key: ${{ runner.os }}-npm-v6-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-v6-${{ hashFiles('**/package-lock.json') }}
${{ runner.os }}-npm-v6-
- name: Install Elixir dependencies
run: mix do deps.get, compile
working-directory: app
- name: Install JS dependencies
run: |
npm ci --force --no-fund
npm list
working-directory: app/assets
- name: Install Lambda dependencies
run: |
for pkg in $(find app/priv/nodejs -maxdepth 2 -name package-lock.json) $(find lambdas -maxdepth 2 -name package-lock.json)
do
cd $(dirname $pkg)
npm ci --no-fund
cd -
done
js-test:
runs-on: ubuntu-latest
needs: dependencies
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version-file: ./.tool-versions
- name: Cache Elixir dependencies
uses: actions/cache@v2
with:
path: |
app/deps
app/_build
key: ${{ runner.os }}-hex-v6-${{ hashFiles('app/mix.lock') }}
restore-keys: |
${{ runner.os }}-hex-v6-${{ hashFiles('app/mix.lock') }}
${{ runner.os }}-hex-v6-
- name: Cache Elixir build
uses: actions/cache@v2
with:
path: |
app/_build
key: ${{ runner.os }}-hex-v6-${{ hashFiles('app/mix.lock') }}-${{ hashFiles('app/**/*.{ex,eex,exs}') }}
restore-keys: |
${{ runner.os }}-hex-v6-${{ hashFiles('app/mix.lock') }}-${{ hashFiles('app/**/*.{ex,eex,exs}') }}
${{ runner.os }}-hex-v6-${{ hashFiles('app/mix.lock') }}
${{ runner.os }}-hex-v6-
- name: Cache JS dependencies
uses: actions/cache@v2
with:
path: |
app/assets/node_modules
app/priv/nodejs/*/node_modules
lambdas/*/node_modules
key: ${{ runner.os }}-npm-v6-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-v6-${{ hashFiles('**/package-lock.json') }}
${{ runner.os }}-npm-v6-
- name: JS Static Analysis
run: npm run-script prettier
working-directory: app/assets
- name: JS Tests
run: npm run-script ci:silent -- -w 1
working-directory: app/assets
- name: Test ESBuild
run: npm run-script deploy
working-directory: app/assets
elixir-test:
runs-on: ubuntu-latest
needs: dependencies
env:
MIX_ENV: test
services:
db:
image: ghcr.io/nulib/postgres:10-alpine
env:
POSTGRES_USER: docker
POSTGRES_PASSWORD: d0ck3r
options: >-
--health-cmd "pg_isready -U docker"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
ldap:
image: ghcr.io/nulib/ldap-alpine
ports:
- 389:389
- 636:636
opensearch:
image: opensearchproject/opensearch:2.11.1
env:
bootstrap.memory_lock: true
OPENSEARCH_JAVA_OPTS: "-Xms256m -Xmx256m"
DISABLE_INSTALL_DEMO_CONFIG: true
DISABLE_SECURITY_PLUGIN: true
discovery.type: single-node
ports:
- 9200:9200
localstack:
image: localstack/localstack
env:
DOCKER_HOST: unix:///var/run/docker.sock
GATEWAY_LISTEN: 0.0.0.0:4566
ports:
- 4566:4566
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
steps:
- uses: actions/checkout@v2
- uses: hashicorp/setup-terraform@v3
- name: Provision Localstack using Terraform
run: |
terraform init
terraform apply -auto-approve -var-file test.tfvars -var localstack_endpoint=https://localhost.localstack.cloud:4566
working-directory: ./infrastructure/localstack
- uses: actions/setup-node@v3
with:
node-version-file: ./.tool-versions
- uses: erlef/setup-beam@v1
with:
otp-version: "26"
elixir-version: "1.15.4"
- name: Install LDAP utils
run: |
sudo apt-get update -qq
sudo apt-get install -y ldap-utils
- name: Install FFMPEG
run: |
mkdir -p ${{ runner.temp }}/ffmpeg && \
cd ${{ runner.temp }}/ffmpeg && \
curl https://s3.amazonaws.com/nul-repo-deploy/ffmpeg-release-64bit-static.tar.xz | tar xJ && \
sudo cp $(find . -type f -executable) /usr/local/bin/ && \
echo "FFMPEG VERSION: $(ffmpeg -version | sed -n "s/ffmpeg version \([-0-9.]*\).*/\1/p;")"
- name: Install ExifTool
run: |
EXIFTOOL_VERSION=$(curl -s https://exiftool.org/ver.txt)
mkdir -p ${{ runner.temp }}/exiftool && \
cd ${{ runner.temp }}/exiftool && \
curl -L -s https://exiftool.org/Image-ExifTool-${EXIFTOOL_VERSION}.tar.gz | tar xz && \
cd Image-ExifTool-${EXIFTOOL_VERSION} && \
perl Makefile.PL && \
sudo make install
- name: Cache Elixir dependencies
uses: actions/cache@v2
with:
path: |
app/deps
key: ${{ runner.os }}-hex-v6-${{ hashFiles('app/mix.lock') }}
restore-keys: |
${{ runner.os }}-hex-v6-${{ hashFiles('app/mix.lock') }}
${{ runner.os }}-hex-v6-
- name: Cache Elixir build
uses: actions/cache@v2
with:
path: |
app/_build
key: ${{ runner.os }}-hex-v6-${{ hashFiles('app/mix.lock') }}-${{ hashFiles('app/**/*.{ex,eex,exs}') }}
restore-keys: |
${{ runner.os }}-hex-v6-${{ hashFiles('app/mix.lock') }}-${{ hashFiles('app/**/*.{ex,eex,exs}') }}
${{ runner.os }}-hex-v6-${{ hashFiles('app/mix.lock') }}
${{ runner.os }}-hex-v6-
- name: Cache JS dependencies
uses: actions/cache@v2
with:
path: |
app/assets/node_modules
app/priv/nodejs/*/node_modules
lambdas/*/node_modules
key: ${{ runner.os }}-npm-v6-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-v6-${{ hashFiles('**/package-lock.json') }}
${{ runner.os }}-npm-v6-
- name: Set SECRET_KEY_BASE
run: echo "SECRET_KEY_BASE=$(openssl rand -hex 32)" >> $GITHUB_ENV
- name: Elixir Static Analysis
run: mix credo
working-directory: app
- name: Elixir Tests
run: mix test || mix test --failed
env:
AWS_REGION: us-east-1
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: app
- name: Test DB Rollback
run: mix ecto.rollback --all
working-directory: app