Fix Windows build and compile Windows and macOS in CI
The retry constants used by run_helper were gated behind cfg(unix) while run_helper itself builds everywhere, so xcrs failed to compile on Windows and broke the v0.7.4 release for win-amd64 and win-arm64. Only TEXT_FILE_BUSY, which is read by the unix-only is_text_file_busy, stays gated. CI ran every Rust job on ubuntu-latest, so this only surfaced at release time. Add a check-cross-platform job that runs clippy for smbcloud-cli and xcrs on windows-latest and macos-latest. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Seto Elkahfi committed
Oct 20, 2026 at 10:21 UTC
9dcf4b64f5e21b86e6bc701ca496dc55b4b386d1
3 files changed
+41
-3
.agents/AGENTS.md
+2
-1
@@ -70,13 +70,14 @@ Rust change done** — after every edit, not just before a push. Fix clippy find
70
than silencing them with `#[allow(...)]` unless there's a specific reason the lint doesn't
71
apply, and note that reason inline.
72
73
-`ci.yml` runs six jobs on every push; run the ones relevant to what changed, not just the
73
+`ci.yml` runs seven jobs on every push; run the ones relevant to what changed, not just the
74
main Rust workspace job — a change that only compiles in the main workspace but breaks one
75
of these is still a broken CI run:
76
77
| Job | Touches | Local check |
78
|---|---|---|
79
| Rust workspace | any `crates/*` change (except the wasm crate) | `cargo fmt --all -- --check && cargo clippy --workspace --exclude smbcloud-auth-sdk-wasm --tests -- -D warnings && cargo test --workspace --exclude smbcloud-auth-sdk-wasm` |
80
+| Cross-platform (Windows, macOS) | `cfg`-gated code in `crates/cli` or `crates/xcrs` | `cargo clippy -p smbcloud-cli -p xcrs --tests -- -D warnings` (CI only for Windows; cannot run locally on a Mac) |
81
| `smbcloud-auth-sdk-wasm` | that crate, or `smbcloud-auth-sdk` it wraps | `cargo check --package smbcloud-auth-sdk-wasm --target wasm32-unknown-unknown` |
82
| Python SDK | `sdk/python`, or `smbcloud-auth-sdk` | `cd sdk/python && maturin build --release --locked --out dist` |
83
| npm/WASM SDK | `sdk/npm/smbcloud-auth`, or `smbcloud-auth-sdk` | `cd sdk/npm/smbcloud-auth && node ./prepare-package.mjs` (needs `wasm-pack` installed) |
.github/workflows/ci.yml
+39
@@ -3,6 +3,7 @@ name: Tests
3
# Runs on every push.
4
# Covers:
5
# - All Rust workspace members (fmt, clippy, tests)
6
+# - smbcloud-cli + xcrs clippy on Windows and macOS (cfg-gated code)
7
# - smbcloud-auth-sdk-wasm (wasm32-unknown-unknown cargo check)
8
# - sdk/python → maturin wheel build (smbcloud-sdk-auth)
9
# - sdk/npm → wasm-pack + prepare-package.mjs (@smbcloud/sdk-auth)
@@ -56,6 +57,44 @@ jobs:
57
- name: Test — all workspace members (host targets)
58
run: cargo test --workspace --exclude smbcloud-auth-sdk-wasm
59
60
+ # ── Cross-platform build ────────────────────────────────────────────────────
61
+ # A #[cfg(unix)] mismatch type-checks on Linux and only fails on Windows, so
62
+ # compile the packages the release workflows build on those OSes.
63
+ check-cross-platform:
64
+ name: Rust — clippy (${{ matrix.os }})
65
+ runs-on: ${{ matrix.os }}
66
+ strategy:
67
+ fail-fast: false
68
+ matrix:
69
+ os: [windows-latest, macos-latest]
70
+ steps:
71
+ - name: Checkout
72
+ uses: actions/checkout@v6
73
+
74
+ - name: Read Rust toolchain
75
+ shell: bash
76
+ run: |
77
+ rust_toolchain="$(sed -n 's/^channel = "\(.*\)"/\1/p' rust-toolchain.toml | head -n 1)"
78
+ if [ -z "$rust_toolchain" ]; then
79
+ echo "Failed to read Rust toolchain from rust-toolchain.toml" >&2
80
+ exit 1
81
+ fi
82
+ echo "RUST_TOOLCHAIN=${rust_toolchain}" >> "$GITHUB_ENV"
83
+
84
+ - name: Install toolkit
85
+ uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
86
+ with:
87
+ toolchain: ${{ env.RUST_TOOLCHAIN }}
88
+ components: clippy
89
+
90
+ - name: Setup Rust cache
91
+ uses: Swatinem/rust-cache@v2
92
+ with:
93
+ key: check-cross-platform-${{ matrix.os }}
94
+
95
+ - name: Clippy — smbcloud-cli and xcrs
96
+ run: cargo clippy --locked --package smbcloud-cli --package xcrs --tests -- -D warnings
97
+
98
# ── WASM crate ──────────────────────────────────────────────────────────────
99
check-wasm:
100
name: Rust — smbcloud-auth-sdk-wasm (wasm32-unknown-unknown)
crates/xcrs/src/xcrs.rs
-2
@@ -22,9 +22,7 @@ const ANDROIDKIT_START_RETRY_DELAY: Duration = Duration::from_millis(100);
22
/// variant for it.
23
#[cfg(unix)]
24
const TEXT_FILE_BUSY: i32 = 26;
25
-#[cfg(unix)]
25
const TEXT_FILE_BUSY_RETRY_DELAY: Duration = Duration::from_millis(20);
27
-#[cfg(unix)]
26
const TEXT_FILE_BUSY_RETRY_ATTEMPTS: usize = 5;
27
28
pub fn encode_base64(data: impl AsRef<[u8]>) -> String {