diff --git a/.github/actions/setup-rust/action.yml b/.github/actions/setup-rust/action.yml new file mode 100644 index 0000000000000..bb6044cbf08f1 --- /dev/null +++ b/.github/actions/setup-rust/action.yml @@ -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" diff --git a/.github/actions/setup-rust/matchers.json b/.github/actions/setup-rust/matchers.json new file mode 100644 index 0000000000000..aff246556a3db --- /dev/null +++ b/.github/actions/setup-rust/matchers.json @@ -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 + } + ] + } + ] +} diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index 8ca3dd0bda481..5e5cc8b1dec2a 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -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} diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 8c7e0e4f0fb1d..9127813622357 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -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' diff --git a/.github/workflows/build_reusable.yml b/.github/workflows/build_reusable.yml index 666582d176585..4050297d4a73f 100644 --- a/.github/workflows/build_reusable.yml +++ b/.github/workflows/build_reusable.yml @@ -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 diff --git a/.github/workflows/pull_request_stats.yml b/.github/workflows/pull_request_stats.yml index 77f3acb697283..23016ba4907cb 100644 --- a/.github/workflows/pull_request_stats.yml +++ b/.github/workflows/pull_request_stats.yml @@ -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 diff --git a/.github/workflows/trigger_release.yml b/.github/workflows/trigger_release.yml index c0962d685af22..1c36715db4ccd 100644 --- a/.github/workflows/trigger_release.yml +++ b/.github/workflows/trigger_release.yml @@ -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