Skip to content

git workflow WIP

git workflow WIP #289

Workflow file for this run

name: python=3.11
on:
push:
branches: [ main, master, dev ]
pull_request:
branches: [ main, master ]
jobs:
run-tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.11" ] # add more if needed
env:
OPENQUAKE_VERSION: "3.15.0"
SETTINGS_MODULE: "egsim.settings_debug"
steps:
# Checkout repository
- name: Checkout repository
uses: actions/checkout@v4
- name: Install system packages
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential \
gfortran \
libopenblas-dev \
liblapack-dev \
cmake \
pkg-config \
proj-bin \
proj-data \
libproj-dev
# Set up Python
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# Cache pip downloads and built wheels to avoid rebuilding heavy packages
# like numpy, scipy, h5py, pyproj, and openquake.engine on every CI run
- name: Cache pip wheels
uses: actions/cache@v3
with:
# Default pip cache directory on Linux runners
path: ~/.cache/pip
# Cache key changes when:
# - OS changes
# - Python version changes
# - dependencies change
key: >
${{ runner.os }}-pip-
${{ matrix.python-version }}-
${{ hashFiles('requirements.txt') }}
# Fallback cache if exact key is not found
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}-
${{ runner.os }}-pip-
# Create and activate virtual environment
- name: Create virtualenv
run: |
python -m venv venv
source venv/bin/activate
python -m pip install --upgrade pip setuptools wheel
# Download openquake.engine source distribution and install editable
- name: Install openquake.engine (editable)
run: |
source venv/bin/activate
mkdir -p /tmp/openquake
cd /tmp/openquake
# Force source distribution download
pip download --no-binary :all: openquake.engine==${OPENQUAKE_VERSION}
# Extract the tar.gz (sdist)
tar -xvf openquake.engine-${OPENQUAKE_VERSION}.tar.gz
cd openquake.engine-${OPENQUAKE_VERSION}
pip install -e .
# Install project dependencies
- name: Install project
run: |
source venv/bin/activate
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install -e .
- name: Test lib (smtk)
run: |
source venv/bin/activate
pytest --ignore=./tests/tmp/ -xvvv ./tests/smtk
# Run Django migrations and pytest
- name: Test web app
run: |
source venv/bin/activate
export DJANGO_SETTINGS_MODULE=${SETTINGS_MODULE}
python manage.py migrate
pytest --ignore=./tests/tmp/ -xvvv ./tests/django