Skip to content

Commit

Permalink
ci(macos): fix caching for faster builds (#1390)
Browse files Browse the repository at this point in the history
Previous approach was broken on macOS due to missing sha256sum command.
This adopts the same cache-key approach as is used in Poetry pipelines.

Closes #1389
  • Loading branch information
kenibrewer authored Nov 4, 2023
1 parent 99bdd11 commit 6e8f985
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,21 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: generate cache key PY
shell: bash
- name: Get full Python version
id: full-python-version
shell: bash # Required for use of $GITHUB_OUTPUT in windows
run:
echo "PY=$((python -VV; pip freeze) | sha256sum | cut -d' ' -f1)" >>
$GITHUB_ENV
echo version=$(python -c "import sys; print('-'.join(str(v) for v in
sys.version_info))") >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: |
.cache
.venv
key:
cache|${{ runner.os }}|${{ env.PY }}|${{ hashFiles('pyproject.toml') }}|${{
hashFiles('poetry.lock') }}|${{ hashFiles('.pre-commit-config.yaml') }}
cache|${{ runner.os }}|${{ steps.full-python-version.outputs.version }}|${{
hashFiles('pyproject.toml') }}|${{ hashFiles('poetry.lock') }}|${{
hashFiles('.pre-commit-config.yaml') }}
- name: Install dependencies
run: |
python -m pip install poetry poetry-dynamic-versioning
Expand Down Expand Up @@ -139,18 +141,20 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: generate cache key PY
- name: Get full Python version
id: full-python-version
run:
echo "PY=$((python -VV; pip freeze) | sha256sum | cut -d' ' -f1)" >>
$GITHUB_ENV
echo version=$(python -c "import sys; print('-'.join(str(v) for v in
sys.version_info))") >> $GITHUB_OUTPUT
- uses: actions/cache@v3
with:
path: |
.cache
.venv
key:
cache|${{ runner.os }}|${{ env.PY }}|${{ hashFiles('pyproject.toml') }}|${{
hashFiles('poetry.lock') }}|${{ hashFiles('.pre-commit-config.yaml') }}
cache|${{ runner.os }}|${{ steps.full-python-version.outputs.version }}|${{
hashFiles('pyproject.toml') }}|${{ hashFiles('poetry.lock') }}|${{
hashFiles('.pre-commit-config.yaml') }}
- name: Install dependencies
shell: bash
run: |
Expand Down

0 comments on commit 6e8f985

Please sign in to comment.