From bc9d07a36a256ae8be8f25a344860cdda4d822b3 Mon Sep 17 00:00:00 2001 From: Kevin Stillhammer Date: Mon, 16 Sep 2024 15:21:15 +0200 Subject: [PATCH] Make cache behavior on self hosted runners clearer The uv cache on the filesystem can be uploaded to the GitHub Actions cache, but they are distinct things. Also make it clear that the local cache path can be changed without using `enable-cache: true` --- README.md | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 04105a4..1380415 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,8 @@ Set up your GitHub Actions workflow with a specific version of [uv](https://docs - [Install a specific version](#install-a-specific-version) - [Validate checksum](#validate-checksum) - [Enable Caching](#enable-caching) - - [Local cache path](#local-cache-path) - [Cache dependency glob](#cache-dependency-glob) + - [Local cache path](#local-cache-path) - [GitHub authentication token](#github-authentication-token) - [How it works](#how-it-works) - [FAQ](#faq) @@ -67,8 +67,13 @@ are automatically verified by this action. The sha265 hashes can be found on the ### Enable caching If you enable caching, the [uv cache](https://docs.astral.sh/uv/concepts/cache/) will be cached to -the GitHub Actions Cache. This can speed up runs that reuse the cache by several minutes. The cache -will always be reused on self-hosted runners. +the GitHub Actions Cache. This can speed up runs that reuse the cache by several minutes. + +> [!TIP] +> +> On self-hosted runners this is usually not needed since the cache generated by `uv` +> on the runner's filesystem is not removed after a run. +> For more details see [Local cache path](#local-cache-path). You can optionally define a custom cache key suffix. @@ -90,19 +95,6 @@ use it in subsequent steps. For example, to use the cache in the above case: run: echo "Cache was restored" ``` -#### Local cache path - -If you want to save the cache to a local path other than the default path (`/tmp/setup-uv-cache`), -specify the path with the `cache-local-path` input. - -```yaml -- name: Define a custom uv cache path - uses: astral-sh/setup-uv@v2 - with: - enable-cache: true - cache-local-path: "/path/to/cache" -``` - #### Cache dependency glob If you want to control when the cache is invalidated, specify a glob pattern with the @@ -135,6 +127,19 @@ changes. The glob matches files relative to the repository root. **pyproject.toml ``` +### Local cache path + +This action controls where `uv` stores its cache on the runner's filesystem. +You can change the default (`/tmp/setup-uv-cache`) by +specifying the path with the `cache-local-path` input. + +```yaml +- name: Define a custom uv cache path + uses: astral-sh/setup-uv@v2 + with: + cache-local-path: "/path/to/cache" +``` + ### GitHub authentication token This action uses the GitHub API to fetch the `uv` release artifacts. To avoid hitting the GitHub API