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