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
85 changes: 85 additions & 0 deletions .github/actions/rustup/action.yml
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 }}

Comment thread
coderabbitai[bot] marked this conversation as resolved.
# 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"
5 changes: 3 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ jobs:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
with:
persist-credentials: false
- uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 # v1
- uses: ./.github/actions/rustup
with:
cache-key: test-${{ runner.os }}
key: test
save-if: ${{ github.ref_name == 'main' }}
- name: Install llvm-cov and nextest
uses: taiki-e/install-action@ad95d4e02e061d4390c4b66ef5ed56c7fee3d2ce # v2
with:
Expand Down
17 changes: 5 additions & 12 deletions .github/workflows/workflow-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ jobs:
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: "24"
- name: Setup Rust
uses: ./.github/actions/rustup
with:
key: build
save-if: ${{ github.ref_name == 'main' }}
- name: TurboCache
uses: lynx-infra/cache@5c6160a6a4c7fca80a2f3057bb9dfc9513fcb732
with:
Expand Down Expand Up @@ -122,15 +127,3 @@ jobs:
retention-days: 1
overwrite: true
include-hidden-files: true
- name: Setup Rust and retry build if failed
if: steps.build.outcome == 'failure'
uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 # v1
with:
target: wasm32-unknown-unknown
cache-key: test-${{ runner.os }}
- name: Retry Build
if: steps.build.outcome == 'failure'
run: |
pnpm turbo build --summarize
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"license": "Apache-2.0",
"type": "module",
"scripts": {
"_internal:cargo:version": "cargo --version",
"build": "tsc --build",
"prepare": "husky && ts-patch install",
"test": "vitest"
Expand Down
4 changes: 1 addition & 3 deletions packages/react/transform/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
"outputs": ["index.d.ts", "index.cjs", "*.node"]
},
"build:wasm": {
"dependsOn": [
"//#_internal:cargo:version"
],
"dependsOn": [],
"inputs": ["src/**/*.rs", "src/wasm.js", "build.rs", "Cargo.toml", "scripts/build_wasm.sh"],
"outputs": ["dist/wasm.cjs"]
},
Expand Down
1 change: 0 additions & 1 deletion packages/web-platform/web-style-transformer/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"tasks": {
"build": {
"dependsOn": [
"//#_internal:cargo:version",
"build:wasm-bindgen"
],
"inputs": [
Expand Down
9 changes: 0 additions & 9 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@
"dependsOn": [],
"cache": false
},
"//#_internal:cargo:version": {
"env": ["GITHUB_SHA"],
"dependsOn": [],
"inputs": [
"rust-toolchain",
"rust-toolchain.toml"
],
"outputs": []
},
"//#build": {
"cache": false,
"dependsOn": [],
Expand Down
Loading