Skip to content

Commit fe4e268

Browse files
authored
Merge pull request #71 from NLESC-JCER/66-readme-flow
reworking the general flow of the README
2 parents b1fd906 + c81f7ca commit fe4e268

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+443
-223
lines changed

.github/workflows/main.yml

Lines changed: 100 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
run: ./build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output make all
5151
- name: Restore wasm
5252
# As we want to analyse files in git not files we just build
53-
run: git restore src/js/newtonraphsonwasm.js src/js/newtonraphsonwasm.wasm
53+
run: git restore webassembly/newtonraphsonwasm.js webassembly/newtonraphsonwasm.wasm
5454
- name: Relativize bw-output
5555
# Build wrapper runs on CI server while sonar-scanner runs in Docker container need to adjust paths
5656
run: perl -pi -e 's@/home/runner/work/cpp2wasm/cpp2wasm@/github/workspace@g' bw-output/build-wrapper-dump.json
@@ -59,7 +59,7 @@ jobs:
5959
env:
6060
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6161
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
62-
cpp:
62+
cli:
6363
# The type of runner that the job will run on
6464
runs-on: ubuntu-latest
6565

@@ -68,11 +68,64 @@ jobs:
6868
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
6969
- uses: actions/checkout@v2
7070

71-
- name: Run C++ examples
72-
run: make test-cli test-cgi
73-
python:
71+
- name: Run C++ test for CLI
72+
run: make test-cli
73+
cgi:
7474
# The type of runner that the job will run on
75-
name: Python ${{ matrix.python-version }}
75+
runs-on: ubuntu-latest
76+
77+
# Steps represent a sequence of tasks that will be executed as part of the job
78+
steps:
79+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
80+
- uses: actions/checkout@v2
81+
82+
- name: Run C++ test for CGI
83+
run: make test-cgi
84+
openapi:
85+
# The type of runner that the job will run on
86+
name: openapi / python-${{ matrix.python-version }}
87+
runs-on: ubuntu-latest
88+
strategy:
89+
matrix:
90+
python-version: [3.6, 3.7, 3.8]
91+
fail-fast: true
92+
steps:
93+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
94+
- uses: actions/checkout@v2
95+
96+
- name: Set up Python ${{ matrix.python-version }}
97+
uses: actions/setup-python@v1
98+
with:
99+
python-version: ${{ matrix.python-version }}
100+
architecture: "x64"
101+
102+
- name: Which Python
103+
run: which python
104+
105+
- name: Install Python dependencies
106+
run: make openapi-deps
107+
108+
- name: Run Python example
109+
run: make test-py
110+
111+
- name: Start web service in background
112+
run: |
113+
make run-webservice 2>&1 | tee ./run-webservice.log &
114+
# Wait for web service to spin up
115+
sleep 1
116+
117+
- name: Test web service
118+
run: make test-webservice
119+
120+
- name: Upload log of services
121+
if: ${{ always() }}
122+
uses: actions/upload-artifact@v2
123+
with:
124+
name: openapi-service-logs
125+
path: ./run-*.log
126+
flask:
127+
# The type of runner that the job will run on
128+
name: flask / python-${{ matrix.python-version }}
76129
runs-on: ubuntu-latest
77130
strategy:
78131
matrix:
@@ -98,34 +151,35 @@ jobs:
98151
run: which python
99152

100153
- name: Install Python dependencies
101-
run: make py-deps && pip install httpie
154+
run: make flask-deps && pip install httpie
102155

103-
- name: Run Python example
104-
run: make test-py
156+
- name: Build shared library and link to it
157+
run: |
158+
make flask/newtonraphsonpy.*.so
105159
106160
- name: Start web application in background
107-
run: make run-webapp 2>&1 | tee ./run-webapp.log &
161+
run: |
162+
make run-webapp 2>&1 | tee ./run-webapp.log &
163+
# Wait for web application to spin up
164+
sleep 1
108165
109166
- name: Test web application
110167
run: http --ignore-stdin -f localhost:5001 epsilon=0.001 guess=-20
111168

112-
- name: Start web service in background
113-
run: make run-webservice 2>&1 | tee ./run-webservice.log &
114-
115-
- name: Test web service
116-
run: make test-webservice
117-
118169
- name: Start Celery web app in background
119-
run: make run-celery-webapp 2>&1 | tee ./run-celery-webapp.log &
170+
run: |
171+
make run-celery-webapp 2>&1 | tee ./run-celery-webapp.log &
120172
121173
- name: Start Celery worker in background
122174
run: |
123-
cd src/py
175+
cd flask
124176
PYTHONPATH=$PWD/../.. celery -A tasks worker 2>&1 | tee ./run-celery-worker.log &
125177
cd ../..
126178
127179
- name: Test Celery web app
128180
run: |
181+
# Wait for web celery app and worker to spin up
182+
sleep 1
129183
http --ignore-stdin -hf localhost:5000 epsilon=0.001 guess=-20 | tee response.txt
130184
# Parse result url from response
131185
RESULT_URL=$(cat response.txt |grep Location |awk '{print $2}')
@@ -136,9 +190,9 @@ jobs:
136190
if: ${{ always() }}
137191
uses: actions/upload-artifact@v2
138192
with:
139-
name: service-logs
193+
name: flask-service-logs
140194
path: ./run-*.log
141-
wasm:
195+
webassembly:
142196
runs-on: ubuntu-latest
143197
steps:
144198
- uses: actions/checkout@v2
@@ -153,14 +207,37 @@ jobs:
153207
run: make build-wasm
154208

155209
- name: Start web server for hosting files in background
156-
run: make host-files 2>&1 | tee ./web-server.log &
210+
run: make host-webassembly-files 2>&1 | tee ./web-server.log &
211+
212+
- name: Run tests
213+
run: make test-webassembly
214+
215+
- name: Upload log of web server
216+
if: ${{ always() }}
217+
uses: actions/upload-artifact@v2
218+
with:
219+
name: webassembly-service-log
220+
path: ./web-server.log
221+
react:
222+
runs-on: ubuntu-latest
223+
steps:
224+
- uses: actions/checkout@v2
225+
226+
- name: Install emscripten
227+
uses: mymindstorm/setup-emsdk@v4
228+
229+
- name: Build WebAssembly module and link to it from react/
230+
run: make react/newtonraphsonwasm.js react/newtonraphsonwasm.wasm
231+
232+
- name: Start web server for hosting files in background
233+
run: make host-react-files 2>&1 | tee ./web-server.log &
157234

158235
- name: Run tests
159-
run: make test-wasm
236+
run: make test-react
160237

161238
- name: Upload log of web server
162239
if: ${{ always() }}
163240
uses: actions/upload-artifact@v2
164241
with:
165-
name: web-server-log
242+
name: react-service-log
166243
path: ./web-server.log

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ __pycache__/
44
cypress/plugins
55
cypress/support
66
cypress/videos
7+
/cypress/screenshots
78

89
# Ignore compiled files
9-
bin/newtonraphson.exe
10-
src/py/newtonraphsonpy.*.so
11-
apache2/cgi-bin/newtonraphson
10+
/cli/newtonraphson.exe
11+
/cgi/apache2/cgi-bin/newtonraphson
12+
/openapi/newtonraphsonpy.*.so
13+
/flask/newtonraphsonpy.*.so
1214

1315
# Ignore entangled db
1416
.entangled/db.sqlite

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
* Directory structure ([#67](https://github.com/NLESC-JCER/cpp2wasm/issues/67))
13+
* Makefile does less entangles ([#61](https://github.com/NLESC-JCER/cpp2wasm/issues/61))
14+
1015
## [0.3.0] - 2020-06-09
1116

1217
### Added

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Ready to contribute? Here's how to set up `cpp2wasm` for local development.
8181
make entangle
8282
```
8383
84-
7. When `src/js/newtonraphsonwasm.js` changes, the WebAssembly module also has to be rebuilt. This will require [emscripten](README.md#accessing-c-function-from-JavaScript-in-web-browser). To rebuild the WebAssembly module run:
84+
7. When `cli/*hpp` or `webassembly/wasm-newtonraphson.cpp` changes, the WebAssembly module also has to be rebuilt. This will require [emscripten](README.md#accessing-c-function-from-JavaScript-in-web-browser). To rebuild the WebAssembly module run:
8585
8686
```shell
8787
make build-wasm

INSTALL.md

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ All the commands in the [README.md](README.md) and [CONTRIBUTING.md](CONTRIBUTIN
1717

1818
```{.makefile file=Makefile}
1919
# this Makefile snippet is stored as Makefile
20-
.PHONY: clean clean-compiled clean-entangled test all check entangle entangle-list py-deps start-redis stop-redis run-webservice run-celery-webapp run-webapp build-wasm host-files test-wasm
20+
.PHONY: clean clean-compiled clean-entangled test all entangle entangle-list py-deps test-cgi test-cli test-py start-redis stop-redis run-webservice test-webservice run-celery-worker run-celery-webapp run-webapp build-wasm host-webassembly-files host-react-files test-webassembly test-react init-git-hook check
2121

2222
UID := $(shell id -u)
2323
# Prevent suicide by excluding Makefile
2424
ENTANGLED := $(shell perl -ne 'print $$1,"\n" if /^```\{.*file=(.*)\}/' *.md | grep -v Makefile | sort -u)
25-
COMPILED := bin/newtonraphson.exe src/py/newtonraphsonpy.*.so apache2/cgi-bin/newtonraphson src/js/newtonraphsonwasm.js src/js/newtonraphsonwasm.wasm
25+
COMPILED := cli/newtonraphson.exe openapi/newtonraphsonpy.*.so flask/newtonraphsonpy.*.so cgi/apache2/cgi-bin/newtonraphson webassembly/newtonraphsonwasm.js webassembly/newtonraphsonwasm.wasm react/newtonraphsonwasm.js react/newtonraphsonwasm.wasm
2626

2727
entangle: *.md
2828
<<pandoc-tangle>>
@@ -32,7 +32,11 @@ $(ENTANGLED): entangle
3232
entangled-list:
3333
@echo $(ENTANGLED)
3434

35-
py-deps: pip-pybind11 pip-flask pip-celery pip-connexion
35+
flask-deps: pip-pybind11 pip-celery pip-flask
36+
37+
openapi-deps: pip-pybind11 pip-connexion
38+
39+
py-deps: flask-deps openapi-deps
3640

3741
pip-pybind11:
3842
<<pip-pybind11>>
@@ -46,22 +50,25 @@ pip-celery:
4650
pip-connexion:
4751
<<pip-connexion>>
4852

49-
bin/newtonraphson.exe: src/cli-newtonraphson.cpp
53+
cli/newtonraphson.exe:
5054
<<build-cli>>
5155

52-
test-cli: bin/newtonraphson.exe
56+
test-cli: cli/newtonraphson.exe
5357
<<test-cli>>
5458

55-
apache2/cgi-bin/newtonraphson: src/cgi-newtonraphson.cpp
59+
cgi/apache2/cgi-bin/newtonraphson:
5660
<<build-cgi>>
5761

58-
test-cgi: apache2/cgi-bin/newtonraphson
62+
test-cgi: cgi/apache2/cgi-bin/newtonraphson
5963
<<test-cgi>>
6064

61-
src/py/newtonraphsonpy.*.so: src/py-newtonraphson.cpp
65+
openapi/newtonraphsonpy.*.so:
6266
<<build-py>>
6367

64-
test-py: src/py/example.py src/py/newtonraphsonpy.*.so
68+
flask/newtonraphsonpy.*.so: openapi/newtonraphsonpy.*.so
69+
<<flask-link-newtonraphsonpy>>
70+
71+
test-py: openapi/newtonraphsonpy.*.so
6572
<<test-py>>
6673

6774
test: test-cli test-cgi test-py test-webservice
@@ -84,31 +91,46 @@ start-redis:
8491
stop-redis:
8592
<<stop-redis>>
8693

87-
run-webapp: src/py/newtonraphsonpy.*.so
94+
run-webapp: flask/newtonraphsonpy.*.so
8895
<<run-webapp>>
8996

90-
run-webservice: src/py/newtonraphsonpy.*.so
97+
run-webservice: openapi/newtonraphsonpy.*.so
9198
<<run-webservice>>
9299

93100
test-webservice:
94101
<<test-webservice>>
95102

96-
run-celery-worker: src/py/newtonraphsonpy.*.so
103+
run-celery-worker: flask/newtonraphsonpy.*.so
97104
<<run-celery-worker>>
98105

99-
run-celery-webapp: src/py/newtonraphsonpy.*.so
106+
run-celery-webapp: flask/newtonraphsonpy.*.so
100107
<<run-celery-webapp>>
101108

102-
build-wasm: src/js/newtonraphsonwasm.js src/js/newtonraphsonwasm.wasm
109+
build-wasm: webassembly/newtonraphsonwasm.js webassembly/newtonraphsonwasm.wasm
103110

104-
src/js/newtonraphsonwasm.js src/js/newtonraphsonwasm.wasm: src/wasm-newtonraphson.cpp
111+
webassembly/newtonraphsonwasm.js webassembly/newtonraphsonwasm.wasm:
105112
<<build-wasm>>
106113

107-
host-files: build-wasm
114+
react/newtonraphsonwasm.wasm: webassembly/newtonraphsonwasm.wasm
115+
<<link-webassembly-wasm>>
116+
117+
react/newtonraphsonwasm.js: webassembly/newtonraphsonwasm.js
118+
<<link-webassembly-js>>
119+
120+
host-webassembly-files: build-wasm
108121
<<host-files>>
109122

110-
test-wasm:
111-
<<test-wasm>>
123+
host-react-files: react/newtonraphsonwasm.js react/newtonraphsonwasm.wasm
124+
<<host-files>>
125+
126+
test-webassembly:
127+
<<test-webassembly>>
128+
129+
react/worker.js:
130+
<<link-worker>>
131+
132+
test-react: react/worker.js
133+
<<test-react>>
112134

113135
init-git-hook:
114136
<<hook-permission>>

0 commit comments

Comments
 (0)