extension_ci: Use different target for nextest (#47738)

Finn Evers created

Release Notes:

- N/A

Change summary

.github/workflows/extension_tests.yml                |  2 
tooling/xtask/src/tasks/workflows/extension_tests.rs |  5 ++
tooling/xtask/src/tasks/workflows/steps.rs           | 28 ++++++++++++--
3 files changed, 29 insertions(+), 6 deletions(-)

Detailed changes

.github/workflows/extension_tests.yml 🔗

@@ -76,7 +76,7 @@ jobs:
     - name: steps::cargo_install_nextest
       uses: taiki-e/install-action@nextest
     - name: steps::cargo_nextest
-      run: cargo nextest run --workspace --no-fail-fast
+      run: 'cargo nextest run --workspace --no-fail-fast --target "$(rustc -vV | sed -n ''s|host: ||p'')"'
       shell: bash -euxo pipefail {0}
       env:
         NEXTEST_NO_TESTS: warn

tooling/xtask/src/tasks/workflows/extension_tests.rs 🔗

@@ -69,7 +69,10 @@ fn check_rust() -> NamedJob {
         .add_step(run_clippy())
         .add_step(steps::cargo_install_nextest())
         .add_step(
-            steps::cargo_nextest(runners::Platform::Linux).add_env(("NEXTEST_NO_TESTS", "warn")),
+            steps::cargo_nextest(runners::Platform::Linux)
+                // Set the target to the current platform again
+                .with_target("$(rustc -vV | sed -n 's|host: ||p')")
+                .add_env(("NEXTEST_NO_TESTS", "warn")),
         );
 
     named::job(job)

tooling/xtask/src/tasks/workflows/steps.rs 🔗

@@ -6,6 +6,30 @@ pub const BASH_SHELL: &str = "bash -euxo pipefail {0}";
 // https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idstepsshell
 pub const PWSH_SHELL: &str = "pwsh";
 
+pub(crate) struct Nextest(Step<Run>);
+
+pub(crate) fn cargo_nextest(platform: Platform) -> Nextest {
+    Nextest(named::run(
+        platform,
+        "cargo nextest run --workspace --no-fail-fast",
+    ))
+}
+
+impl Nextest {
+    pub(crate) fn with_target(mut self, target: &str) -> Step<Run> {
+        if let Some(nextest_command) = self.0.value.run.as_mut() {
+            nextest_command.push_str(&format!(r#" --target "{target}""#));
+        }
+        self.into()
+    }
+}
+
+impl From<Nextest> for Step<Run> {
+    fn from(value: Nextest) -> Self {
+        value.0
+    }
+}
+
 pub fn checkout_repo() -> Step<Use> {
     named::uses(
         "actions",
@@ -66,10 +90,6 @@ pub fn cargo_install_nextest() -> Step<Use> {
     named::uses("taiki-e", "install-action", "nextest")
 }
 
-pub fn cargo_nextest(platform: Platform) -> Step<Run> {
-    named::run(platform, "cargo nextest run --workspace --no-fail-fast")
-}
-
 pub fn setup_cargo_config(platform: Platform) -> Step<Run> {
     match platform {
         Platform::Windows => named::pwsh(indoc::indoc! {r#"