-
Notifications
You must be signed in to change notification settings - Fork 2
198 lines (176 loc) · 5.42 KB
/
ci.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
on:
pull_request:
paths-ignore:
- "archives/**"
- "docs/**"
- "terraform/**"
- "tombstone/**"
- "docker/postgis/**"
push:
branches:
- main
paths-ignore:
- "archives/**"
- "docs/**"
- "terraform/**"
- "tombstone/**"
- "docker/postgis/**"
name: Continuous Integration
jobs:
test:
runs-on: ubuntu-latest
services:
# PostGIS service for use with server tests
postgres:
image: "postgis/postgis:13-3.1"
env:
POSTGRES_DB: univaf-test
POSTGRES_USER: test
POSTGRES_PASSWORD: test-password
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v3
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18.16.0
- name: Cache Dependencies
uses: actions/cache@v3
with:
path: |
~/.npm
~/.cache
key: ${{ runner.os }}-npm-v2-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-v2
${{ runner.os }}-npm-
- name: Install dependencies
run: |
npm ci
- name: Run common tests
if: ${{ always() }}
env:
NOCK_BACK_MODE: lockdown
run: |
npm run test --workspace common
# A build version of common will be needed for loader/server tests.
- name: Build common package
if: ${{ always() }}
run: |
npm run build --workspace common
- name: Run server tests
if: ${{ always() }}
run: |
npm run test --workspace server
env:
DB_HOST: localhost
DB_PORT: 5432
DB_USERNAME: test
DB_NAME: univaf
DB_PASSWORD: test-password
- name: Run loader tests
if: ${{ always() }}
env:
NOCK_BACK_MODE: lockdown
run: |
npm run test --workspace loader
lint:
name: Run linters
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18.16.0
- name: Cache Dependencies
uses: actions/cache@v3
with:
path: |
~/.npm
~/.cache
key: ${{ runner.os }}-npm-v2-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-v2
${{ runner.os }}-npm-
- name: Install dependencies
run: |
npm ci
# We have ESLint and Prettier installed separately in each subproject,
# but this action can only run once per job. So we run the versions
# installed in the server project on both at once, and have some weird
# arguments.
- name: Lint JS Code
if: github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository
uses: wearerequired/lint-action@v2
with:
eslint: true
eslint_extensions: js,ts
prettier: true
- name: Lint JS Code (without GitHub checks)
if: github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.repository
run: |
npx eslint --ext 'js,ts' .
echo "--------------------------------------------------------------"
echo "Prettier:"
npx prettier --check .
lint_workflows:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Lint workflow files
run: |
# Install actionlint
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
# Install matcher for GitHub line annotations
curl 'https://raw.githubusercontent.com/rhysd/actionlint/main/.github/actionlint-matcher.json' > actionlint-matcher.json
echo "::add-matcher::./actionlint-matcher.json"
./actionlint
build_docker:
needs:
- lint
- test
runs-on: ubuntu-latest
strategy:
matrix:
# Instead of building all combinations of a set of options, just build
# these particular combinations.
include:
- repository: univaf-server
target: server
dockerfile: "./server/Dockerfile"
build_path: "./server"
- repository: univaf-loader
target: loader
dockerfile: "./loader/Dockerfile"
build_path: "./loader"
env:
ECR_REPOSITORY: ${{ matrix.repository }}
IMAGE_TAG: ${{ github.sha }}
steps:
- uses: actions/checkout@v3
- name: Build ${{ matrix.repository }}
run: |
IMAGE_NAME="dev/${ECR_REPOSITORY}:${IMAGE_TAG}"
docker buildx build \
--tag "${IMAGE_NAME}" \
--target "${{ matrix.target }}" \
--build-arg RELEASE="${IMAGE_TAG}" \
.
# Report image info
SIZE=$(
docker image inspect \
--format '{{ .VirtualSize }}' \
"${IMAGE_NAME}"
)
SIZE_MB=$((SIZE / 1024 / 1024))
echo "Built image \`${IMAGE_NAME}\`: ${SIZE_MB} MB" >> "$GITHUB_STEP_SUMMARY"