-
Notifications
You must be signed in to change notification settings - Fork 3
148 lines (142 loc) · 4.84 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
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-connection: sqlite
typeorm-host: ''
typeorm-port: ''
typeorm-username: ''
typeorm-password: ''
typeorm-database: local.sqlite
env:
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: 0
TYPEORM_LOGGING: 0
LOG_LEVEL: INFO
RESET_TOKEN_EXPIRES: 3600
FILE_STORAGE_METHOD: disk
ENABLE_LDAP: true
PAGINATION_DEFAULT: 20
PAGINATION_MAX: 500
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: "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: ''
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@v3
with:
name: coverage
path: reports/coverage/
retention-days: 7