Skip to content

Commit

Permalink
CI: Cache virtual environments
Browse files Browse the repository at this point in the history
  • Loading branch information
kurtmckee committed Jul 25, 2023
1 parent 965c86a commit 1086eee
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
uses: "actions/checkout@v3"

- name: "Set up Python"
id: "setup-python"
uses: "actions/setup-python@v4"
with:
# The last listed Python version is the default.
Expand All @@ -47,13 +48,26 @@ jobs:
3.9
3.10
3.11
cache: pip
cache-dependency-path: 'requirements/*.txt'
- name: "Restore cache"
id: "restore-cache"
uses: "actions/cache@v3"
with:
path: |
.tox/
.venv/
key: "cache-python-${{ steps.setup-python.outputs.python-version }}-os-${{ runner.os }}-hash-${{ hashFiles('tox.ini', 'requirements/*.txt') }}"

- name: "Identify venv path"
shell: "bash"
run: "echo 'venv-path=${{ runner.os == 'Windows' && '.venv/Scripts' || '.venv/bin' }}' >> $GITHUB_ENV"

- name: "Install dependencies"
if: "steps.restore-cache.outputs.cache-hit == false"
run: |
python -m pip install -U setuptools
python -m pip install -r requirements/tox.txt
python -m venv .venv
${{ env.venv-path }}/python -m pip install -U setuptools
${{ env.venv-path }}/python -m pip install -r requirements/tox.txt
- name: "Install pandoc on Linux"
# sudo apt-get pandoc: will install a version from 2018!
Expand All @@ -74,7 +88,7 @@ jobs:
- name: "Run tox"
run: |
python -m tox -m ci-tests
${{ env.venv-path }}/python -m tox -m ci-tests
- name: "Upload coverage data"
uses: actions/upload-artifact@v3
Expand Down

0 comments on commit 1086eee

Please sign in to comment.