Skip to content
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

Add note on cache growth for self-hosted GitHub runners #5757

Merged
merged 6 commits into from
Sep 18, 2024
Merged
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
24 changes: 24 additions & 0 deletions docs/guides/integration/github.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,30 @@ Its effect on performance is dependent on the packages being installed.

If using `uv pip`, use `requirements.txt` instead of `uv.lock` in the cache key.

!!! note

[post-job-hook]: https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/running-scripts-before-or-after-a-job

When using non-ephemeral, self-hosted runners the default cache directory can grow unbounded.
In this case, it may not be optimal to share the cache between jobs. Instead, move the cache
inside the GitHub Workspace and remove it once the job finishes using a
[Post Job Hook][post-job-hook].

```yaml
install_job:
env:
# Configure a relative location for the uv cache
UV_CACHE_DIR: ${{ github.workspace }}/.cache/uv
```

Using a post job hook requires setting the `ACTIONS_RUNNER_HOOK_JOB_STARTED` environment
variable on the self-hosted runner to the path of a cleanup script such as the one shown below.

```sh title="clean-uv-cache.sh"
#!/usr/bin/env sh
uv cache clean
Copy link
Collaborator Author

@samypr100 samypr100 Sep 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zanieb I noticed this was changed 😅 This happens at the runner level and not at the job level, so uv will not be at the path (unless installed globally and not via setup-uv) nor the job env vars 😁
Hence why it was rm -rf $GITHUB_WORKSPACE/* before

```

## Using `uv pip`

If using the `uv pip` interface instead of the uv project interface, uv requires a virtual
Expand Down
Loading