update github workflow #296
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 venv or cache it (note: trailing "-" in restore-keys means: match anything after it. Also, cached version is stored in GiHub storage, not on the testing VM) | |
| - name: Restore cached virtualenv (if any) | |
| uses: actions/cache@v3 | |
| with: | |
| path: venv | |
| key: ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ env.OPENQUAKE_VERSION }} | |
| restore-keys: ${{ runner.os }}-venv-${{ matrix.python-version }}- | |
| # Create and activate virtual environment | |
| - name: Create virtualenv if needed | |
| run: if [ -d venv ]; then echo "Using cached venv"; else python -m venv venv; source venv/bin/activate; python -m pip install --upgrade pip setuptools wheel; fi | |
| # 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 | |
| run: | | |
| source venv/bin/activate | |
| if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
| pip install -e . | |
| - name: Test eGSIM (smtk lib) | |
| run: | | |
| source venv/bin/activate | |
| pytest --ignore=./tests/tmp/ -xvvv ./tests/smtk | |
| # 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 |