-
Notifications
You must be signed in to change notification settings - Fork 30
155 lines (135 loc) · 4.31 KB
/
api-binary-tests.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
name: Build and Test Linux Binary
on:
workflow_dispatch:
pull_request:
branches:
- main
paths:
- "api/source/**"
- "test/api/**"
- ".github/workflows/api-binary-tests.yml"
- "api/build.sh"
- "client/build.sh"
- "docs/build.sh"
push:
branches:
- main
paths:
- "api/source/**"
- "test/api/**"
- ".github/workflows/api-binary-tests.yml"
- "api/build.sh"
- "client/build.sh"
- "docs/build.sh"
env:
STIGMAN_API_PORT: 64001
STIGMAN_DB_HOST: localhost
STIGMAN_DB_PORT: 3306
STIGMAN_DB_PASSWORD: stigman
STIGMAN_API_AUTHORITY: http://127.0.0.1:8080/auth/realms/stigman
STIGMAN_SWAGGER_ENABLED: true
STIGMAN_SWAGGER_SERVER: http://127.0.0.1:64001/api
STIGMAN_SWAGGER_REDIRECT: http://127.0.0.1:64001/api-docs/oauth2-redirect.html
STIGMAN_DEV_RESPONSE_VALIDATION: logOnly
STIGMAN_EXPERIMENTAL_APPDATA: 'true'
STIGMAN_OIDC_PROVIDER: http://127.0.0.1:8080/auth/realms/stigman
jobs:
build-artifacts:
name: Build binary artifacts
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Get repository metadata
id: repo
uses: actions/github-script@v7
with:
script: |
const repo = await github.rest.repos.get(context.repo)
return repo.data
- name: install uglify
run: |
sudo npm install -g uglify-js
- name: run build script
id: run-the-build-script
working-directory: ./api
run: ./build.sh
- name: Upload builds
if: always()
uses: actions/upload-artifact@v4
with:
name: binary-artifacts
path: ./api/bin/
if-no-files-found: error
- name: Upload archives
if: always()
uses: actions/upload-artifact@v4
with:
name: binary-archives
path: ./api/dist/
if-no-files-found: error
run-test-linux-binary-artifact:
name: Run and test linux artifact
needs: build-artifacts
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Run mock Keycloak
id: idp-run
working-directory: test/api/mock-keycloak
run: |
python3 -m http.server 8080 &
- name: Run MySQL container
id: mysql-run
run: |
docker run -d --name stig-manager-db \
-p 3306:3306 \
-e MYSQL_ROOT_PASSWORD=rootpw \
-e MYSQL_DATABASE=stigman \
-e MYSQL_USER=stigman \
-e MYSQL_PASSWORD=stigman \
mysql:8.0.24
- name: wait 10 seconds
run: sleep 10
- name: Download builds
uses: actions/download-artifact@v4
with:
name: binary-artifacts
path: ./binary-artifacts
- name: Set execute permissions on binary
run: chmod +x ./binary-artifacts/stig-manager-linuxstatic
- name: Run linux binary and log output
working-directory: ./
run: |
mkdir -p ./binary-artifacts/logs
echo "Running tests on binary artifacts"
./binary-artifacts/stig-manager-linuxstatic > ./binary-artifacts/logs/output.log 2>&1 &
echo $! > binary-artifacts/stig-manager.pid
- name: Wait for bootstrap
run: for i in {1..10}; do [ $i -gt 1 ] && sleep 5; curl --output /dev/null --silent --fail http://localhost:64001/api/op/configuration && s=0 && break || s=$?; printf '.'; done; (exit $s)
- name: Install test dependencies
run: npm ci
working-directory: ./test/api/
- name: Run tests with coverage and log output
working-directory: ./test/api/
run: |
npm test 2>&1 | tee ../../binary-artifacts/logs/test-output.log
- name: Stop linux binary
if: always()
run: |
if [ -f binary-artifacts/stig-manager.pid ]; then
kill $(cat binary-artifacts/stig-manager.pid) || true
fi
- name: Upload logs
if: always()
uses: actions/upload-artifact@v4
with:
name: test-logs
path: ./binary-artifacts/logs/