From bf19a4276b7eef17bbea85fdd43cf3cc95571b25 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Thu, 12 Mar 2020 14:54:14 +0100 Subject: [PATCH 01/12] Added Github Actions workflow --- .github/workflows/main.yml | 56 ++++++++++++++++++++++++++++++++++++++ INSTALL.md | 19 +++++++++---- Makefile | 24 ++++++++++++++-- README.md | 10 +++++-- 4 files changed, 100 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..fe2fcc1 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,56 @@ +# 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] + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + cpp: + # 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 + + # Should not be needed anymore when https://github.com/NLESC-JCER/cpp2wasm/issues/1 is fixed + - name: Generate source code + run: docker run --rm -ti --user $(id -u) -v ${PWD}:/data nlesc/pandoc-tangle README.md INSTALL.md + + # Should not be needed anymore when https://github.com/entangled/filters/issues/2 is fixed + - name: Correct Makefile + run: perl -pi -e 's/ /\t/' Makefile + + - name: Run C++ examples + run: make test-cli test-cgi + python: + # 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 + + # Should not be needed anymore when https://github.com/NLESC-JCER/cpp2wasm/issues/1 is fixed + - name: Generate source code + run: docker run --rm -ti --user $(id -u) -v ${PWD}:/data nlesc/pandoc-tangle README.md INSTALL.md + + # Should not be needed anymore when https://github.com/entangled/filters/issues/2 is fixed + - name: Correct Makefile + run: perl -pi -e 's/ /\t/' Makefile + + - uses: actions/setup-python@v1 + with: + python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax + architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified + + - name: Install Python dependencies + run: make py-deps + + - name: Run Python example + run: make test-py \ No newline at end of file diff --git a/INSTALL.md b/INSTALL.md index 290dfe9..4035586 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -4,9 +4,10 @@ To run the commands in the README.md the following items are required -1. [Apache httpd server 2.4](http://httpd.apache.org/) -1. Python devel with `sudo apt install python3-dev` +1. [Apache httpd server 2.4](http://httpd.apache.org/) with `sudo apt install -y apache2` +1. Python devel with `sudo apt install -y python3-dev` 1. [Emscriptem](https://emscripten.org/docs/getting_started/downloads.html) +1. [Docker Engine](https://docs.docker.com/install/) ## Generating code from Markdown @@ -30,9 +31,9 @@ docker run --rm -ti --user $(id -u) -v ${PWD}:/data nlesc/pandoc-tangle README.m All the commands in the README.md can be captured in a Makefile like so: ```{.makefile file=Makefile} -.PHONY: clean test entangle deps +.PHONY: clean test entangle py-deps start-redis stop-redis -deps: pip-pybind11 pip-flask pip-celery pip-connexion +py-deps: pip-pybind11 pip-flask pip-celery pip-connexion pip-pybind11: <> @@ -43,7 +44,7 @@ pip-flask: pip-celery: <> -pip-connexion +pip-connexion: > newtonraphson.exe: cli-newtonraphson.cpp @@ -68,4 +69,12 @@ test: test-cli test-cgi test-py clean: $(RM) newtonraphson.exe newtonraphsonpy.*.so cgi-bin/newtonraphson + +start-redis: + <> + +stop-redis: + <> ``` + +Some of the commands expect a Debian based OS like Ubuntu. diff --git a/Makefile b/Makefile index 4e2e7fe..1a2562f 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,18 @@ -.PHONY: clean test entangle +.PHONY: clean test entangle py-deps start-redis stop-redis + +py-deps: pip-pybind11 pip-flask pip-celery pip-connexion + +pip-pybind11: + pip install pybind11 + +pip-flask: + pip install flask + +pip-celery: + pip install celery[redis] + +pip-connexion: + > newtonraphson.exe: cli-newtonraphson.cpp g++ cli-newtonraphson.cpp -o newtonraphson.exe @@ -22,4 +36,10 @@ test-py: example.py newtonraphsonpy.*.so test: test-cli test-cgi test-py clean: - $(RM) newtonraphson.exe newtonraphsonpy.*.so cgi-bin/newtonraphson \ No newline at end of file + $(RM) newtonraphson.exe newtonraphsonpy.*.so cgi-bin/newtonraphson + +start-redis: + docker run --rm -d -p 6379:6379 --name some-redis redis + +stop-redis: + docker stop some-redis \ No newline at end of file diff --git a/README.md b/README.md index d438313..7365f65 100644 --- a/README.md +++ b/README.md @@ -472,8 +472,8 @@ When performing a long calculation (more than 30 seconds), the end-user requires Celery needs a broker for a queue and result storage. Will use [redis](https://redis.io/) in a Docker container as Celery broker, because it's simple to setup. Redis can be started with the following command -```{.awk #run-redis} -docker run -d -p 6379:6379 redis +```{.awk #start-redis} +docker run --rm -d -p 6379:6379 --name some-redis redis ``` To use Celery we must install the redis flavoured version with @@ -577,6 +577,12 @@ To test web service 2. Submit form, 3. Refresh result page until progress states are replaced with result. +The redis server can be shutdown with + +```{.awk #stop-redis} +docker stop some-redis +``` + ### Web service A web application is meant for consumption by humans and web service is meant for consumption by machines or other programs. From bd90d4de077b255261468c0a5d24b2aff1dd5e70 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Thu, 12 Mar 2020 14:58:53 +0100 Subject: [PATCH 02/12] Dont need tty --- .github/workflows/main.yml | 4 ++-- Makefile | 28 ++++++++++++++-------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fe2fcc1..feef381 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,7 +19,7 @@ jobs: # Should not be needed anymore when https://github.com/NLESC-JCER/cpp2wasm/issues/1 is fixed - name: Generate source code - run: docker run --rm -ti --user $(id -u) -v ${PWD}:/data nlesc/pandoc-tangle README.md INSTALL.md + run: docker run --rm --user $(id -u) -v ${PWD}:/data nlesc/pandoc-tangle README.md INSTALL.md # Should not be needed anymore when https://github.com/entangled/filters/issues/2 is fixed - name: Correct Makefile @@ -38,7 +38,7 @@ jobs: # Should not be needed anymore when https://github.com/NLESC-JCER/cpp2wasm/issues/1 is fixed - name: Generate source code - run: docker run --rm -ti --user $(id -u) -v ${PWD}:/data nlesc/pandoc-tangle README.md INSTALL.md + run: docker run --rm --user $(id -u) -v ${PWD}:/data nlesc/pandoc-tangle README.md INSTALL.md # Should not be needed anymore when https://github.com/entangled/filters/issues/2 is fixed - name: Correct Makefile diff --git a/Makefile b/Makefile index 1a2562f..8bdf90e 100644 --- a/Makefile +++ b/Makefile @@ -3,43 +3,43 @@ py-deps: pip-pybind11 pip-flask pip-celery pip-connexion pip-pybind11: - pip install pybind11 + pip install pybind11 pip-flask: - pip install flask + pip install flask pip-celery: - pip install celery[redis] + pip install celery[redis] pip-connexion: - > + > newtonraphson.exe: cli-newtonraphson.cpp - g++ cli-newtonraphson.cpp -o newtonraphson.exe + g++ cli-newtonraphson.cpp -o newtonraphson.exe test-cli: newtonraphson.exe - ./newtonraphson.exe + ./newtonraphson.exe cgi-bin/newtonraphson: cgi-newtonraphson.cpp - g++ -Ideps cgi-newtonraphson.cpp -o ./cgi-bin/newtonraphson + g++ -Ideps cgi-newtonraphson.cpp -o ./cgi-bin/newtonraphson test-cgi: cgi-bin/newtonraphson - echo '{"guess":-20, "epsilon":0.001}' | ./cgi-bin/newtonraphson + echo '{"guess":-20, "epsilon":0.001}' | ./cgi-bin/newtonraphson newtonraphsonpy.*.so: py-newtonraphson.cpp - g++ -O3 -Wall -shared -std=c++14 -fPIC `python3 -m pybind11 --includes` \ - py-newtonraphson.cpp -o newtonraphsonpy`python3-config --extension-suffix` + g++ -O3 -Wall -shared -std=c++14 -fPIC `python3 -m pybind11 --includes` \ + py-newtonraphson.cpp -o newtonraphsonpy`python3-config --extension-suffix` test-py: example.py newtonraphsonpy.*.so - python example.py + python example.py test: test-cli test-cgi test-py clean: - $(RM) newtonraphson.exe newtonraphsonpy.*.so cgi-bin/newtonraphson + $(RM) newtonraphson.exe newtonraphsonpy.*.so cgi-bin/newtonraphson start-redis: - docker run --rm -d -p 6379:6379 --name some-redis redis + docker run --rm -d -p 6379:6379 --name some-redis redis stop-redis: - docker stop some-redis \ No newline at end of file + docker stop some-redis \ No newline at end of file From fb1b1d69ad573710011c19d51b7b6452c2f3dd89 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Thu, 12 Mar 2020 15:05:13 +0100 Subject: [PATCH 03/12] Make sure dirs for source code exist --- src/py/templates/.gitignore | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/py/templates/.gitignore diff --git a/src/py/templates/.gitignore b/src/py/templates/.gitignore new file mode 100644 index 0000000..e69de29 From 43324ecb168f34892606873ff5d0d69e209f8494 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Thu, 12 Mar 2020 15:09:15 +0100 Subject: [PATCH 04/12] Make sure cgi-bin exists --- cgi-bin/.gitignore | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 cgi-bin/.gitignore diff --git a/cgi-bin/.gitignore b/cgi-bin/.gitignore new file mode 100644 index 0000000..e69de29 From 86f01b247dd8373640140e1a590d96f47ba0bcac Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Thu, 12 Mar 2020 15:09:58 +0100 Subject: [PATCH 05/12] Typo Makefile --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 4035586..106db11 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -45,7 +45,7 @@ pip-celery: <> pip-connexion: - > + <> newtonraphson.exe: cli-newtonraphson.cpp <> From 3876be2b91cb265099e3b0cd6db2ba2b37fe49af Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Thu, 12 Mar 2020 17:02:58 +0100 Subject: [PATCH 06/12] Also test simple web app and celery web app --- .github/workflows/main.yml | 37 ++++++++++++++++++++++++++++- INSTALL.md | 32 +++++++++++++++++++++---- Makefile | 48 +++++++++++++++++++++++++------------- README.md | 29 ++++++++++++++--------- 4 files changed, 114 insertions(+), 32 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index feef381..6b493ed 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -53,4 +53,39 @@ jobs: run: make py-deps - name: Run Python example - run: make test-py \ No newline at end of file + run: make test-py + + - name: Start web application in background + run: make run-webapp & + + - name: Test web application + run: | + pip install httpie + http -hf localhost:5001 epsilon=0.001 guess=-20 + + - name: Start web service in background + run: make run-webservice & + + - name: Test web service + run: make test-webservice + + - name: Start redis + run: make start-redis + + - name: Start Celery web app in background + run: make start-celery-webapp & + + - name: Start Celery worker in background + run: | + cd src/py + PYTHONPATH=$PWD/../.. celery -A tasks worker & + cd ../.. + + - name: Test Celery web app + run: | + RESULT_URL=$(http -hf localhost:5000 epsilon=0.001 guess=-20 |grep Location |awk '{print $2}') + sleep 2 + http $RESULT_URL + + - name: Stop redis + run: make stop-redis \ No newline at end of file diff --git a/INSTALL.md b/INSTALL.md index 106db11..e74e951 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -1,5 +1,7 @@ # Installation +![CI](https://github.com/NLESC-JCER/cpp2wasm/workflows/CI/badge.svg) + ## Dependencies To run the commands in the README.md the following items are required @@ -31,7 +33,7 @@ docker run --rm -ti --user $(id -u) -v ${PWD}:/data nlesc/pandoc-tangle README.m All the commands in the README.md can be captured in a Makefile like so: ```{.makefile file=Makefile} -.PHONY: clean test entangle py-deps start-redis stop-redis +.PHONY: clean test entangle py-deps start-redis stop-redis run-webservice run-celery-webapp run-webapp py-deps: pip-pybind11 pip-flask pip-celery pip-connexion @@ -63,9 +65,9 @@ newtonraphsonpy.*.so: py-newtonraphson.cpp <> test-py: example.py newtonraphsonpy.*.so - python example.py + PYTHONPATH=${PWD} python src/py/example.py -test: test-cli test-cgi test-py +test: test-cli test-cgi test-py test-webservice clean: $(RM) newtonraphson.exe newtonraphsonpy.*.so cgi-bin/newtonraphson @@ -75,6 +77,28 @@ start-redis: stop-redis: <> + +run-webapp: newtonraphsonpy.*.so + <> + +run-webservice: newtonraphsonpy.*.so + <> + +test-webservice: + <> + +# Unable to get worker runnig correctly from Makefile, the newtonraphsonpy.*.so cannot be found +# run-celery-worker: newtonraphsonpy.*.so +# <> + +run-celery-webapp: newtonraphsonpy.*.so + <> +``` + +For example the Python dependencies can be installed with + +```shell +make py-deps ``` -Some of the commands expect a Debian based OS like Ubuntu. +See [GitHub Actions workflow](.github/workflows/main.yml) for other usages of the Makefile. diff --git a/Makefile b/Makefile index 8bdf90e..7291eac 100644 --- a/Makefile +++ b/Makefile @@ -1,45 +1,61 @@ -.PHONY: clean test entangle py-deps start-redis stop-redis +.PHONY: clean test entangle py-deps start-redis stop-redis run-webservice run-celery-webapp run-webapp py-deps: pip-pybind11 pip-flask pip-celery pip-connexion pip-pybind11: - pip install pybind11 + pip install pybind11 pip-flask: - pip install flask + pip install flask pip-celery: - pip install celery[redis] + pip install celery[redis] pip-connexion: - > + pip install connexion[swagger-ui] newtonraphson.exe: cli-newtonraphson.cpp - g++ cli-newtonraphson.cpp -o newtonraphson.exe + g++ cli-newtonraphson.cpp -o newtonraphson.exe test-cli: newtonraphson.exe - ./newtonraphson.exe + ./newtonraphson.exe cgi-bin/newtonraphson: cgi-newtonraphson.cpp - g++ -Ideps cgi-newtonraphson.cpp -o ./cgi-bin/newtonraphson + g++ -Ideps cgi-newtonraphson.cpp -o ./cgi-bin/newtonraphson test-cgi: cgi-bin/newtonraphson - echo '{"guess":-20, "epsilon":0.001}' | ./cgi-bin/newtonraphson + echo '{"guess":-20, "epsilon":0.001}' | ./cgi-bin/newtonraphson newtonraphsonpy.*.so: py-newtonraphson.cpp - g++ -O3 -Wall -shared -std=c++14 -fPIC `python3 -m pybind11 --includes` \ - py-newtonraphson.cpp -o newtonraphsonpy`python3-config --extension-suffix` + g++ -O3 -Wall -shared -std=c++14 -fPIC `python3 -m pybind11 --includes` \ + py-newtonraphson.cpp -o newtonraphsonpy`python3-config --extension-suffix` test-py: example.py newtonraphsonpy.*.so - python example.py + PYTHONPATH=${PWD} python src/py/example.py -test: test-cli test-cgi test-py +test: test-cli test-cgi test-py test-webservice clean: - $(RM) newtonraphson.exe newtonraphsonpy.*.so cgi-bin/newtonraphson + $(RM) newtonraphson.exe newtonraphsonpy.*.so cgi-bin/newtonraphson start-redis: - docker run --rm -d -p 6379:6379 --name some-redis redis + docker run --rm -d -p 6379:6379 --name some-redis redis stop-redis: - docker stop some-redis \ No newline at end of file + docker stop some-redis + +run-webapp: newtonraphsonpy.*.so + PYTHONPATH=${PWD} python src/py/webapp.py + +run-webservice: newtonraphsonpy.*.so + PYTHONPATH=${PWD} python src/py/webservice.py + +test-webservice: + curl -X POST "http://localhost:8080/api/newtonraphson" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"epsilon\":0.001,\"guess\":-20}" + +# Unable to get worker runnig correctly from Makefile, the newtonraphsonpy.*.so cannot be found +# run-celery-worker: newtonraphsonpy.*.so +# <> + +run-celery-webapp: newtonraphsonpy.*.so + PYTHONPATH=${PWD} python src/py/webapp-celery.py \ No newline at end of file diff --git a/README.md b/README.md index 7365f65..0125220 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ - [Form](#form) - [Visualization](#visualization) +![CI](https://github.com/NLESC-JCER/cpp2wasm/workflows/CI/badge.svg) + Document describing a way that a scientist with a C++ algorithm can make it available as a web application. The [Newton raphson root finding algorithm](https://en.wikipedia.org/wiki/Newton%27s_method) will be the use case. @@ -318,7 +320,7 @@ py-newtonraphson.cpp -o newtonraphsonpy`python3-config --extension-suffix` In Python it can be used: -```{.python file=example.py} +```{.python file=src/py/example.py} from newtonraphsonpy import NewtonRaphson finder = NewtonRaphson(epsilon=0.001) @@ -454,16 +456,16 @@ app = Flask(__name__) <> -app.run() +app.run(port=5001) ``` And running it with -```{.awk #py-webapp} -PYTHONPATH=$PWD python src/py/webapp.py +```{.awk #run-webapp} +PYTHONPATH=${PWD} python src/py/webapp.py ``` -To test we can visit [http://localhost:5000](http://localhost:5000) fill the form and press submit to get the result. +To test we can visit [http://localhost:5001](http://localhost:5001) fill the form and press submit to get the result. ### Long running tasks @@ -543,7 +545,7 @@ def result(jobid): Putting it all together -```{.python file=src/py/awebapp.py} +```{.python file=src/py/webapp-celery.py} from flask import Flask, render_template, request, redirect, url_for app = Flask(__name__) @@ -555,18 +557,18 @@ app = Flask(__name__) <> if __name__ == '__main__': - app.run() + app.run(port=5000) ``` Start the web application like before with -```{.awk #py-awebapp} -PYTHONPATH=$PWD python src/py/awebapp.py +```{.awk #run-celery-webapp} +PYTHONPATH=${PWD} python src/py/webapp-celery.py ``` Tasks will be run by the Celery worker. The worker can be started with -```{.awk #py-worker} +```{.awk #run-celery-worker} cd src/py PYTHONPATH=$PWD/../.. celery -A tasks worker ``` @@ -681,10 +683,15 @@ app.run(port=8080) The web service can be started with ```{.awk #run-webservice} -PYTHONPATH=$PWD python src/py/webservice.py +PYTHONPATH=${PWD} python src/py/webservice.py ``` We can try out the web service using the Swagger UI at [http://localhost:8080/ui/](http://localhost:8080/ui/). +Or by running a curl command like + +```{.awk #test-webservice} +curl -X POST "http://localhost:8080/api/newtonraphson" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"epsilon\":0.001,\"guess\":-20}" +``` ## Javascript From c03d7b9bed3fa7f139632801a70602b64f148be5 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Thu, 12 Mar 2020 17:08:29 +0100 Subject: [PATCH 07/12] Correct location example.py --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index e74e951..ec54320 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -64,7 +64,7 @@ test-cgi: cgi-bin/newtonraphson newtonraphsonpy.*.so: py-newtonraphson.cpp <> -test-py: example.py newtonraphsonpy.*.so +test-py: src/py/example.py newtonraphsonpy.*.so PYTHONPATH=${PWD} python src/py/example.py test: test-cli test-cgi test-py test-webservice From 80f95507e8eee025e259e8ba63eed80fa5d4a19f Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Thu, 12 Mar 2020 17:11:31 +0100 Subject: [PATCH 08/12] Ignore stdin for httpie --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6b493ed..4a7bb9f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -61,7 +61,7 @@ jobs: - name: Test web application run: | pip install httpie - http -hf localhost:5001 epsilon=0.001 guess=-20 + http -f --ignore-stdin localhost:5001 epsilon=0.001 guess=-20 - name: Start web service in background run: make run-webservice & @@ -83,7 +83,7 @@ jobs: - name: Test Celery web app run: | - RESULT_URL=$(http -hf localhost:5000 epsilon=0.001 guess=-20 |grep Location |awk '{print $2}') + RESULT_URL=$(http -hf --ignore-stdin localhost:5000 epsilon=0.001 guess=-20 |grep Location |awk '{print $2}') sleep 2 http $RESULT_URL From 196024a82d5545de85b4cfd6d778ad5f77a94e6c Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Thu, 12 Mar 2020 17:45:15 +0100 Subject: [PATCH 09/12] httpie not working, trying split --- .github/workflows/main.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4a7bb9f..2e0b62c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -50,7 +50,7 @@ jobs: architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified - name: Install Python dependencies - run: make py-deps + run: make py-deps && pip install httpie - name: Run Python example run: make test-py @@ -59,9 +59,7 @@ jobs: run: make run-webapp & - name: Test web application - run: | - pip install httpie - http -f --ignore-stdin localhost:5001 epsilon=0.001 guess=-20 + run: http --ignore-stdin -f localhost:5001 epsilon=0.001 guess=-20 - name: Start web service in background run: make run-webservice & @@ -83,9 +81,9 @@ jobs: - name: Test Celery web app run: | - RESULT_URL=$(http -hf --ignore-stdin localhost:5000 epsilon=0.001 guess=-20 |grep Location |awk '{print $2}') + RESULT_URL=$(http --ignore-stdin -hf localhost:5000 epsilon=0.001 guess=-20 |grep Location |awk '{print $2}') sleep 2 - http $RESULT_URL + http --ignore-stdin $RESULT_URL - name: Stop redis run: make stop-redis \ No newline at end of file From a81e3dc400ba93cf74da695a4c288eed907e965e Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Thu, 12 Mar 2020 17:55:40 +0100 Subject: [PATCH 10/12] Correct target celery web app start + Use GH actions config for redis and Docker --- .github/workflows/main.yml | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2e0b62c..cd74637 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -19,7 +19,9 @@ jobs: # Should not be needed anymore when https://github.com/NLESC-JCER/cpp2wasm/issues/1 is fixed - name: Generate source code - run: docker run --rm --user $(id -u) -v ${PWD}:/data nlesc/pandoc-tangle README.md INSTALL.md + uses: docker://nlesc/pandoc-tangle + with: + args: README.md INSTALL.md # Should not be needed anymore when https://github.com/entangled/filters/issues/2 is fixed - name: Correct Makefile @@ -30,15 +32,21 @@ jobs: python: # 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 + # Redis is needed for Celery + services: + redis: + image: redis + ports: + - 6379/tcp steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 # Should not be needed anymore when https://github.com/NLESC-JCER/cpp2wasm/issues/1 is fixed - name: Generate source code - run: docker run --rm --user $(id -u) -v ${PWD}:/data nlesc/pandoc-tangle README.md INSTALL.md + uses: docker://nlesc/pandoc-tangle + with: + args: README.md INSTALL.md # Should not be needed anymore when https://github.com/entangled/filters/issues/2 is fixed - name: Correct Makefile @@ -67,11 +75,8 @@ jobs: - name: Test web service run: make test-webservice - - name: Start redis - run: make start-redis - - name: Start Celery web app in background - run: make start-celery-webapp & + run: make run-celery-webapp & - name: Start Celery worker in background run: | @@ -84,6 +89,3 @@ jobs: RESULT_URL=$(http --ignore-stdin -hf localhost:5000 epsilon=0.001 guess=-20 |grep Location |awk '{print $2}') sleep 2 http --ignore-stdin $RESULT_URL - - - name: Stop redis - run: make stop-redis \ No newline at end of file From 01ea6a30dec1c05f2090091a2227d2eeb4c76374 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Thu, 12 Mar 2020 18:00:54 +0100 Subject: [PATCH 11/12] Split celery test --- .github/workflows/main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cd74637..4df1331 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -86,6 +86,8 @@ jobs: - name: Test Celery web app run: | - RESULT_URL=$(http --ignore-stdin -hf localhost:5000 epsilon=0.001 guess=-20 |grep Location |awk '{print $2}') + 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 From 295c0e290382cecfd7b37d5b4ac844c922e46b5b Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Thu, 12 Mar 2020 18:07:28 +0100 Subject: [PATCH 12/12] Pin redis outside port --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4df1331..1efb1a7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,7 +37,7 @@ jobs: redis: image: redis ports: - - 6379/tcp + - 6379:6379 steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2