From 80f129d78500abcc8b527835d657d1ff6232634b Mon Sep 17 00:00:00 2001 From: samypr100 <3933065+samypr100@users.noreply.github.com> Date: Sun, 4 Aug 2024 00:48:39 -0400 Subject: [PATCH 1/6] docs: add warning note on self-hosted github runners --- docs/guides/integration/github.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/guides/integration/github.md b/docs/guides/integration/github.md index f6eb44540ab5..62f0fb7628f9 100644 --- a/docs/guides/integration/github.md +++ b/docs/guides/integration/github.md @@ -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. +!!! warning + + [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 location can grow over time, + becoming problematic. In such cases its possible to set the caching location relative to the + GitHub Workspace and clean 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 + # ... restore uv cache ... + ``` + + 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 + #!/usr/bin/env sh + rm -rf $GITHUB_WORKSPACE/* + ``` + ## Using `uv pip` If using the `uv pip` interface instead of the uv project interface, uv requires a virtual From 9f2a892103acb8e67a21a9983ea89552465406f3 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Mon, 16 Sep 2024 23:09:36 -0500 Subject: [PATCH 2/6] Update docs/guides/integration/github.md --- docs/guides/integration/github.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guides/integration/github.md b/docs/guides/integration/github.md index 62f0fb7628f9..fef2729da85e 100644 --- a/docs/guides/integration/github.md +++ b/docs/guides/integration/github.md @@ -286,7 +286,7 @@ Its effect on performance is dependent on the packages being installed. 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 + ```sh title="clean-workspace.sh" #!/usr/bin/env sh rm -rf $GITHUB_WORKSPACE/* ``` From 7367de23c902c383df8f8db448d25a150afb0f39 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Mon, 16 Sep 2024 23:12:53 -0500 Subject: [PATCH 3/6] Update docs/guides/integration/github.md --- docs/guides/integration/github.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guides/integration/github.md b/docs/guides/integration/github.md index fef2729da85e..a99952791f82 100644 --- a/docs/guides/integration/github.md +++ b/docs/guides/integration/github.md @@ -271,8 +271,8 @@ Its effect on performance is dependent on the packages being installed. [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 location can grow over time, - becoming problematic. In such cases its possible to set the caching location relative to the + When using non-ephemeral self-hosted runners and the default cache directory, the cache can grow over time + and become problematic. In such cases, it's recommend to move the cache to inside the GitHub Workspace and clean it once the job finishes using a [Post Job Hook][post-job-hook]. ```yaml From 87e51ac7368929adc244e0aa86121432bbab93e1 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Mon, 16 Sep 2024 23:13:34 -0500 Subject: [PATCH 4/6] Format --- docs/guides/integration/github.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guides/integration/github.md b/docs/guides/integration/github.md index a99952791f82..b0fa1e2edeaf 100644 --- a/docs/guides/integration/github.md +++ b/docs/guides/integration/github.md @@ -271,8 +271,8 @@ Its effect on performance is dependent on the packages being installed. [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 and the default cache directory, the cache can grow over time - and become problematic. In such cases, it's recommend to move the cache to inside the + When using non-ephemeral self-hosted runners and the default cache directory, the cache can grow + over time and become problematic. In such cases, it's recommend to move the cache to inside the GitHub Workspace and clean it once the job finishes using a [Post Job Hook][post-job-hook]. ```yaml From c8fc944b6d3afcbdecf439e595fd28bf6069200c Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Tue, 17 Sep 2024 11:31:56 -0500 Subject: [PATCH 5/6] Update docs/guides/integration/github.md --- docs/guides/integration/github.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/guides/integration/github.md b/docs/guides/integration/github.md index b0fa1e2edeaf..48e28bd30c65 100644 --- a/docs/guides/integration/github.md +++ b/docs/guides/integration/github.md @@ -280,7 +280,6 @@ Its effect on performance is dependent on the packages being installed. env: # Configure a relative location for the uv cache UV_CACHE_DIR: ${{ github.workspace }}/.cache/uv - # ... restore uv cache ... ``` Using a post job hook requires setting the `ACTIONS_RUNNER_HOOK_JOB_STARTED` environment From b235bec72d3162844a4d343547552c4b28ee5aa7 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Wed, 18 Sep 2024 08:32:43 -0500 Subject: [PATCH 6/6] Additional touchups --- docs/guides/integration/github.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/guides/integration/github.md b/docs/guides/integration/github.md index 48e28bd30c65..e8cccf064b1a 100644 --- a/docs/guides/integration/github.md +++ b/docs/guides/integration/github.md @@ -267,13 +267,14 @@ 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. -!!! warning +!!! 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 and the default cache directory, the cache can grow - over time and become problematic. In such cases, it's recommend to move the cache to inside the - GitHub Workspace and clean it once the job finishes using a [Post Job Hook][post-job-hook]. + 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: @@ -285,9 +286,9 @@ Its effect on performance is dependent on the packages being installed. 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-workspace.sh" + ```sh title="clean-uv-cache.sh" #!/usr/bin/env sh - rm -rf $GITHUB_WORKSPACE/* + uv cache clean ``` ## Using `uv pip`