Skip to content

Commit

Permalink
Unify cache location across OS
Browse files Browse the repository at this point in the history
Pip, poetry and pre-commit defaulted to OS-specific cache and venv dirs. This made the caching system less useful on macOS and Windows.

Now, all is stored under $PWD/.venv and cached from there. This works fine across different OS. Also, the OS is added to the cache key.
  • Loading branch information
Jairo Llopis committed Aug 7, 2020
1 parent d7a0d05 commit 8614a44
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
28 changes: 15 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
env:
LANG: "en_US.utf-8"
LC_ALL: "en_US.utf-8"
PIP_CACHE_DIR: ${{ github.workspace }}/.cache/pip
POETRY_CACHE_DIR: ${{ github.workspace }}/.cache/pypoetry
POETRY_VIRTUALENVS_IN_PROJECT: "true"
PRE_COMMIT_HOME: ${{ github.workspace }}/.cache/pre-commit
PYTHONIOENCODING: "UTF-8"

jobs:
Expand Down Expand Up @@ -41,17 +45,13 @@ jobs:
run:
echo "::set-env name=PY::$((python -VV; pip freeze) | sha256sum | cut -d' '
-f1)"
- uses: actions/cache@v1
- uses: actions/cache@v2.1.0
with:
path: ~/.cache
path: |
.cache
.venv
key:
cache-${{ env.PY }}|${{ hashFiles('pyproject.toml') }}|${{
hashFiles('poetry.lock') }}|${{ hashFiles('.pre-commit-config.yaml') }}
- uses: actions/cache@v1
with:
path: ~/.local
key:
local-${{ env.PY }}|${{ hashFiles('pyproject.toml') }}|${{
cache|${{ runner.os }}|${{ env.PY }}|${{ hashFiles('pyproject.toml') }}|${{
hashFiles('poetry.lock') }}|${{ hashFiles('.pre-commit-config.yaml') }}
- run: python -m pip install poetry poetry-dynamic-versioning
shell: bash
Expand All @@ -61,7 +61,7 @@ jobs:
shell: bash
run: poetry run pre-commit run --all-files --color=always
# FIXME Make pre-commit pass reliably on Windows, and remove this
continue-on-error: ${{ matrix.os == 'windows-latest' }}
continue-on-error: ${{ runner.os == 'Windows' }}
- name: Run mypy
shell: bash
run: poetry run mypy --ignore-missing-imports .
Expand All @@ -84,11 +84,13 @@ jobs:
run:
echo "::set-env name=PY::$((python -VV; pip freeze) | sha256sum | cut -d' '
-f1)"
- uses: actions/cache@v1
- uses: actions/cache@v2.1.0
with:
path: ~/.cache
path: |
.cache
.venv
key:
${{ env.PY }}|${{ hashFiles('pyproject.toml') }}|${{
cache|${{ runner.os }}|${{ env.PY }}|${{ hashFiles('pyproject.toml') }}|${{
hashFiles('poetry.lock') }}|${{ hashFiles('.pre-commit-config.yaml') }}
- run: poetry install
- name: Build dist
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ jobs:
run:
echo "::set-env name=PY::$((python -VV; pip freeze) | sha256sum | cut -d' '
-f1)"
- uses: actions/cache@v1
- uses: actions/cache@v2.1.0
with:
path: ~/.cache
path: |
.cache
.venv
key:
${{ env.PY }}|${{ hashFiles('pyproject.toml') }}|${{
cache|${{ runner.os }}|${{ env.PY }}|${{ hashFiles('pyproject.toml') }}|${{
hashFiles('poetry.lock') }}|${{ hashFiles('.pre-commit-config.yaml') }}
- run: git config --global user.name copier-ci
- run: git config --global user.email copier@copier
Expand Down

0 comments on commit 8614a44

Please sign in to comment.