Skip to content
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
17 changes: 17 additions & 0 deletions .github/actions/save_cargo_cache/action.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
name: "save_cargo_cache"

# Every step is gated on runner type, mirroring restore_npm_cache /
# restore_cargo_cache which already skip on self-hosted. Our self-hosted runners
# are persistent (one long-lived VM taking job after job), so the cached
# directories under $HOME survive between jobs and the upload is WAN traffic for
# nothing. It is also not merely wasteful: the cleanup step below deletes every
# key but the newest, so a cache saved on self-hosted hardware displaces the
# ones the GitHub-hosted runners restore from.

inputs:
save-on-self-hosted:
description: "Whether to save the cargo cache to the GitHub cache backend on self-hosted runners"
required: false
default: "false"

runs:
using: "composite"
steps:

# dirs must exist before cache restore
- name: Make dirs
if: ${{ runner.environment != 'self-hosted' || inputs.save-on-self-hosted == 'true' }}
shell: bash
run: |
mkdir -p ~/.cargo
Expand All @@ -14,6 +29,7 @@ runs:
mkdir -p target

- name: Save cargo cache
if: ${{ runner.environment != 'self-hosted' || inputs.save-on-self-hosted == 'true' }}
uses: actions/cache/save@v4
with:
path: |
Expand All @@ -25,6 +41,7 @@ runs:
key: cargo-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }}-${{ github.run_attempt }}

- name: Cleanup cargo caches
if: ${{ runner.environment != 'self-hosted' || inputs.save-on-self-hosted == 'true' }}
shell: bash
run: |
# remove all but the latest cache, leaving only the cache we just saved
Expand Down
18 changes: 18 additions & 0 deletions .github/actions/save_npm_cache/action.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
name: "save_npm_cache"

# Every step is gated on runner type, mirroring restore_npm_cache /
# restore_cargo_cache which already skip on self-hosted. Our self-hosted runners
# are persistent (one long-lived VM taking job after job), so the cached
# directories under $HOME survive between jobs and the upload is WAN traffic for
# nothing. It is also not merely wasteful: the cleanup step below deletes every
# key but the newest, so a cache saved on self-hosted hardware displaces the
# ones the GitHub-hosted runners restore from.

inputs:
save-on-self-hosted:
description: "Whether to save the npm cache to the GitHub cache backend on self-hosted runners"
required: false
default: "false"

runs:
using: "composite"
steps:

# dirs must exist before cache restore
- name: Make dirs
if: ${{ runner.environment != 'self-hosted' || inputs.save-on-self-hosted == 'true' }}
shell: bash
run: |
mkdir -p ~/.npm
Expand All @@ -15,11 +30,13 @@ runs:

# checks the cache is valid and compresses it
- name: Verify npm cache
if: ${{ runner.environment != 'self-hosted' || inputs.save-on-self-hosted == 'true' }}
shell: bash
run: |
npm cache verify

- name: Save npm cache
if: ${{ runner.environment != 'self-hosted' || inputs.save-on-self-hosted == 'true' }}
uses: actions/cache/save@v4
with:
path: |
Expand All @@ -30,6 +47,7 @@ runs:
key: npm-${{ runner.os }}-${{ runner.arch }}-${{ github.run_id }}-${{ github.run_attempt }}

- name: Cleanup npm caches
if: ${{ runner.environment != 'self-hosted' || inputs.save-on-self-hosted == 'true' }}
shell: bash
run: |
# remove all but the latest cache, leaving only the cache we just saved
Expand Down
Loading