improve github workflow #298
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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.test" | |
| 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 }} | |
| # Restore pip cache | |
| - name: Restore pip cache, if any | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ matrix.python-version }} | |
| # 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 eGSIM smtk lib | |
| run: | | |
| source venv/bin/activate | |
| if [ -f requirements.lib.txt ]; then pip install -r requirements.lib.txt; fi | |
| pip install . | |
| - name: Test eGSIM (smtk lib) | |
| run: | | |
| source venv/bin/activate | |
| pytest --ignore=./tests/tmp/ -xvvv ./tests/smtk | |
| # Install project dependencies | |
| - name: Install eGSIM web app dependencies | |
| run: | | |
| source venv/bin/activate | |
| if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
| pip install -e ".[web]" | |
| # Run Django migrations and pytest | |
| - name: Test eGSIM (web app) | |
| run: | | |
| source venv/bin/activate | |
| export DJANGO_SETTINGS_MODULE=${SETTINGS_MODULE} | |
| # python manage.py migrate | |
| # python manage.py egsim-init --no-input | |
| pytest --ignore=./tests/tmp/ -xvvv ./tests/django |