Skip to content

Commit

Permalink
Pre-cache python environment before test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
pvandyken committed Sep 21, 2023
1 parent ca91c96 commit a74133c
Showing 1 changed file with 48 additions and 2 deletions.
50 changes: 48 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,53 @@ jobs:
- name: ruff
run: poetry run ruff snakebids

test:
build-cache-env:
runs-on: ubuntu-latest
needs: [ 'quality' ]
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}
${{ runner.os }}-pip-
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}-${{ matrix.python-version }}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --no-ansi

test:
runs-on: ubuntu-latest
needs: [ 'build-cache-env' ]
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
Expand All @@ -91,7 +135,9 @@ jobs:
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ matrix.python-version }}
restore-keys: ${{ runner.os }}-pip-${{ matrix.python-version }}
restore-keys: |
${{ runner.os }}-pip-${{ matrix.python-version }}
${{ runner.os }}-pip-
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
Expand Down

0 comments on commit a74133c

Please sign in to comment.