1 name: Tests
2
3 # Runs on every push.
4 # Covers:
5 # - All Rust workspace members (fmt, clippy, tests)
6 # - smbcloud-auth-sdk-wasm (wasm32-unknown-unknown cargo check)
7 # - sdk/python → maturin wheel build (smbcloud-sdk-auth)
8 # - sdk/npm → wasm-pack + prepare-package.mjs (@smbcloud/sdk-auth)
9 # - sdk/gems → rb_sys native-extension compile (smbcloud-auth gem)
10 # - nuget → .NET tool launcher build (SmbCloud.Cli)
11
12 on: push
13
14 env:
15 CLI_CLIENT_SECRET: ${{ secrets.CLI_CLIENT_SECRET }}
16 CARGO_TERM_COLOR: always
17
18 jobs:
19 # ── Rust workspace ──────────────────────────────────────────────────────────
20 test-rust:
21 name: Rust — fmt / clippy / test (workspace)
22 runs-on: ubuntu-latest
23 steps:
24 - name: Checkout
25 uses: actions/checkout@v6
26
27 - name: Read Rust toolchain
28 shell: bash
29 run: |
30 rust_toolchain="$(sed -n 's/^channel = "\(.*\)"/\1/p' rust-toolchain.toml | head -n 1)"
31 if [ -z "$rust_toolchain" ]; then
32 echo "Failed to read Rust toolchain from rust-toolchain.toml" >&2
33 exit 1
34 fi
35 echo "RUST_TOOLCHAIN=${rust_toolchain}" >> "$GITHUB_ENV"
36
37 - name: Install toolkit
38 uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
39 with:
40 toolchain: ${{ env.RUST_TOOLCHAIN }}
41 components: rustfmt, clippy
42
43 - name: Setup Rust cache
44 uses: Swatinem/rust-cache@v2
45 with:
46 key: test-rust
47
48 - name: Check formatting
49 run: cargo fmt --all -- --check
50
51 # smbcloud-auth-sdk-wasm targets wasm32-unknown-unknown and cannot be
52 # compiled or tested on the host. It is checked in its own job below.
53 - name: Clippy — all workspace members (host targets)
54 run: cargo clippy --workspace --exclude smbcloud-auth-sdk-wasm --tests -- -D warnings
55
56 - name: Test — all workspace members (host targets)
57 run: cargo test --workspace --exclude smbcloud-auth-sdk-wasm
58
59 # ── WASM crate ──────────────────────────────────────────────────────────────
60 check-wasm:
61 name: Rust — smbcloud-auth-sdk-wasm (wasm32-unknown-unknown)
62 runs-on: ubuntu-latest
63 steps:
64 - name: Checkout
65 uses: actions/checkout@v6
66
67 - name: Read Rust toolchain
68 shell: bash
69 run: |
70 rust_toolchain="$(sed -n 's/^channel = "\(.*\)"/\1/p' rust-toolchain.toml | head -n 1)"
71 if [ -z "$rust_toolchain" ]; then
72 echo "Failed to read Rust toolchain from rust-toolchain.toml" >&2
73 exit 1
74 fi
75 echo "RUST_TOOLCHAIN=${rust_toolchain}" >> "$GITHUB_ENV"
76
77 - name: Install toolkit with wasm32 target
78 uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
79 with:
80 toolchain: ${{ env.RUST_TOOLCHAIN }}
81 targets: wasm32-unknown-unknown
82
83 - name: Setup Rust cache
84 uses: Swatinem/rust-cache@v2
85 with:
86 key: check-wasm
87
88 - name: Check — smbcloud-auth-sdk-wasm
89 run: cargo check --package smbcloud-auth-sdk-wasm --target wasm32-unknown-unknown
90
91 # ── Python SDK ──────────────────────────────────────────────────────────────
92 check-python-sdk:
93 name: SDK — Python wheel (smbcloud-sdk-auth)
94 runs-on: ubuntu-latest
95 steps:
96 - name: Checkout
97 uses: actions/checkout@v6
98
99 - name: Read Rust toolchain
100 shell: bash
101 run: |
102 rust_toolchain="$(sed -n 's/^channel = "\(.*\)"/\1/p' rust-toolchain.toml | head -n 1)"
103 if [ -z "$rust_toolchain" ]; then
104 echo "Failed to read Rust toolchain from rust-toolchain.toml" >&2
105 exit 1
106 fi
107 echo "RUST_TOOLCHAIN=${rust_toolchain}" >> "$GITHUB_ENV"
108
109 - name: Install toolkit
110 uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
111 with:
112 toolchain: ${{ env.RUST_TOOLCHAIN }}
113
114 - name: Setup Rust cache
115 uses: Swatinem/rust-cache@v2
116 with:
117 key: check-python-sdk
118
119 # manylinux: 'off' runs natively on the ubuntu-latest runner without
120 # spinning up a manylinux container, which is sufficient for a CI check.
121 # OpenSSL is vendored in the workspace (features = ["vendored"]) so no
122 # system libssl-dev is required.
123 - name: Build Python wheel
124 uses: PyO3/maturin-action@v1
125 with:
126 working-directory: sdk/python
127 manylinux: "off"
128 args: --release --locked --out dist
129
130 # ── npm / WASM SDK ──────────────────────────────────────────────────────────
131 check-npm-sdk:
132 name: SDK — npm / WASM (@smbcloud/sdk-auth)
133 runs-on: ubuntu-latest
134 steps:
135 - name: Checkout
136 uses: actions/checkout@v6
137
138 - name: Read Rust toolchain
139 shell: bash
140 run: |
141 rust_toolchain="$(sed -n 's/^channel = "\(.*\)"/\1/p' rust-toolchain.toml | head -n 1)"
142 if [ -z "$rust_toolchain" ]; then
143 echo "Failed to read Rust toolchain from rust-toolchain.toml" >&2
144 exit 1
145 fi
146 echo "RUST_TOOLCHAIN=${rust_toolchain}" >> "$GITHUB_ENV"
147
148 - name: Install toolkit with wasm32 target
149 uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
150 with:
151 toolchain: ${{ env.RUST_TOOLCHAIN }}
152 targets: wasm32-unknown-unknown
153
154 - name: Setup Rust cache
155 uses: Swatinem/rust-cache@v2
156 with:
157 key: check-npm-sdk
158
159 # wasm-pack orchestrates the wasm32 build and wasm-bindgen code generation.
160 - name: Install wasm-pack
161 run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
162
163 - name: Install Node.js
164 uses: actions/setup-node@v6
165 with:
166 node-version-file: .nvmrc
167
168 # prepare-package.mjs runs wasm-pack internally and then assembles the
169 # dist/ directory — this validates the full npm package pipeline.
170 - name: Build and prepare package
171 working-directory: sdk/npm/smbcloud-auth
172 run: node ./prepare-package.mjs
173
174 # ── .NET tool ───────────────────────────────────────────────────────────────
175 check-nuget-tool:
176 name: NuGet — .NET tool launcher (SmbCloud.Cli)
177 runs-on: ubuntu-latest
178 steps:
179 - name: Checkout
180 uses: actions/checkout@v6
181
182 - name: Setup .NET SDK
183 uses: actions/setup-dotnet@v4
184 with:
185 dotnet-version: 8.0.x
186
187 - name: Build .NET tool launcher
188 run: dotnet build nuget/smbcloud-cli/SmbCloud.Cli.csproj --configuration Release
189
190 # ── Ruby Gem ────────────────────────────────────────────────────────────────
191 check-ruby-gem:
192 name: SDK — Ruby gem (smbcloud-auth)
193 runs-on: ubuntu-latest
194 steps:
195 - name: Checkout
196 uses: actions/checkout@v6
197
198 - name: Read Rust toolchain
199 shell: bash
200 run: |
201 rust_toolchain="$(sed -n 's/^channel = "\(.*\)"/\1/p' rust-toolchain.toml | head -n 1)"
202 if [ -z "$rust_toolchain" ]; then
203 echo "Failed to read Rust toolchain from rust-toolchain.toml" >&2
204 exit 1
205 fi
206 echo "RUST_TOOLCHAIN=${rust_toolchain}" >> "$GITHUB_ENV"
207
208 - name: Install toolkit
209 uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
210 with:
211 toolchain: ${{ env.RUST_TOOLCHAIN }}
212
213 # The gem's ext Cargo workspace (sdk/gems/auth) is separate from the main
214 # workspace and pulls smbcloud-* crates from crates.io. Its transitive
215 # deps may link against system OpenSSL, so we install libssl-dev to be safe.
216 - name: Install system dependencies
217 run: sudo apt-get update -q && sudo apt-get install -y libssl-dev pkg-config
218
219 # Swatinem/rust-cache scoped to the gem's own Cargo workspace so its
220 # registry deps are cached independently from the main workspace.
221 - name: Setup Rust cache (gem workspace)
222 uses: Swatinem/rust-cache@v2
223 with:
224 key: check-ruby-gem
225 workspaces: sdk/gems/auth
226
227 # CI validates the unreleased workspace version. Derive the local crate
228 # patches from the extension manifest; release builds deliberately
229 # resolve published crates after the release workflow has run.
230 - name: Use workspace Rust crates for the gem check
231 shell: bash
232 run: |
233 mkdir -p sdk/gems/auth/.cargo
234 {
235 echo "[patch.crates-io]"
236 awk -F '=' '/^smbcloud-[[:alnum:]-]+[[:space:]]*=/ {
237 name = $1
238 gsub(/[[:space:]]/, "", name)
239 print name " = { path = \"../../../crates/" name "\" }"
240 }' sdk/gems/auth/ext/auth/Cargo.toml
241 } > sdk/gems/auth/.cargo/config.toml
242
243 - name: Setup Ruby
244 uses: ruby/setup-ruby@v1
245 with:
246 ruby-version: .ruby-version
247 bundler-cache: true
248 working-directory: sdk/gems/auth
249
250 - name: Compile native extension
251 working-directory: sdk/gems/auth
252 run: bundle exec rake compile