diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index af1b19a..4972e26 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -2,7 +2,11 @@ name: Tests for JANUS on: push: + branches: + - master pull_request: + branches: + - master workflow_dispatch: jobs: @@ -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