Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

ci(agent): run both SDK suites against a real runtime

thinhlpgecac143fdd09
diff --git a/.github/workflows/rust-check.yml b/.github/workflows/rust-check.yml
index c3a974347..d9b27d01c 100644
--- a/.github/workflows/rust-check.yml
+++ b/.github/workflows/rust-check.yml
@@ -225,3 +225,54 @@ jobs:
- name: cargo clippy
run: cargo clippy --manifest-path src-tauri/${{ matrix.crate }}/Cargo.toml --all-targets -- -D warnings
+
+ # The SDKs are clients of the same channel the CLI tests drive, so they are
+ # built and run here rather than in the linter workflow: the subject is a real
+ # runtime binary, and a client that only agreed with itself would pass. The
+ # committed wire types are checked against protocol/rpc-schema.json in the
+ # same job, since that document is what generates them.
+ sdk:
+ name: agent SDKs
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
+
+ - uses: dtolnay/rust-toolchain@stable
+
+ - uses: Swatinem/rust-cache@v2
+ with:
+ workspaces: src-tauri
+ key: sdk
+ save-if: ${{ github.ref == 'refs/heads/main' }}
+
+ - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
+ with:
+ node-version: '20.x'
+
+ # The runtime the SDKs drive, built the way a user builds it.
+ - name: Build the jan runtime
+ run: |
+ cargo build --locked --manifest-path src-tauri/jan-cli/Cargo.toml \
+ --no-default-features --features cli --bin jan
+ echo "JAN_BIN=$PWD/src-tauri/jan-cli/target/debug/jan" >> "$GITHUB_ENV"
+
+ # For the SDK's own type-check. The suite itself needs no dependency: the
+ # package has none, and `node --test` is in the runtime.
+ - name: Install the workspace
+ run: |
+ corepack enable
+ corepack prepare [email protected] --activate
+ yarn install --immutable
+
+ - name: Type-check the JavaScript SDK
+ run: yarn workspace @janhq/agent-sdk check-types
+
+ - name: JavaScript SDK suite
+ run: yarn workspace @janhq/agent-sdk test
+
+ # The Python client reaches the runtime without Node, so it runs with a
+ # PATH that has no node on it: the claim is checked, not stated.
+ - name: Python SDK suite
+ run: |
+ env -i PATH="$(dirname "$JAN_BIN"):/usr/bin:/bin" HOME="$HOME" \
+ JAN_BIN="$JAN_BIN" python3 -m unittest discover -s sdk/python/tests -t sdk/python