-
Notifications
You must be signed in to change notification settings - Fork 6
270 lines (227 loc) · 8.36 KB
/
main.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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on: [push, pull_request, workflow_dispatch]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
entangle:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Check all entangled files are in sync with Markdown
run: make check
sonarcloud:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
architecture: "x64"
- name: Install Python dependencies
run: make py-deps
- name: Install emscripten
uses: mymindstorm/setup-emsdk@v6
with:
version: 1.39.17
actions-cache-folder: 'emsdk-cache'
- name: Cache SonarCloud Build Wrapper
id: cache-bw
uses: actions/cache@v2
with:
path: build-wrapper-linux-x86
key: ${{ runner.os }}-bw
- name: Install SonarCloud Build Wrapper
if: steps.cache-bw.outputs.cache-hit != 'true'
run: |
wget https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
unzip build-wrapper-linux-x86.zip
rm -f build-wrapper-linux-x86.zip
- name: Remove all compiled files
run: make clean-compiled
- name: Compile C++ files using wrapper
run: ./build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output make all
- name: Restore wasm
# As we want to analyse files in git not files we just build
run: git restore webassembly/newtonraphsonwasm.js webassembly/newtonraphsonwasm.wasm
- name: Relativize bw-output
# Build wrapper runs on CI server while sonar-scanner runs in Docker container need to adjust paths
run: perl -pi -e 's@/home/runner/work/cpp2wasm/cpp2wasm@/github/workspace@g' bw-output/build-wrapper-dump.json
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
cli:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Run C++ test for CLI
run: make test-cli
cgi:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Run C++ test for CGI
run: make test-cgi
openapi:
# The type of runner that the job will run on
name: openapi / python-${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
fail-fast: true
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
architecture: "x64"
- name: Which Python
run: which python
- name: Install Python dependencies
run: make openapi-deps
- name: Run Python example
run: make test-py
- name: Start web service in background
run: |
make run-webservice 2>&1 | tee ./run-webservice.log &
# Wait for web service to spin up
sleep 1
- name: Test web service
run: make test-webservice
- name: Upload log of services
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: openapi-service-logs
path: ./run-*.log
flask:
# The type of runner that the job will run on
name: flask / python-${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
fail-fast: true
# Redis is needed for Celery
services:
redis:
image: redis
ports:
- 6379:6379
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: "x64"
- name: Which Python
run: which python
- name: Install Python dependencies
run: make flask-deps && pip install httpie
- name: Build shared library and link to it
run: |
make flask/newtonraphsonpy.*.so
- name: Start web application in background
run: |
make run-webapp 2>&1 | tee ./run-webapp.log &
# Wait for web application to spin up
sleep 1
- name: Test web application
run: http --ignore-stdin -f localhost:5001 epsilon=0.001 guess=-20
- name: Start Celery web app in background
run: |
make run-celery-webapp 2>&1 | tee ./run-celery-webapp.log &
- name: Start Celery worker in background
run: |
cd flask
PYTHONPATH=$PWD/../.. celery -A tasks worker 2>&1 | tee ./run-celery-worker.log &
cd ../..
- name: Test Celery web app
run: |
# Wait for web celery app and worker to spin up
sleep 1
http --ignore-stdin -hf localhost:5000 epsilon=0.001 guess=-20 | tee response.txt
# Parse result url from response
RESULT_URL=$(cat response.txt |grep Location |awk '{print $2}')
sleep 2
http --ignore-stdin $RESULT_URL
- name: Upload log of services
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: flask-service-logs
path: ./run-*.log
webassembly:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install emscripten
uses: mymindstorm/setup-emsdk@v5
with:
version: 1.39.17
actions-cache-folder: 'emsdk-cache'
- name: Build WebAssembly module
run: make build-wasm
- name: Test from command line
run: make test-wasm-cli
- name: Start web server for hosting files in background
run: make host-webassembly-files 2>&1 | tee ./run-host-service.log &
- name: Run tests
run: make test-webassembly
- name: Install Node.js dependencies
run: make js-deps
- name: Start web service in background
run: make run-js-webservice 2>&1 | tee ./run-web-service.log &
- name: Test web service
run: make test-js-webservice
- name: Test web service with invalid request
run: make test-js-webservice-invalid || test $? -eq 2
- name: Start OpenAPI web service in background
run: make run-js-openapi 2>&1 | tee ./run-openapi-web-service.log &
- name: Test OpenAPI web service
run: make test-js-openapi
- name: Start OpenAPI threaded web service in background
run: make run-js-threaded 2>&1 | tee ./run-threaded-web-service.log &
- name: Test OpenAPI threaded web service
run: make test-js-threaded
- name: Upload log of services
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: webassembly-service-logs
path: ./run-*.log
react:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install emscripten
uses: mymindstorm/setup-emsdk@v4
- name: Build WebAssembly module and link to it from react/
run: make react/newtonraphsonwasm.js react/newtonraphsonwasm.wasm
- name: Start web server for hosting files in background
run: make host-react-files 2>&1 | tee ./web-server.log &
- name: Run tests
run: make test-react
- name: Upload log of web server
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: react-service-log
path: ./web-server.log