-
-
Notifications
You must be signed in to change notification settings - Fork 41
executable file
·110 lines (102 loc) · 3.7 KB
/
build.yaml
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
name: Node.js CI
on:
pull_request:
push:
branches:
- master
schedule:
- cron: '0 0 * * 0' # weekly
jobs:
test:
runs-on: ubuntu-latest
name: Node.js ${{ matrix.node-version }}
strategy:
matrix:
node-version: [20.x, 22.x]
env:
DB_HOST: 127.0.0.1
DB_PORT: 3306
DB_USER: root
DB_PASSWORD: root
ENCRYPTION_KEY: b097b390a68441cc3bb151dd0171f25c3aabc688c50eeb26dc5e13254b333911
SESSION_KEY: a73545a5f08d2906e39a4438014200303f9269f3ade9227525ffb141294f1b62
DB_CONNECTION_LIMIT: 5
SERVER_FOOTER_NAME: BanManagement
steps:
- uses: actions/checkout@v4
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Cache Node.js modules
uses: actions/cache@v4
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-
- run: npm ci
- name: Set up MySQL
run: |
sudo systemctl start mysql.service
sleep 5 && mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '';" -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }}
- run: npm run lint
# Temporary work around jest memory leaks https://github.com/facebook/jest/issues/11956
- run: |
shopt -s globstar
set -e
for x in server/test/*.test.js; do (node --expose-gc ./node_modules/.bin/jest "$x" && sh -c 'mv coverage/coverage-final.json "coverage/$(basename "$1" .js).json"' sh "$x") || exit 1; done
for x in cli/test/*.test.js; do (node --expose-gc ./node_modules/.bin/jest "$x" && sh -c 'mv coverage/coverage-final.json "coverage/$(basename "$1" .js).json"' sh "$x") || exit 1; done
npx nyc merge coverage coverage-final.json
rm -rf coverage
mkdir coverage
mv coverage-final.json coverage/coverage-final.json
npx nyc report -t coverage --reporter=lcov --report-dir=coverage
env:
DB_PASSWORD:
LOG_LEVEL: warn
PORT: 3001
- name: Cypress run
uses: cypress-io/github-action@v2
env:
DB_PASSWORD:
DB_NAME: bm_e2e_tests
LOG_LEVEL: warn
PORT: 3000
NODE_ENV: production
ADMIN_USERNAME: 'admin@banmanagement.com'
ADMIN_PASSWORD: 'P%@#fjdVJ3Y%pdGR'
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_PROJECT_ID: ${{ secrets.PROJECT_ID }}
CONTACT_EMAIL: 'admin@banmanagement.com'
NOTIFICATION_VAPID_PUBLIC_KEY: ${{ secrets.NOTIFICATION_VAPID_PUBLIC_KEY }}
NOTIFICATION_VAPID_PRIVATE_KEY: ${{ secrets.NOTIFICATION_VAPID_PRIVATE_KEY }}
with:
install: false
build: npm run e2e:build
start: npm start
wait-on: 'http://127.0.0.1:3000'
record: true
- name: Coveralls Parallel
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
flag-name: run-${{ matrix.test_number }}
parallel: true
build_docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: docker build . # TODO cache
finish:
needs: test
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true