-
Notifications
You must be signed in to change notification settings - Fork 122
ci: use self-hosted rust cache #1607
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
Merged
+94
−28
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c9108e3
ci: use self-hosted rust cache
colinaaa 34eecc0
fix: zizmor
colinaaa d817962
Merge branch 'main' into colin/0826/rust-cache
colinaaa 8b3d937
fix: update install rustup to support Windows
colinaaa 931e4bb
fix: remove `_internal:cargo:version`
colinaaa bd453d9
Apply suggestions from code review
colinaaa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,85 @@ | ||
| # This action installs the minimal Rust profile and configures Swatinem/rust-cache. | ||
| # | ||
| # It is needed to install as few Rust components as possbile because | ||
| # it takes a few minutes to install some of components on Windows and Mac, especially rust-doc. | ||
|
|
||
| name: Rustup | ||
|
|
||
| description: Install Rust with cache | ||
|
|
||
| inputs: | ||
| key: | ||
| description: The cache key for cargo | ||
| required: true | ||
| save-if: | ||
| description: Should save toolchain cache or not | ||
| default: "false" | ||
| required: false | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Install rustup, if needed | ||
| shell: bash | ||
| run: | # zizmor: ignore[github-env] This action would only run on pull_request | ||
| if ! command -v rustup &> /dev/null ; then | ||
| curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL "https://sh.rustup.rs" | sh -s -- --default-toolchain none -y | ||
|
|
||
| # Resolve the correct CARGO_HOME path depending on OS | ||
| if [[ "$RUNNER_OS" == "Windows" ]]; then | ||
| echo "${CARGO_HOME:-$USERPROFILE/.cargo}/bin" | sed 's|/|\\|g' >> $GITHUB_PATH | ||
| else | ||
| printf '%s\n' "${CARGO_HOME:-$HOME/.cargo}/bin" >> "$GITHUB_PATH" | ||
| fi | ||
| fi | ||
| env: | ||
| RUNNER_OS: "${{ runner.os }}" | ||
|
|
||
| - name: Get toolchain | ||
| id: get-toolchain | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| if [[ -f rust-toolchain.toml ]]; then | ||
| toolchain="$(grep -E '^\s*channel\s*=' rust-toolchain.toml | head -n1 | sed -E 's/.*=\s*"([^"]+)".*/\1/')" | ||
| elif [[ -f rust-toolchain ]]; then | ||
| toolchain="$(cat rust-toolchain)" | ||
| else | ||
| toolchain="stable" | ||
| fi | ||
| printf 'toolchain=%s\n' "${toolchain}" >> "$GITHUB_OUTPUT" | ||
| - name: Restore rustup cache | ||
| id: restore | ||
| if: ${{ inputs.save-if == 'true' }} | ||
| uses: lynx-infra/cache/restore@5c6160a6a4c7fca80a2f3057bb9dfc9513fcb732 | ||
| with: | ||
| path: ~/.rustup/toolchains | ||
| key: rustup-cache-v3-${{ runner.os }}-${{ steps.get-toolchain.outputs.toolchain }} | ||
|
|
||
| # install components for nightly toolchain | ||
| - name: Install | ||
| shell: bash | ||
| env: | ||
| toolchain: ${{ steps.get-toolchain.outputs.toolchain }} | ||
| run: | | ||
| rustup toolchain install "$toolchain" \ | ||
| -c rustc \ | ||
| -c cargo \ | ||
| -c rust-std \ | ||
| -c clippy \ | ||
| -c rustfmt | ||
| rustup target add --toolchain "$toolchain" wasm32-unknown-unknown | ||
| - name: Save rustup cache | ||
| uses: lynx-infra/cache/save@5c6160a6a4c7fca80a2f3057bb9dfc9513fcb732 | ||
| if: ${{ inputs.save-if == 'true' && steps.restore.outputs.cache-hit != 'true' }} | ||
| with: | ||
| path: ~/.rustup/toolchains | ||
| key: rustup-cache-v3-${{ runner.os }}-${{ steps.get-toolchain.outputs.toolchain }} | ||
|
|
||
| - name: Cargo cache | ||
| uses: stormslowly/rust-cache@8269079380bc35105b3ed8b0f1f7c9557c6dec93 # v0.0.2 | ||
| with: | ||
| prefix-key: "RCache-L-5" | ||
| shared-key: ${{ inputs.key }} | ||
| save-if: ${{ inputs.save-if }} | ||
| fullmatch-only: "true" | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.