Skip to content

Commit

Permalink
Merge pull request #71 from NLESC-JCER/66-readme-flow
Browse files Browse the repository at this point in the history
reworking the general flow of the README
  • Loading branch information
jspaaks authored Jun 10, 2020
2 parents b1fd906 + c81f7ca commit fe4e268
Show file tree
Hide file tree
Showing 49 changed files with 443 additions and 223 deletions.
123 changes: 100 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
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 src/js/newtonraphsonwasm.js src/js/newtonraphsonwasm.wasm
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
Expand All @@ -59,7 +59,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
cpp:
cli:
# The type of runner that the job will run on
runs-on: ubuntu-latest

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

- name: Run C++ examples
run: make test-cli test-cgi
python:
- name: Run C++ test for CLI
run: make test-cli
cgi:
# The type of runner that the job will run on
name: Python ${{ matrix.python-version }}
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:
Expand All @@ -98,34 +151,35 @@ jobs:
run: which python

- name: Install Python dependencies
run: make py-deps && pip install httpie
run: make flask-deps && pip install httpie

- name: Run Python example
run: make test-py
- 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 &
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 web service in background
run: make run-webservice 2>&1 | tee ./run-webservice.log &

- name: Test web service
run: make test-webservice

- name: Start Celery web app in background
run: make run-celery-webapp 2>&1 | tee ./run-celery-webapp.log &
run: |
make run-celery-webapp 2>&1 | tee ./run-celery-webapp.log &
- name: Start Celery worker in background
run: |
cd src/py
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}')
Expand All @@ -136,9 +190,9 @@ jobs:
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: service-logs
name: flask-service-logs
path: ./run-*.log
wasm:
webassembly:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand All @@ -153,14 +207,37 @@ jobs:
run: make build-wasm

- name: Start web server for hosting files in background
run: make host-files 2>&1 | tee ./web-server.log &
run: make host-webassembly-files 2>&1 | tee ./web-server.log &

- name: Run tests
run: make test-webassembly

- name: Upload log of web server
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: webassembly-service-log
path: ./web-server.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-wasm
run: make test-react

- name: Upload log of web server
if: ${{ always() }}
uses: actions/upload-artifact@v2
with:
name: web-server-log
name: react-service-log
path: ./web-server.log
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ __pycache__/
cypress/plugins
cypress/support
cypress/videos
/cypress/screenshots

# Ignore compiled files
bin/newtonraphson.exe
src/py/newtonraphsonpy.*.so
apache2/cgi-bin/newtonraphson
/cli/newtonraphson.exe
/cgi/apache2/cgi-bin/newtonraphson
/openapi/newtonraphsonpy.*.so
/flask/newtonraphsonpy.*.so

# Ignore entangled db
.entangled/db.sqlite
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

* Directory structure ([#67](https://github.com/NLESC-JCER/cpp2wasm/issues/67))
* Makefile does less entangles ([#61](https://github.com/NLESC-JCER/cpp2wasm/issues/61))

## [0.3.0] - 2020-06-09

### Added
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Ready to contribute? Here's how to set up `cpp2wasm` for local development.
make entangle
```
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:
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:
```shell
make build-wasm
Expand Down
58 changes: 40 additions & 18 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ All the commands in the [README.md](README.md) and [CONTRIBUTING.md](CONTRIBUTIN

```{.makefile file=Makefile}
# this Makefile snippet is stored as Makefile
.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
.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

UID := $(shell id -u)
# Prevent suicide by excluding Makefile
ENTANGLED := $(shell perl -ne 'print $$1,"\n" if /^```\{.*file=(.*)\}/' *.md | grep -v Makefile | sort -u)
COMPILED := bin/newtonraphson.exe src/py/newtonraphsonpy.*.so apache2/cgi-bin/newtonraphson src/js/newtonraphsonwasm.js src/js/newtonraphsonwasm.wasm
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

entangle: *.md
<<pandoc-tangle>>
Expand All @@ -32,7 +32,11 @@ $(ENTANGLED): entangle
entangled-list:
@echo $(ENTANGLED)

py-deps: pip-pybind11 pip-flask pip-celery pip-connexion
flask-deps: pip-pybind11 pip-celery pip-flask

openapi-deps: pip-pybind11 pip-connexion

py-deps: flask-deps openapi-deps

pip-pybind11:
<<pip-pybind11>>
Expand All @@ -46,22 +50,25 @@ pip-celery:
pip-connexion:
<<pip-connexion>>

bin/newtonraphson.exe: src/cli-newtonraphson.cpp
cli/newtonraphson.exe:
<<build-cli>>

test-cli: bin/newtonraphson.exe
test-cli: cli/newtonraphson.exe
<<test-cli>>

apache2/cgi-bin/newtonraphson: src/cgi-newtonraphson.cpp
cgi/apache2/cgi-bin/newtonraphson:
<<build-cgi>>

test-cgi: apache2/cgi-bin/newtonraphson
test-cgi: cgi/apache2/cgi-bin/newtonraphson
<<test-cgi>>

src/py/newtonraphsonpy.*.so: src/py-newtonraphson.cpp
openapi/newtonraphsonpy.*.so:
<<build-py>>

test-py: src/py/example.py src/py/newtonraphsonpy.*.so
flask/newtonraphsonpy.*.so: openapi/newtonraphsonpy.*.so
<<flask-link-newtonraphsonpy>>

test-py: openapi/newtonraphsonpy.*.so
<<test-py>>

test: test-cli test-cgi test-py test-webservice
Expand All @@ -84,31 +91,46 @@ start-redis:
stop-redis:
<<stop-redis>>

run-webapp: src/py/newtonraphsonpy.*.so
run-webapp: flask/newtonraphsonpy.*.so
<<run-webapp>>

run-webservice: src/py/newtonraphsonpy.*.so
run-webservice: openapi/newtonraphsonpy.*.so
<<run-webservice>>

test-webservice:
<<test-webservice>>

run-celery-worker: src/py/newtonraphsonpy.*.so
run-celery-worker: flask/newtonraphsonpy.*.so
<<run-celery-worker>>

run-celery-webapp: src/py/newtonraphsonpy.*.so
run-celery-webapp: flask/newtonraphsonpy.*.so
<<run-celery-webapp>>

build-wasm: src/js/newtonraphsonwasm.js src/js/newtonraphsonwasm.wasm
build-wasm: webassembly/newtonraphsonwasm.js webassembly/newtonraphsonwasm.wasm

src/js/newtonraphsonwasm.js src/js/newtonraphsonwasm.wasm: src/wasm-newtonraphson.cpp
webassembly/newtonraphsonwasm.js webassembly/newtonraphsonwasm.wasm:
<<build-wasm>>

host-files: build-wasm
react/newtonraphsonwasm.wasm: webassembly/newtonraphsonwasm.wasm
<<link-webassembly-wasm>>

react/newtonraphsonwasm.js: webassembly/newtonraphsonwasm.js
<<link-webassembly-js>>

host-webassembly-files: build-wasm
<<host-files>>

test-wasm:
<<test-wasm>>
host-react-files: react/newtonraphsonwasm.js react/newtonraphsonwasm.wasm
<<host-files>>

test-webassembly:
<<test-webassembly>>

react/worker.js:
<<link-worker>>

test-react: react/worker.js
<<test-react>>

init-git-hook:
<<hook-permission>>
Expand Down
Loading

0 comments on commit fe4e268

Please sign in to comment.