Skip to content
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

better rust setup in CI #50905

Merged
merged 5 commits into from
Jun 7, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/actions/setup-rust/action.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 44 additions & 0 deletions .github/actions/setup-rust/matchers.json
Original file line number Diff line number Diff line change
@@ -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 changes: 21 additions & 14 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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}

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/build_reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand All @@ -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

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/pull_request_stats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/trigger_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down