Files
Yossi EliazandDarren Schroeder 396a7588af CI: run Fmt and Clippy in a parallel lint job (#19453)
## Description

Move workspace Fmt and Clippy onto a per-OS `lint` job so they no longer
sit on the root build/test critical path. Same Incredibuild runners,
same `--workspace --all-targets`, same `ci` profile, same Clippy `-D
warnings` strictness. Root still runs Check, Build, Test, Doctest,
stdlib and Python checks. Fuzz still runs Fmt/Check/Clippy through the
shared step anchors.

Depends on / stacks with nushell/nushell#19445: that PR removes the
redundant Check before Clippy and switches Clippy to
`CARGO_BUILD_WARNINGS=deny`. Best merged after #19445 so the lint job
picks up those Clippy changes and root drops Check.

## Timing (motivation from #19445 run)

| Job | Clippy | Root total |
| --- | --- | --- |
| [Windows /
root](https://github.com/nushell/nushell/actions/runs/42012499261/job/127194764210)
| 43s | 416s |
| [MacOS /
root](https://github.com/nushell/nushell/actions/runs/42012499261/job/127194764322)
| 30s | 424s |
| [Linux /
root](https://github.com/nushell/nushell/actions/runs/42012499261/job/127194764098)
| 33s | 228s |

Expected wall-clock win is roughly Clippy (+ Fmt) coming off the
critical path, if there is spare Incredibuild capacity for the extra
lint jobs.

## User-facing changes (Release notes)

n/a

---------

Signed-off-by: Yossi Eliaz <zozo123@users.noreply.github.com>
Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
2026-11-12 15:56:12 -06:00

258 lines
7.8 KiB
YAML

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
push:
branches:
- main
- 'patch-release-*'
name: Continuous Integration
permissions:
contents: read
env:
NU_BUILD_PR: ${{ github.event.pull_request.html_url }}
NU_LOG_LEVEL: DEBUG
NU_TEST_SKIP_DEPS_BUILD: true
NUSHELL_CARGO_PROFILE: ci
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}
cancel-in-progress: true
jobs:
root:
name: ${{ matrix.platform.name }} / root
runs-on: ${{ matrix.platform.runner }}
# Do not run CI on draft PRs or on the lower layers of stacked PRs
if: &job_if >-
!github.event.pull_request.draft &&
(
github.event.pull_request.stack == null ||
github.event.pull_request.stack.position ==
github.event.pull_request.stack.size
)
env:
build-target: ${{ matrix.platform.target }}
working-directory: ${{ github.workspace }}
cargo-options: --workspace --all-targets
profile: ci
strategy:
matrix:
platform: &platforms
- name: Linux
runner: &runner_linux incredibuild-ubuntu-2204
target: &target_linux x86_64-unknown-linux-gnu
- name: Windows
runner: &runner_windows incredibuild-windows-2022
target: &target_windows x86_64-pc-windows-msvc
- name: MacOS
runner: &runner_macos incredibuild-macos-latest
target: &target_macos x86_64-apple-darwin
steps:
- &step_checkout_repo
name: Checkout Repo
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- &step_setup_rust_toolchain
name: Setup Rust Toolchain
run: rustup target add ${{ env.build-target }}
working-directory: ${{ env.working-directory }}
- &step_cache_rust
name: Cache Rust
uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
with:
workspaces: ${{ env.working-directory }} -> target
cache-all-crates: true
# Workspace crates are recompiled after an exact cache hit anyway (fingerprint
# mismatch), while restoring them dominates Cache Rust on Windows (~2.8 GB, ~54s).
# Cache dependencies only so restores stay small and useful.
cache-workspace-crates: false
# Fmt and Clippy run in the parallel lint job so they stay off the build/test critical path.
- &step_build
name: Build
working-directory: ${{ env.working-directory }}
run: >-
cargo --config "${{ github.workspace }}/.cargo/ci.toml"
build ${{ env.cargo-options }}
--profile ${{ env.profile }}
- &step_test
name: Test
working-directory: ${{ env.working-directory }}
run: >-
cargo --config "${{ github.workspace }}/.cargo/ci.toml"
test ${{ env.cargo-options }}
--profile ${{ env.profile }}
- &step_doctest
name: Doctest
working-directory: ${{ env.working-directory }}
run: >-
cargo --config "${{ github.workspace }}/.cargo/ci.toml"
test --workspace --doc
--profile ${{ env.profile }}
- &step_add_nushell_to_path
name: Add Nushell to PATH
shell: bash
env:
NU_HOME: ${{ env.working-directory }}/target/${{ env.profile }}
run: printf '%s\n' "${NU_HOME}" >> "$GITHUB_PATH"
- &step_test_std
name: Test Std
run: nu -n -c 'use crates/nu-std/testing.nu; testing run-tests --path crates/nu-std'
- &step_setup_python
name: Setup Python
uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.10"
- &step_install_virtualenv
name: Install virtualenv
run: pip install virtualenv
- &step_test_virtualenv
name: Test virtualenv
run: nu scripts/test_virtualenv.nu
- &step_upload_artifacts
name: Upload Artifacts
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
env:
OS_NAMES: '{"Windows":"windows","Linux":"linux","macOS":"macos"}'
ARCH_NAMES: '{"X86":"x86","X64":"x86_64","ARM":"arm","ARM64":"aarch64"}'
with:
name: &artifact_name >-
${{ format('nu-{0}-{1}-{2}',
github.event.number || github.ref_name,
fromJSON(env.OS_NAMES)[runner.os],
fromJSON(env.ARCH_NAMES)[runner.arch]) }}
path: |
${{ format('{0}/target/{1}/nu',
env.working-directory || github.workspace,
env.profile || 'ci') }}
${{ format('{0}/target/{1}/nu.exe',
env.working-directory || github.workspace,
env.profile || 'ci') }}
retention-days: 14
- &step_assert_clean_repo
name: Assert Clean Repo
shell: bash
run: test -z "$(git status --porcelain)"
# Fmt + Clippy on their own runners so root can build/test without waiting on them.
# Same platforms, same cargo-options/profile, same warning-deny via CARGO_BUILD_WARNINGS.
lint:
name: ${{ matrix.platform.name }} / lint
runs-on: ${{ matrix.platform.runner }}
if: *job_if
env:
build-target: ${{ matrix.platform.target }}
working-directory: ${{ github.workspace }}
cargo-options: --workspace --all-targets
profile: ci
strategy:
matrix:
platform: *platforms
steps:
- *step_checkout_repo
- *step_setup_rust_toolchain
- *step_cache_rust
- &step_fmt
name: Fmt
working-directory: ${{ env.working-directory }}
run: |
rustup component add rustfmt
cargo fmt --all --check
- &step_clippy
name: Clippy
env:
CARGO_BUILD_WARNINGS: deny
working-directory: ${{ env.working-directory }}
run: >-
rustup component add clippy
cargo --config "${{ github.workspace }}/.cargo/ci.toml"
clippy ${{ env.cargo-options }}
--profile ${{ env.profile }}
- *step_assert_clean_repo
root_wasm:
name: WASM / root
runs-on: *runner_linux
if: *job_if
env:
build-target: wasm32-unknown-unknown
working-directory: ${{ github.workspace }}
profile: ci
cargo-options: >-
--no-default-features
--target wasm32-unknown-unknown
-p nu-cmd-base
-p nu-cmd-extra
-p nu-cmd-lang
-p nu-color-config
-p nu-command
-p nu-derive-value
-p nu-engine
-p nu-glob
-p nu-json
-p nu-parser
-p nu-path
-p nu-pretty-hex
-p nu-protocol
-p nu-std
-p nu-system
-p nu-table
-p nu-term-grid
-p nu-utils
-p nuon
steps:
- *step_checkout_repo
- *step_setup_rust_toolchain
- *step_cache_rust
- name: Check
working-directory: ${{ env.working-directory }}
run: >-
cargo --config "${{ github.workspace }}/.cargo/ci.toml"
check ${{ env.cargo-options }}
--profile ${{ env.profile }}
- *step_build
- *step_assert_clean_repo
fuzz:
name: ${{ matrix.platform.name }} / ${{ matrix.crate }} / fuzz
runs-on: ${{ matrix.platform.runner }}
if: *job_if
env:
build-target: ${{ matrix.platform.target }}
working-directory: ${{ github.workspace }}/crates/${{ matrix.crate }}/fuzz
profile: dev
cargo-options: --all-targets
strategy:
matrix:
platform: *platforms
crate:
- nu-parser
- nu-path
steps:
- *step_checkout_repo
- *step_setup_rust_toolchain
- *step_cache_rust
- *step_fmt
- *step_clippy
- *step_assert_clean_repo