From abec0efce8de9388506ea92341ded605c1e37e03 Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Sat, 21 Mar 2026 04:44:34 -0400 Subject: [PATCH] ci: Run clippy for x86_64-apple-darwin target (#52036) Release Notes: - N/A --------- Co-authored-by: Finn Evers Co-authored-by: Jakub Konka --- .github/workflows/run_tests.yml | 36 +++++++++++++++++++ .../src/tasks/workflows/deploy_collab.rs | 2 +- tooling/xtask/src/tasks/workflows/release.rs | 6 ++-- .../src/tasks/workflows/release_nightly.rs | 2 +- .../xtask/src/tasks/workflows/run_tests.rs | 30 ++++++++++------ tooling/xtask/src/tasks/workflows/steps.rs | 11 ++++-- 6 files changed, 70 insertions(+), 17 deletions(-) diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index fd7fecb4eb0309b7cc53c6efe0d2f2ece5f2a228..1906acf9fab7bbaab81b0549328c2e85d732756d 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -263,6 +263,39 @@ jobs: - name: steps::show_sccache_stats run: sccache --show-stats || true timeout-minutes: 60 + clippy_mac_x86_64: + needs: + - orchestrate + if: needs.orchestrate.outputs.run_tests == 'true' + runs-on: namespace-profile-mac-large + steps: + - name: steps::checkout_repo + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + with: + clean: false + - name: steps::setup_cargo_config + run: | + mkdir -p ./../.cargo + cp ./.cargo/ci-config.toml ./../.cargo/config.toml + - name: steps::cache_rust_dependencies_namespace + uses: namespacelabs/nscloud-cache-action@v1 + with: + cache: rust + path: ~/.rustup + - name: steps::install_rustup_target + run: rustup target add x86_64-apple-darwin + - name: steps::setup_sccache + run: ./script/setup-sccache + env: + R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }} + R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} + R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} + SCCACHE_BUCKET: sccache-zed + - name: steps::clippy + run: ./script/clippy --target x86_64-apple-darwin + - name: steps::show_sccache_stats + run: sccache --show-stats || true + timeout-minutes: 60 run_tests_windows: needs: - orchestrate @@ -731,6 +764,7 @@ jobs: - clippy_windows - clippy_linux - clippy_mac + - clippy_mac_x86_64 - run_tests_windows - run_tests_linux - run_tests_mac @@ -760,6 +794,7 @@ jobs: check_result "clippy_windows" "$RESULT_CLIPPY_WINDOWS" check_result "clippy_linux" "$RESULT_CLIPPY_LINUX" check_result "clippy_mac" "$RESULT_CLIPPY_MAC" + check_result "clippy_mac_x86_64" "$RESULT_CLIPPY_MAC_X86_64" check_result "run_tests_windows" "$RESULT_RUN_TESTS_WINDOWS" check_result "run_tests_linux" "$RESULT_RUN_TESTS_LINUX" check_result "run_tests_mac" "$RESULT_RUN_TESTS_MAC" @@ -779,6 +814,7 @@ jobs: RESULT_CLIPPY_WINDOWS: ${{ needs.clippy_windows.result }} RESULT_CLIPPY_LINUX: ${{ needs.clippy_linux.result }} RESULT_CLIPPY_MAC: ${{ needs.clippy_mac.result }} + RESULT_CLIPPY_MAC_X86_64: ${{ needs.clippy_mac_x86_64.result }} RESULT_RUN_TESTS_WINDOWS: ${{ needs.run_tests_windows.result }} RESULT_RUN_TESTS_LINUX: ${{ needs.run_tests_linux.result }} RESULT_RUN_TESTS_MAC: ${{ needs.run_tests_mac.result }} diff --git a/tooling/xtask/src/tasks/workflows/deploy_collab.rs b/tooling/xtask/src/tasks/workflows/deploy_collab.rs index a13e5684f615e1c219e131f7308f6e021e89ac9f..c6b620bd5d54c18ddad3796b414e1ba04c90f530 100644 --- a/tooling/xtask/src/tasks/workflows/deploy_collab.rs +++ b/tooling/xtask/src/tasks/workflows/deploy_collab.rs @@ -33,7 +33,7 @@ fn style() -> NamedJob { .add_step(steps::cache_rust_dependencies_namespace()) .map(steps::install_linux_dependencies) .add_step(steps::cargo_fmt()) - .add_step(steps::clippy(Platform::Linux)), + .add_step(steps::clippy(Platform::Linux, None)), )) } diff --git a/tooling/xtask/src/tasks/workflows/release.rs b/tooling/xtask/src/tasks/workflows/release.rs index 2963bbec24301b85b345461a6ea532a9ac3421c5..2646005021e052681c0fa16a258a1d0dad725390 100644 --- a/tooling/xtask/src/tasks/workflows/release.rs +++ b/tooling/xtask/src/tasks/workflows/release.rs @@ -16,9 +16,9 @@ pub(crate) fn release() -> Workflow { let macos_tests = run_tests::run_platform_tests_no_filter(Platform::Mac); let linux_tests = run_tests::run_platform_tests_no_filter(Platform::Linux); let windows_tests = run_tests::run_platform_tests_no_filter(Platform::Windows); - let macos_clippy = run_tests::clippy(Platform::Mac); - let linux_clippy = run_tests::clippy(Platform::Linux); - let windows_clippy = run_tests::clippy(Platform::Windows); + let macos_clippy = run_tests::clippy(Platform::Mac, None); + let linux_clippy = run_tests::clippy(Platform::Linux, None); + let windows_clippy = run_tests::clippy(Platform::Windows, None); let check_scripts = run_tests::check_scripts(); let create_draft_release = create_draft_release(); diff --git a/tooling/xtask/src/tasks/workflows/release_nightly.rs b/tooling/xtask/src/tasks/workflows/release_nightly.rs index bcae94d08d14a76bef82482c1afd707c5a8a4bda..277db38bee6ebe24482d6c91f6bb8966bed9d1d3 100644 --- a/tooling/xtask/src/tasks/workflows/release_nightly.rs +++ b/tooling/xtask/src/tasks/workflows/release_nightly.rs @@ -18,7 +18,7 @@ pub fn release_nightly() -> Workflow { let style = check_style(); // run only on windows as that's our fastest platform right now. let tests = run_platform_tests_no_filter(Platform::Windows); - let clippy_job = clippy(Platform::Windows); + let clippy_job = clippy(Platform::Windows, None); let nightly = Some(ReleaseChannel::Nightly); let bundle = ReleaseBundleJobs { diff --git a/tooling/xtask/src/tasks/workflows/run_tests.rs b/tooling/xtask/src/tasks/workflows/run_tests.rs index 3ca8e456346dc5b1bbea89ca40993456e4f1354c..a43b36e975957daed86e5eff242eb645599eb185 100644 --- a/tooling/xtask/src/tasks/workflows/run_tests.rs +++ b/tooling/xtask/src/tasks/workflows/run_tests.rs @@ -15,7 +15,7 @@ use crate::tasks::workflows::{ }; use super::{ - runners::{self, Platform}, + runners::{self, Arch, Platform}, steps::{self, FluentBuilder, NamedJob, named, release_job}, }; @@ -48,9 +48,10 @@ pub(crate) fn run_tests() -> Workflow { let mut jobs = vec![ orchestrate, check_style(), - should_run_tests.guard(clippy(Platform::Windows)), - should_run_tests.guard(clippy(Platform::Linux)), - should_run_tests.guard(clippy(Platform::Mac)), + should_run_tests.guard(clippy(Platform::Windows, None)), + should_run_tests.guard(clippy(Platform::Linux, None)), + should_run_tests.guard(clippy(Platform::Mac, None)), + should_run_tests.guard(clippy(Platform::Mac, Some(Arch::X86_64))), should_run_tests.guard(run_platform_tests(Platform::Windows)), should_run_tests.guard(run_platform_tests(Platform::Linux)), should_run_tests.guard(run_platform_tests(Platform::Mac)), @@ -489,7 +490,12 @@ fn check_workspace_binaries() -> NamedJob { )) } -pub(crate) fn clippy(platform: Platform) -> NamedJob { +pub(crate) fn clippy(platform: Platform, arch: Option) -> NamedJob { + let target = arch.map(|arch| match (platform, arch) { + (Platform::Mac, Arch::X86_64) => "x86_64-apple-darwin", + (Platform::Mac, Arch::AARCH64) => "aarch64-apple-darwin", + _ => unimplemented!("cross-arch clippy not supported for {platform}/{arch}"), + }); let runner = match platform { Platform::Windows => runners::WINDOWS_DEFAULT, Platform::Linux => runners::LINUX_DEFAULT, @@ -507,16 +513,20 @@ pub(crate) fn clippy(platform: Platform) -> NamedJob { platform == Platform::Linux, steps::install_linux_dependencies, ) + .when_some(target, |this, target| { + this.add_step(steps::install_rustup_target(target)) + }) .add_step(steps::setup_sccache(platform)) - .add_step(steps::clippy(platform)) + .add_step(steps::clippy(platform, target)) .add_step(steps::show_sccache_stats(platform)); if platform == Platform::Linux { job = use_clang(job); } - NamedJob { - name: format!("clippy_{platform}"), - job, - } + let name = match arch { + Some(arch) => format!("clippy_{platform}_{arch}"), + None => format!("clippy_{platform}"), + }; + NamedJob { name, job } } pub(crate) fn run_platform_tests(platform: Platform) -> NamedJob { diff --git a/tooling/xtask/src/tasks/workflows/steps.rs b/tooling/xtask/src/tasks/workflows/steps.rs index 27d3819ec72d9117347284610742a0de96d005f3..2593d5dd0e8a2edc33f558de07af05a30f46ddbe 100644 --- a/tooling/xtask/src/tasks/workflows/steps.rs +++ b/tooling/xtask/src/tasks/workflows/steps.rs @@ -211,13 +211,20 @@ pub fn clear_target_dir_if_large(platform: Platform) -> Step { } } -pub fn clippy(platform: Platform) -> Step { +pub fn clippy(platform: Platform, target: Option<&str>) -> Step { match platform { Platform::Windows => named::pwsh("./script/clippy.ps1"), - _ => named::bash("./script/clippy"), + _ => match target { + Some(target) => named::bash(format!("./script/clippy --target {target}")), + None => named::bash("./script/clippy"), + }, } } +pub fn install_rustup_target(target: &str) -> Step { + named::bash(format!("rustup target add {target}")) +} + pub fn cache_rust_dependencies_namespace() -> Step { named::uses("namespacelabs", "nscloud-cache-action", "v1") .add_with(("cache", "rust"))