Skip to content

Commit

Permalink
Refine cache key to include specific Python patch version (#1588)
Browse files Browse the repository at this point in the history
  • Loading branch information
rsmb7z authored Apr 11, 2024
1 parent 04e294d commit 73a9245
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Get Python version
run: |
version=$(python -c "import sys; print('.'.join(map(str, sys.version_info[:3])))")
echo "PYTHON_VERSION=$version" >> $GITHUB_ENV
- name: Get Poetry version from poetry-version
run: |
version=$(cat poetry-version)
Expand All @@ -83,7 +88,7 @@ jobs:
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-${{ matrix.python-version }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
key: ${{ runner.os }}-${{ env.PYTHON_VERSION }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}

- name: Set poetry cache-dir
run: echo "POETRY_CACHE_DIR=$(poetry config cache-dir)" >> $GITHUB_ENV
Expand All @@ -93,7 +98,7 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ env.POETRY_CACHE_DIR }}
key: ${{ runner.os }}-${{ matrix.python-version }}-poetry-${{ hashFiles('**/poetry.lock') }}
key: ${{ runner.os }}-${{ env.PYTHON_VERSION }}-poetry-${{ hashFiles('**/poetry.lock') }}

- name: Run pre-commit
run: |
Expand Down Expand Up @@ -240,6 +245,11 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Get Python version
run: |
version=$(python -c "import sys; print('.'.join(map(str, sys.version_info[:3])))")
echo "PYTHON_VERSION=$version" >> $GITHUB_ENV
- name: Get Poetry version from poetry-version
run: |
version=$(cat poetry-version)
Expand All @@ -258,7 +268,7 @@ jobs:
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-${{ matrix.python-version }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
key: ${{ runner.os }}-${{ env.PYTHON_VERSION }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}

- name: Set poetry cache-dir
run: echo "POETRY_CACHE_DIR=$(poetry config cache-dir)" >> $GITHUB_ENV
Expand All @@ -268,7 +278,7 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ env.POETRY_CACHE_DIR }}
key: ${{ runner.os }}-${{ matrix.python-version }}-poetry-${{ hashFiles('**/poetry.lock') }}
key: ${{ runner.os }}-${{ env.PYTHON_VERSION }}-poetry-${{ hashFiles('**/poetry.lock') }}

- name: Run pre-commit
run: |
Expand Down

0 comments on commit 73a9245

Please sign in to comment.