This repository has been archived by the owner on Mar 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Keep Rust caches on main branch warm
Due to cache isolation for security, workflow runs can only restore caches created in either the current branch, the base branch for a PR, or the repo's default branch. Since we're now using merge queues, we don't have regular jobs running on pushes to the main branch, so we won't have a warm cache that is accessible by pull requests. Running check's on each of the supported Rust versions and operating systems will be enough to preload the caches and keep our jobs running more efficiently. GitHub will remove any cache entries that have not been accessed in over 7 days, and we'd also like to ensure that we always cache the latest Rust stable version even if our code/dependencies haven't changed, so we'll also preload the cache on a weekly basis. High load times for GitHub Actions include the start of every hour, so we'll offset that a bit. See: - https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache - https://github.com/Swatinem/rust-cache#cache-details - https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy - https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
- Loading branch information
1 parent
00eb863
commit 0ddd7a3
Showing
3 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package workflows | ||
|
||
preloadCache: { | ||
name: "preload-cache" | ||
|
||
on: { | ||
push: { | ||
branches: [defaultBranch] | ||
paths: [ | ||
"**/Cargo.lock", | ||
"**/Cargo.toml", | ||
".github/workflows/rust.yml", | ||
] | ||
} | ||
|
||
// Run every Monday at 7:45am UTC to cover any upstream Rust stable release. | ||
schedule: [{cron: "45 7 * * 1"}] | ||
|
||
// Allow manually running this workflow. | ||
workflow_dispatch: null | ||
} | ||
|
||
concurrency: { | ||
group: "${{ github.workflow }}-${{ github.ref }}" | ||
"cancel-in-progress": true | ||
} | ||
|
||
env: { | ||
CARGO_INCREMENTAL: 0 | ||
CARGO_TERM_COLOR: "always" | ||
RUST_BACKTRACE: 1 | ||
RUSTFLAGS: "-D warnings" | ||
} | ||
|
||
jobs: { | ||
check_stable: { | ||
name: "check / stable" | ||
defaults: run: shell: "bash" | ||
strategy: { | ||
"fail-fast": false | ||
matrix: platform: [ | ||
"macos-latest", | ||
"ubuntu-latest", | ||
"windows-latest", | ||
] | ||
} | ||
"runs-on": "${{ matrix.platform }}" | ||
steps: [ | ||
_#checkoutCode, | ||
_#installRust, | ||
_#cacheRust, | ||
_#cargoCheck, | ||
] | ||
} | ||
|
||
// Minimum Supported Rust Version | ||
check_msrv: { | ||
name: "check / msrv" | ||
"runs-on": defaultRunner | ||
steps: [ | ||
_#checkoutCode, | ||
{ | ||
name: "Get MSRV from package metadata" | ||
id: "msrv" | ||
run: "awk -F '\"' '/rust-version/{ print \"version=\" $2 }' Cargo.toml >> $GITHUB_OUTPUT" | ||
}, | ||
_#installRust & {with: toolchain: "${{ steps.msrv.outputs.version }}"}, | ||
_#cacheRust, | ||
_#cargoCheck, | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# This file is generated by .github/cue/ci_tool.cue; DO NOT EDIT! | ||
|
||
name: preload-cache | ||
"on": | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- '**/Cargo.lock' | ||
- '**/Cargo.toml' | ||
- .github/workflows/rust.yml | ||
schedule: | ||
- cron: 45 7 * * 1 | ||
workflow_dispatch: null | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
env: | ||
CARGO_INCREMENTAL: 0 | ||
CARGO_TERM_COLOR: always | ||
RUST_BACKTRACE: 1 | ||
RUSTFLAGS: -D warnings | ||
jobs: | ||
check_stable: | ||
name: check / stable | ||
defaults: | ||
run: | ||
shell: bash | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
platform: | ||
- macos-latest | ||
- ubuntu-latest | ||
- windows-latest | ||
runs-on: ${{ matrix.platform }} | ||
steps: | ||
- name: Checkout source code | ||
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab | ||
- name: Install stable Rust toolchain | ||
uses: dtolnay/rust-toolchain@b44cb146d03e8d870c57ab64b80f04586349ca5d | ||
with: | ||
toolchain: stable | ||
components: clippy,rustfmt | ||
- name: Cache dependencies | ||
uses: Swatinem/rust-cache@6fd3edff6979b79f87531400ad694fb7f2c84b1f | ||
with: | ||
shared-key: workflow | ||
- name: Check packages and dependencies for errors | ||
run: cargo check --locked | ||
check_msrv: | ||
name: check / msrv | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout source code | ||
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab | ||
- name: Get MSRV from package metadata | ||
id: msrv | ||
run: awk -F '"' '/rust-version/{ print "version=" $2 }' Cargo.toml >> $GITHUB_OUTPUT | ||
- name: Install ${{ steps.msrv.outputs.version }} Rust toolchain | ||
uses: dtolnay/rust-toolchain@b44cb146d03e8d870c57ab64b80f04586349ca5d | ||
with: | ||
toolchain: ${{ steps.msrv.outputs.version }} | ||
components: clippy,rustfmt | ||
- name: Cache dependencies | ||
uses: Swatinem/rust-cache@6fd3edff6979b79f87531400ad694fb7f2c84b1f | ||
with: | ||
shared-key: workflow | ||
- name: Check packages and dependencies for errors | ||
run: cargo check --locked |