Skip to content

Commit ea20997

Browse files
committed
web workflow
1 parent ed7c154 commit ea20997

2 files changed

Lines changed: 91 additions & 0 deletions

File tree

.github/workflows/pytest-web.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Test eGSIM web app (kinda deployement)
2+
3+
on:
4+
push:
5+
branches: [ main, master, dev ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
jobs:
10+
run-tests:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
python-version: [ "3.11" ] # add more if needed (the server version should be sufficient)
16+
17+
env:
18+
OQ_VERSION: "3.24.1"
19+
SETTINGS_MODULE: "egsim.settings.test"
20+
REQUIREMENTS_FILE: "requirements-py311-linux64.txt"
21+
22+
steps:
23+
# Checkout repository
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
- name: Install system packages
28+
run: |
29+
sudo apt-get update
30+
sudo apt-get install -y \
31+
build-essential \
32+
gfortran \
33+
libopenblas-dev \
34+
liblapack-dev \
35+
cmake \
36+
pkg-config \
37+
proj-bin \
38+
proj-data \
39+
libproj-dev
40+
41+
# Set up Python
42+
- name: Set up Python ${{ matrix.python-version }}
43+
uses: actions/setup-python@v5
44+
with:
45+
python-version: ${{ matrix.python-version }}
46+
47+
# Create and activate virtual environment
48+
- name: Create virtualenv
49+
run: |
50+
python -m venv venv
51+
source venv/bin/activate
52+
python -m pip install --upgrade pip setuptools wheel
53+
54+
# Download openquake.engine source distribution and install editable
55+
- name: Install openquake.engine (editable)
56+
run: |
57+
source venv/bin/activate
58+
mkdir -p /tmp/openquake
59+
(cd /tmp/openquake && git clone --branch v${OQ_VERSION} https://github.com/gem/oq-engine.git .)
60+
pip install -r "/tmp/openquake/${REQUIREMENTS_FILE}"
61+
pip install -U -e ".[web]" # upgrade all packages to most recent ones
62+
# pip freeze > ./${REQUIREMENTS_FILE} # in case one wants to freeze dependencies locally
63+
64+
# Run Django migrations and pytest
65+
- name: Test eGSIM (web app)
66+
run: |
67+
source venv/bin/activate
68+
export DJANGO_SETTINGS_MODULE=${SETTINGS_MODULE}
69+
# python manage.py migrate
70+
# python manage.py egsim-init --no-input
71+
pytest --ignore=./tests/tmp/ -xvvv ./tests
72+
73+
Show pip freeze in log, save requirements-web.txt, and upload artifact
74+
75+
- name: Show pip freeze in workflow log
76+
run: |
77+
source venv/bin/activate
78+
pip freeze
79+
80+
- name: Generate requirements-web.txt
81+
run: |
82+
source venv/bin/activate
83+
pip freeze > requirements-web.txt
84+
85+
- name: Upload requirements-web.txt artifact
86+
# GitHub repo -> Actions -> Workflow Run -> Scroll to Section "Artifacts" -> Download requirements-web.txt
87+
uses: actions/upload-artifact@v4
88+
with:
89+
name: requirements-web
90+
path: requirements-web.txt

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
'Django>=4.1.2',
3737
'plotly>=5.10.0',
3838
'kaleido>=0.2.1', # required by plotly to save images
39+
'gunicorn>=21.2.0', # production server (not necessary local browser testing, but harmless)
3940
# test packages:
4041
'pytest',
4142
'pytest-django>=3.4.8',

0 commit comments

Comments
 (0)