Skip to content

Commit

Permalink
Prune uv's CI cache (#135)
Browse files Browse the repository at this point in the history
* Prune uv's CI cache

Just keep the downloaded packages to make cache operations faster.

* Be explicit about saving/restoring

* Please don't tell me cache won't allow to cache uv

* Try moving uv cache dir elsewhere

* jfc

* Remove debug

* Add changelog
  • Loading branch information
hynek committed Jul 25, 2024
1 parent e2e1d19 commit 0b18de8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
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

0 comments on commit 0b18de8

Please sign in to comment.