-
Notifications
You must be signed in to change notification settings - Fork 3
222 lines (215 loc) · 7.47 KB
/
build.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
name: Build & Test
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
actions: read
contents: read
pull-requests: write
statuses: read
jobs:
lint:
runs-on: ubuntu-latest
container:
image: node:18
steps:
- uses: actions/checkout@v3
- name: Cache and restore node_modules
id: cache-node
uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ runner.os }}-node-${{ hashFiles('./package-lock.json') }}
- run: npm install
if: steps.cache-node.outputs.cache-hit != 'true'
- run: npm run lint
build:
needs: [ lint ]
runs-on: ubuntu-latest
container:
image: node:18
steps:
- uses: actions/checkout@v3
- name: Cache and restore node_modules
id: cache-node
uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ runner.os }}-node-${{ hashFiles('./package-lock.json') }}
- run: npm install
if: steps.cache-node.outputs.cache-hit != 'true'
- run: npm run build
- name: "Compress out folder"
run: tar -zcvf out.tar.gz out/
- name: "Upload /out of build"
uses: actions/upload-artifact@v3
with:
name: build
path: out.tar.gz
retention-days: 1
coverage:
name: "coverage-${{ matrix.typeorm-connection }}"
needs: [ lint ]
runs-on: ubuntu-latest
container:
image: node:18
services:
mariadb:
image: mariadb:lts
env:
MARIADB_RANDOM_ROOT_PASSWORD: true
MARIADB_DATABASE: sudosos-ci
MARIADB_USER: sudosos-ci
MARIADB_PASSWORD: sudosos-ci
strategy:
matrix:
include:
- typeorm-connection: mariadb
typeorm-host: mariadb
typeorm-port: 3306
typeorm-username: sudosos-ci
typeorm-password: sudosos-ci
typeorm-database: sudosos-ci
typeorm-synchronize: 'false'
- typeorm-connection: sqlite
typeorm-host: ''
typeorm-port: ''
typeorm-username: ''
typeorm-password: ''
typeorm-database: local.sqlite
typeorm-synchronize: 'true'
env:
NAME: sudosos-test
NODE_ENV: development
API_HOST: localhost:3000
API_BASEPATH: /v1
CURRENCY_CODE: EUR
CURRENCY_PRECISION: 2
GEWISWEB_JWT_SECRET: ChangeMe
JWT_KEY_PATH: ./config/jwt.key
HTTP_PORT: 3000
TYPEORM_CONNECTION: ${{ matrix.typeorm-connection }}
TYPEORM_HOST: ${{ matrix.typeorm-host }}
TYPEORM_PORT: ${{ matrix.typeorm-port }}
TYPEORM_USERNAME: ${{ matrix.typeorm-username }}
TYPEORM_PASSWORD: ${{ matrix.typeorm-password }}
TYPEORM_DATABASE: ${{ matrix.typeorm-database }}
TYPEORM_SYNCHRONIZE: ${{ matrix.typeorm-synchronize }}
TYPEORM_LOGGING: 0
LOG_LEVEL: INFO
RESET_TOKEN_EXPIRES: 3600
FILE_STORAGE_METHOD: disk
ENABLE_LDAP: true
PAGINATION_DEFAULT: 20
PAGINATION_MAX: 500
STRIPE_PUBLIC_KEY: ${{ secrets.STRIPE_SUDOSOS_TEST_KEY }}
STRIPE_PRIVATE_KEY: ${{ secrets.STRIPE_SUDOSOS_TEST_KEY }}
STRIPE_WEBHOOK_SECRET: ${{ secrets.STRIPE_WEBHOOK_TEST_SECRET }}
SKIP_SQLITE_DEFAULTS: true
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache and restore node_modules
id: cache-node
uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ runner.os }}-node-${{ hashFiles('./package-lock.json') }}
- run: npm install
if: steps.cache-node.outputs.cache-hit != 'true'
- run: openssl genrsa -out ./config/jwt.key 2048 && chmod 0777 ./config/jwt.key
- run: npm run swagger:validate
- run: npm run coverage-ci # Separate command to limit the number of workers to prevent timeouts
- run: git config --global --add safe.directory $GITHUB_WORKSPACE # To avoid dubious ownership
if: ${{ matrix.typeorm-connection == 'mariadb' }}
- name: "Cannot commit code coverage cross-fork"
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork && matrix.typeorm-connection == 'mariadb'
run: |
echo "::warning Cannot comment code coverage cross-fork"
- name: "Fetch target branch coverage from artifacts"
id: fetch-coverage-base
if: github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork && matrix.typeorm-connection == 'mariadb'
uses: dawidd6/action-download-artifact@v6
with:
workflow: build.yml
workflow_conclusion: success
name: coverage
if_no_artifact_found: warn
branch: ${{ github.base_ref }}
path: reports/coverage-base
- name: "Comment code coverage on PR"
if: github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork && matrix.typeorm-connection == 'mariadb'
uses: sidx1024/[email protected]
with:
comment_template_file: .github/coverage-template.md
coverage_file: reports/coverage/coverage-summary.json
base_coverage_file: reports/coverage-base/coverage-summary.json
sources_base_path: "/__w/sudosos-backend/sudosos-backend" #github.action_path does not work in Docker (https://github.com/actions/runner/issues/716)
- name: "Upload code coverage report"
if: ${{ matrix.typeorm-connection == 'mariadb' }}
uses: actions/upload-artifact@v4
with:
name: coverage
path: reports/coverage/
retention-days: 7
post-migration-test:
runs-on: ubuntu-latest
env:
NAME: sudosos-test
NODE_ENV: development
API_HOST: localhost:3000
API_BASEPATH: /v1
CURRENCY_CODE: EUR
CURRENCY_PRECISION: 2
GEWISWEB_JWT_SECRET: ChangeMe
JWT_KEY_PATH: ./config/jwt.key
HTTP_PORT: 3000
TYPEORM_CONNECTION: mariadb
TYPEORM_HOST: mariadb
TYPEORM_PORT: 3306
TYPEORM_USERNAME: sudosos-ci
TYPEORM_PASSWORD: sudosos-ci
TYPEORM_DATABASE: sudosos-ci
TYPEORM_SYNCHRONIZE: 'false'
TYPEORM_LOGGING: 0
LOG_LEVEL: INFO
RESET_TOKEN_EXPIRES: 3600
FILE_STORAGE_METHOD: disk
ENABLE_LDAP: true
PAGINATION_DEFAULT: 20
PAGINATION_MAX: 500
STRIPE_PUBLIC_KEY: ${{ secrets.STRIPE_SUDOSOS_TEST_KEY }}
STRIPE_PRIVATE_KEY: ${{ secrets.STRIPE_SUDOSOS_TEST_KEY }}
STRIPE_WEBHOOK_SECRET: ${{ secrets.STRIPE_WEBHOOK_TEST_SECRET }}
SKIP_SQLITE_DEFAULTS: true
container:
image: node:18
services:
mariadb:
image: mariadb:lts
env:
MARIADB_RANDOM_ROOT_PASSWORD: true
MARIADB_DATABASE: sudosos-ci
MARIADB_USER: sudosos-ci
MARIADB_PASSWORD: sudosos-ci
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache and restore node_modules
id: cache-node
uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ runner.os }}-node-${{ hashFiles('./package-lock.json') }}
- run: npm install
if: steps.cache-node.outputs.cache-hit != 'true'
- run: openssl genrsa -out ./config/jwt.key 2048 && chmod 0777 ./config/jwt.key
- run: npm run swagger:validate
- run: npm run test-ci-migrate