better rust setup in CI (#50905)
### Description Set some environment variables that reduce size on disk and make the build a little faster. Also, read the toolchain from the `rust-toolchain` file, so it's not duplicated in every workflow. Ported over from the `turbo` repo.
This commit is contained in:
parent
675dec04ca
commit
ded54923a0
7 changed files with 141 additions and 26 deletions
65
.github/actions/setup-rust/action.yml
vendored
Normal file
65
.github/actions/setup-rust/action.yml
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
name: 'Rust Setup'
|
||||
description: 'Sets up the Rust toolchain for CI'
|
||||
inputs:
|
||||
targets:
|
||||
description: 'Comma-separated list of target triples to install for this toolchain'
|
||||
required: false
|
||||
components:
|
||||
description: 'Comma-separated list of components to be additionally installed'
|
||||
required: false
|
||||
skip-install:
|
||||
description: 'Sets environment variables without installing the rust toolchain'
|
||||
required: false
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: 'Get toolchain version from file'
|
||||
id: file
|
||||
shell: bash
|
||||
run: echo "toolchain=$(cat ./rust-toolchain)" >> $GITHUB_OUTPUT
|
||||
|
||||
- shell: bash
|
||||
run: |
|
||||
: force toolchain version
|
||||
echo "RUST_TOOLCHAIN=${{ steps.file.outputs.toolchain }}" >> $GITHUB_ENV
|
||||
|
||||
- shell: bash
|
||||
run: |
|
||||
: disable incremental compilation
|
||||
if [ -z "${CARGO_INCREMENTAL+set}" ]; then
|
||||
echo CARGO_INCREMENTAL=0 >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- shell: bash
|
||||
run: |
|
||||
: enable colors in Cargo output
|
||||
if [ -z "${CARGO_TERM_COLOR+set}" ]; then
|
||||
echo CARGO_TERM_COLOR=always >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- shell: bash
|
||||
run: |
|
||||
: enable rust backtrace
|
||||
if [ -z "${RUST_BACKTRACE+set}" ]; then
|
||||
echo RUST_BACKTRACE=short >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- shell: bash
|
||||
run: |
|
||||
: enable faster cargo sparse registry
|
||||
if [ -z "${CARGO_REGISTRIES_CRATES_IO_PROTOCOL+set}" ]; then
|
||||
echo CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: 'Setup Rust toolchain'
|
||||
uses: dtolnay/rust-toolchain@master
|
||||
if: ${{ !inputs.skip-install }}
|
||||
with:
|
||||
toolchain: ${{ steps.file.outputs.toolchain }}
|
||||
targets: ${{ inputs.targets }}
|
||||
components: ${{ inputs.components }}
|
||||
|
||||
- name: 'Add cargo problem matchers'
|
||||
shell: bash
|
||||
run: echo "::add-matcher::${{ github.action_path }}/matchers.json"
|
44
.github/actions/setup-rust/matchers.json
vendored
Normal file
44
.github/actions/setup-rust/matchers.json
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
"problemMatcher": [
|
||||
{
|
||||
"owner": "cargo-common",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^(warning|warn|error)(?:\\[(\\S*)\\])?: (.*)$",
|
||||
"severity": 1,
|
||||
"code": 2,
|
||||
"message": 3
|
||||
},
|
||||
{
|
||||
"regexp": "^(?:[\\s->=]*(.*):(\\d*):(\\d*)|.*)$",
|
||||
"file": 1,
|
||||
"line": 2,
|
||||
"column": 3
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"owner": "cargo-test",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^.*panicked\\s+at\\s+'(.*)',\\s+(.*):(\\d+):(\\d+)$",
|
||||
"message": 1,
|
||||
"file": 2,
|
||||
"line": 3,
|
||||
"column": 4
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"owner": "rustfmt",
|
||||
"pattern": [
|
||||
{
|
||||
"regexp": "^(Diff in (\\S+)) at line (\\d+):",
|
||||
"message": 1,
|
||||
"file": 2,
|
||||
"line": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
35
.github/workflows/build_and_deploy.yml
vendored
35
.github/workflows/build_and_deploy.yml
vendored
|
@ -8,7 +8,6 @@ on:
|
|||
env:
|
||||
NAPI_CLI_VERSION: 2.14.7
|
||||
TURBO_VERSION: 1.9.6
|
||||
RUST_TOOLCHAIN: nightly-2023-03-09
|
||||
PNPM_VERSION: 7.24.3
|
||||
NODE_MAINTENANCE_VERSION: 16
|
||||
NODE_LTS_VERSION: 18
|
||||
|
@ -199,14 +198,11 @@ jobs:
|
|||
node-version: ${{ env.NODE_LTS_VERSION }}
|
||||
check-latest: true
|
||||
|
||||
- name: Install
|
||||
uses: actions-rs/toolchain@v1
|
||||
if: ${{ !matrix.settings.docker }}
|
||||
- name: Install Rust
|
||||
uses: ./.github/actions/setup-rust
|
||||
with:
|
||||
profile: minimal
|
||||
override: true
|
||||
toolchain: ${{ env.RUST_TOOLCHAIN }}
|
||||
target: ${{ matrix.settings.target }}
|
||||
targets: ${{ matrix.settings.target }}
|
||||
skip-install: ${{ !!matrix.settings.docker }}
|
||||
|
||||
- name: Cache cargo registry
|
||||
uses: actions/cache@v3
|
||||
|
@ -235,7 +231,21 @@ jobs:
|
|||
if: ${{ matrix.settings.docker }}
|
||||
with:
|
||||
image: ${{ matrix.settings.docker }}
|
||||
options: -e RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }} -e NAPI_CLI_VERSION=${{ env.NAPI_CLI_VERSION }} -e TURBO_VERSION=${{ env.TURBO_VERSION }} -e TURBO_TEAM=vercel -e TURBO_TOKEN=${{ secrets.TURBO_TOKEN }} -e TURBO_REMOTE_ONLY=true -v ${{ env.HOME }}/.cargo/git:/root/.cargo/git -v ${{ env.HOME }}/.cargo/registry:/root/.cargo/registry -v ${{ github.workspace }}:/build -w /build
|
||||
options: >-
|
||||
-e RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }}
|
||||
-e CARGO_INCREMENTAL=${{ env.CARGO_INCREMENTAL }}
|
||||
-e CARGO_TERM_COLOR=${{ env.CARGO_TERM_COLOR }}
|
||||
-e RUST_BACKTRACE=${{ env.RUST_BACKTRACE }}
|
||||
-e CARGO_REGISTRIES_CRATES_IO_PROTOCOL=${{ env.CARGO_REGISTRIES_CRATES_IO_PROTOCOL }}
|
||||
-e NAPI_CLI_VERSION=${{ env.NAPI_CLI_VERSION }}
|
||||
-e TURBO_VERSION=${{ env.TURBO_VERSION }}
|
||||
-e TURBO_TEAM=vercel
|
||||
-e TURBO_TOKEN=${{ secrets.TURBO_TOKEN }}
|
||||
-e TURBO_REMOTE_ONLY=true
|
||||
-v ${{ env.HOME }}/.cargo/git:/root/.cargo/git
|
||||
-v ${{ env.HOME }}/.cargo/registry:/root/.cargo/registry
|
||||
-v ${{ github.workspace }}:/build
|
||||
-w /build
|
||||
run: ${{ matrix.settings.build }}
|
||||
|
||||
- name: 'Build'
|
||||
|
@ -293,12 +303,9 @@ jobs:
|
|||
check-latest: true
|
||||
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
uses: ./.github/actions/setup-rust
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: ${{ env.RUST_TOOLCHAIN }}
|
||||
override: true
|
||||
target: wasm32-unknown-unknown
|
||||
targets: wasm32-unknown-unknown
|
||||
|
||||
- run: npm i -g turbo@${{ env.TURBO_VERSION }} pnpm@${PNPM_VERSION}
|
||||
|
||||
|
|
3
.github/workflows/build_and_test.yml
vendored
3
.github/workflows/build_and_test.yml
vendored
|
@ -9,11 +9,12 @@ on:
|
|||
env:
|
||||
NAPI_CLI_VERSION: 2.14.7
|
||||
TURBO_VERSION: 1.9.6
|
||||
RUST_TOOLCHAIN: nightly-2023-03-09
|
||||
PNPM_VERSION: 7.24.3
|
||||
NODE_MAINTENANCE_VERSION: 16
|
||||
NODE_LTS_VERSION: 18
|
||||
TEST_CONCURRENCY: 6
|
||||
# disable backtrace for test snapshots
|
||||
RUST_BACKTRACE: 0
|
||||
|
||||
TURBO_TEAM: 'vercel'
|
||||
TURBO_REMOTE_ONLY: 'true'
|
||||
|
|
18
.github/workflows/build_reusable.yml
vendored
18
.github/workflows/build_reusable.yml
vendored
|
@ -31,11 +31,12 @@ on:
|
|||
env:
|
||||
NAPI_CLI_VERSION: 2.14.7
|
||||
TURBO_VERSION: 1.9.6
|
||||
RUST_TOOLCHAIN: nightly-2023-03-09
|
||||
PNPM_VERSION: 7.24.3
|
||||
NODE_MAINTENANCE_VERSION: 16
|
||||
NODE_LTS_VERSION: 18
|
||||
TEST_CONCURRENCY: 6
|
||||
# disable backtrace for test snapshots
|
||||
RUST_BACKTRACE: 0
|
||||
|
||||
TURBO_TEAM: 'vercel'
|
||||
TURBO_REMOTE_ONLY: 'true'
|
||||
|
@ -56,11 +57,14 @@ jobs:
|
|||
- run: node -v
|
||||
- run: pwd
|
||||
|
||||
- name: Install
|
||||
uses: actions-rs/toolchain@v1
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 25
|
||||
|
||||
# local action -> needs to run after checkout
|
||||
- name: Install Rust
|
||||
uses: ./.github/actions/setup-rust
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: ${{ env.RUST_TOOLCHAIN }}
|
||||
components: rustfmt, clippy
|
||||
|
||||
- name: Install nextest
|
||||
|
@ -71,10 +75,6 @@ jobs:
|
|||
|
||||
- run: npm i -g yarn "pnpm@${PNPM_VERSION}" "turbo@${TURBO_VERSION}" "@napi-rs/cli@${NAPI_CLI_VERSION}"
|
||||
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 25
|
||||
|
||||
# clean up any previous artifacts to avoid hitting disk space limits
|
||||
- run: git clean -xdf && rm -rf /tmp/next-repo-*; rm -rf /tmp/next-install-* /tmp/yarn-* /tmp/ncc-cache target && cargo clean
|
||||
|
||||
|
|
1
.github/workflows/pull_request_stats.yml
vendored
1
.github/workflows/pull_request_stats.yml
vendored
|
@ -7,7 +7,6 @@ name: Generate Pull Request Stats
|
|||
env:
|
||||
NAPI_CLI_VERSION: 2.14.7
|
||||
TURBO_VERSION: 1.9.6
|
||||
RUST_TOOLCHAIN: nightly-2023-03-09
|
||||
PNPM_VERSION: 7.24.3
|
||||
NODE_MAINTENANCE_VERSION: 16
|
||||
NODE_LTS_VERSION: 18
|
||||
|
|
1
.github/workflows/trigger_release.yml
vendored
1
.github/workflows/trigger_release.yml
vendored
|
@ -26,7 +26,6 @@ name: Trigger Release
|
|||
env:
|
||||
NAPI_CLI_VERSION: 2.14.7
|
||||
TURBO_VERSION: 1.9.6
|
||||
RUST_TOOLCHAIN: nightly-2023-03-09
|
||||
PNPM_VERSION: 7.24.3
|
||||
NODE_MAINTENANCE_VERSION: 16
|
||||
NODE_LTS_VERSION: 18
|
||||
|
|
Loading…
Reference in a new issue