Skip to content

Prune uv's CI cache #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased](https://github.com/hynek/build-and-inspect-python-package/compare/v2.7.0...main)

### Changed

- Use *uv*'s new `uv cache prune --ci` to only cache downloaded files.
This makes the cache smaller and faster to pack/unpack.
[#135](https://github.com/hynek/build-and-inspect-python-package/pull/135)


### Fixed

- Turns out, the default location of *uv*'s cache cannot be cached and [*actions/cache*](https://github.com/actions/cache) fails silently with an opaque "Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved." log message.
We have moved the cache to `/tmp`.
[#135](https://github.com/hynek/build-and-inspect-python-package/pull/135)


## [2.7.0](https://github.com/hynek/build-and-inspect-python-package/compare/v2.6.0...v2.7.0) - 2024-07-17

Expand Down
16 changes: 10 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@ runs:
run: curl -LsSf https://astral.sh/uv/install.sh | sh
shell: bash

- name: Find uv cache and hash lock file
- name: Set uv cache and hash lock file
run: |
echo "UV_CACHE=$(uv cache dir)" >>$GITHUB_ENV
echo "UV_CACHE_DIR=/tmp/baipp-uv_cache_dir" >>$GITHUB_ENV

echo "REQS_HASH=$(sha256sum ${{ github.action_path }}/requirements/tools.txt | cut -d' ' -f1)" >>$GITHUB_ENV
shell: bash

- name: Cache uv
- name: Setup uv cache
uses: actions/cache@v4
with:
path: ${{ env.UV_CACHE }}
path: ${{ env.UV_CACHE_DIR }}
key: baipp-${{ env.REQS_HASH }}

- name: Create venv for tools
Expand Down Expand Up @@ -107,13 +107,17 @@ runs:
export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct)

if [[ "${{ inputs.skip-wheel }}" == "true" ]]; then
/tmp/baipp/bin/python -m build --installer=uv --sdist --outdir /tmp/baipp/dist
/tmp/baipp/bin/python -Im build --installer=uv --sdist --outdir /tmp/baipp/dist
else
/tmp/baipp/bin/python -m build --installer=uv --outdir /tmp/baipp/dist
/tmp/baipp/bin/python -Im build --installer=uv --outdir /tmp/baipp/dist
fi
shell: bash
working-directory: ${{ inputs.path }}

- name: Optimize uv cache for CI
run: uv cache prune --ci
shell: bash

- name: Attest GitHub build provenance
if: ${{ inputs.attest-build-provenance-github == 'true' }}
uses: actions/attest-build-provenance@v1
Expand Down