Skip to content

Commit

Permalink
Add caching to tests (#39)
Browse files Browse the repository at this point in the history
* Avoid running the same tests twice in a PR

* Cache python venv install

* Set up cache for socrates

* Move apt install back to the top

* Fix path and cache key

* Pull to local directory

* Fix path to version file

* Trigger workflow

* Add caching for FWL_DATA directory

* Expand path
  • Loading branch information
stefsmeets authored Jul 24, 2024
1 parent f53287a commit 8bed2b6
Showing 1 changed file with 35 additions and 10 deletions.
45 changes: 35 additions & 10 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ name: Tests for JANUS

on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:

jobs:
Expand All @@ -16,38 +20,59 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Setup system
run: |
sudo apt-get install libnetcdff-dev netcdf-bin gfortran gcc
- name: Get SOCRATES
uses: actions/checkout@v4
with:
repository: 'FormingWorlds/SOCRATES'
path: 'SOCRATES'

- name: Setup system
run: |
sudo apt update
sudo apt-get install libnetcdff-dev netcdf-bin gfortran gcc
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- uses: actions/cache@v3
id: cache-socrates
with:
python-version: ${{ matrix.python-version }}
path: |
SOCRATES/bin
SOCRATES/sbin
SOCRATES/set_rad_env
key: socrates-${{ hashFiles('SOCRATES/version') }}

- name: Build SOCRATES
if: steps.cache-socrates.outputs.cache-hit != 'true'
run: |
export LD_LIBRARY_PATH=""
cd SOCRATES
./configure
./build_code
source set_rad_env
cd ..
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- uses: actions/cache@v3
id: cache-virtualenv
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}

- name: Build JANUS
if: steps.cache-virtualenv.outputs.cache-hit != 'true'
run: |
python -m pip install -e .[develop]
- uses: actions/cache@v3
id: cache-fwl-data
with:
path: /home/runner/work/fwl_data
key: fwl-data-1

- name: Test with pytest
run: |
export FWL_DATA="./fwl_data"
export FWL_DATA="/home/runner/work/fwl_data"
source SOCRATES/set_rad_env
coverage run -m pytest
Expand Down

0 comments on commit 8bed2b6

Please sign in to comment.