Skip to content

Commit

Permalink
fix cache key
Browse files Browse the repository at this point in the history
  • Loading branch information
edenhaus committed Jan 24, 2025
1 parent 7c9622e commit cbb4967
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ jobs:
info:
name: Collect information & changes data
outputs:
venv_cache_key_partly: ${{ steps.info.outputs.venv_key_partly }}
default_python_version: ${{ steps.info.outputs.default_python_version }}
python_versions: ${{ steps.info.outputs.python_versions }}
venv_cache_key_partly: ${{ steps.info.outputs.venv_key_partly }}
runs-on: ubuntu-latest
steps:
- name: ⤵️ Check out code from GitHub
Expand All @@ -28,6 +29,14 @@ jobs:
venv_key_partly=venv-${{ runner.os }}-${{hashFiles('uv.lock', 'pyproject.toml', 'Cargo.lock', 'Cargo.toml') }}
echo "venv cache key partly : ${venv_key_partly}"
echo "venv_key_partly=${venv_key_partly}" >> $GITHUB_OUTPUT
default_python_version=$(cat .python-version)
echo "default python version: ${default_python_version}"
echo "default_python_version=${default_python_version}" >> $GITHUB_OUTPUT
# Check if ALL_PYTHON_VERSIONS contains default_python_version. If not add it
if [[ ! ${ALL_PYTHON_VERSIONS} == *"${default_python_version}"* ]]; then
ALL_PYTHON_VERSIONS="[${ALL_PYTHON_VERSIONS:1:-1}, '${default_python_version}']"
fi
echo "python_versions: ${ALL_PYTHON_VERSIONS}"
echo "python_versions=${ALL_PYTHON_VERSIONS}" >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -67,17 +76,17 @@ jobs:
steps:
- name: ⤵️ Checkout repository
uses: actions/checkout@v4
- name: 🏗 Set up uv and Python
- name: 🏗 Set up uv and Python ${{ needs.info.outputs.default_python_version }}
uses: astral-sh/setup-uv@v5
with:
python-version-file: ".python-version"
- name: 🏗 Restore full Python virtual environment
python-version: ${{ needs.info.outputs.default_python_version }}
- name: 🏗 Restore full Python ${{ needs.info.outputs.default_python_version }} virtual environment
id: cache-venv
uses: actions/cache/[email protected]
with:
path: .venv
fail-on-cache-miss: true
key: ${{ matrix.python-version }}-${{ needs.info.outputs.venv_cache_key_partly }}
key: ${{ needs.info.outputs.default_python_version }}-${{ needs.info.outputs.venv_cache_key_partly }}

# Following steps cannot run by pre-commit.ci as repo = local
- name: Run mypy
Expand Down Expand Up @@ -151,18 +160,18 @@ jobs:
- name: 🏗 Install uv
uses: astral-sh/setup-uv@v5

- name: 🏗 Setup Python
- name: 🏗 Setup Python ${{ needs.info.outputs.default_python_version }}
uses: actions/setup-python@v5
with:
python-version-file: ".python-version"
python-version: ${{ needs.info.outputs.default_python_version }}

- name: 🏗 Restore full Python virtual environment
id: cache-venv
uses: actions/cache/[email protected]
with:
path: .venv
fail-on-cache-miss: true
key: ${{ matrix.python-version }}-${{ needs.info.outputs.venv_cache_key_partly }}
key: ${{ needs.info.outputs.default_python_version }}-${{ needs.info.outputs.venv_cache_key_partly }}

- name: Run benchmarks
uses: CodSpeedHQ/action@main
Expand Down

0 comments on commit cbb4967

Please sign in to comment.