From 9ad9e47758a97c0fa1d6a6f3dfae628ab03178e3 Mon Sep 17 00:00:00 2001 From: samzong Date: Thu, 2 Jul 2026 23:37:07 -0400 Subject: [PATCH] fix(ci): split SDK checks Signed-off-by: samzong --- .github/workflows/check.yml | 59 ++++++++++++++++++++++++++++++++--- .github/workflows/release.yml | 10 ++---- scripts/check.mjs | 37 +++++++++++++++++++--- 3 files changed, 88 insertions(+), 18 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index a99f57a..71119b5 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -5,7 +5,16 @@ on: push: jobs: - check: + source: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 24 + - name: Check source data + run: node scripts/check.mjs source + typescript: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -14,17 +23,44 @@ jobs: node-version: 24 - name: Enable pnpm run: corepack enable && corepack prepare pnpm@11.7.0 --activate + - name: Check TypeScript SDK + run: node scripts/check.mjs typescript + go: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 24 - uses: actions/setup-go@v5 with: go-version: "1.23" + - name: Check Go SDKs + run: node scripts/check.mjs go + rust: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 24 + - name: Setup Rust + run: rustup toolchain install stable --profile minimal + - name: Check Rust SDK + run: node scripts/check.mjs rust + python: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 24 - uses: actions/setup-python@v5 with: python-version: "3.14" - uses: astral-sh/setup-uv@v5 - - name: Setup Rust - run: rustup toolchain install stable --profile minimal - - name: Check - run: make check + - name: Check Python SDK + run: node scripts/check.mjs python python-compat: runs-on: ubuntu-latest strategy: @@ -39,3 +75,16 @@ jobs: - uses: astral-sh/setup-uv@v5 - name: Test Python SDK run: uv run --directory python --python ${{ matrix.python-version }} pytest tests -q + check: + runs-on: ubuntu-latest + needs: + - source + - typescript + - go + - rust + - python + - python-compat + if: ${{ always() }} + steps: + - name: Check required jobs + run: test "${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}" = "true" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8dfa739..d098541 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,16 +38,10 @@ jobs: - name: Verify release version run: | version="${GITHUB_REF_NAME#v}" - VERSION="$version" node -e 'const { readFileSync } = require("node:fs"); const version = process.env.VERSION; const pkg = JSON.parse(readFileSync("ts/package.json", "utf8")); if (pkg.version !== version) { throw new Error(`ts/package.json version ${pkg.version} != ${version}`); }' + VERSION="$version" node -e 'const { readFileSync } = require("node:fs"); const version = process.env.VERSION; const pkg = JSON.parse(readFileSync("ts/package.json", "utf8")); if (pkg.version !== version) { throw new Error("ts/package.json version " + pkg.version + " != " + version); }' rust_version="$(awk -F '"' '/^version = / { print $2; exit }' rust/Cargo.toml)" test "$rust_version" = "$version" - python_version="$(python - <<'PY' -from pathlib import Path -import re -text = Path("python/pyproject.toml").read_text() -print(re.search(r'^version = "([^"]+)"$', text, re.M).group(1)) -PY -)" + python_version="$(awk -F '"' '/^version = / { print $2; exit }' python/pyproject.toml)" test "$python_version" = "$version" go_cobra_core_version="$(awk '/github.com\/lathe-cli\/kitup\/go / { print $2; exit }' go-cobra/go.mod)" test "$go_cobra_core_version" = "v$version" diff --git a/scripts/check.mjs b/scripts/check.mjs index 6ecee7e..2379ed5 100755 --- a/scripts/check.mjs +++ b/scripts/check.mjs @@ -23,6 +23,16 @@ function assert(condition, message) { if (!condition) fail(message); } +const knownGroups = new Set(["source", "typescript", "go", "rust", "python"]); +const selectedGroups = new Set(process.argv.slice(2)); +for (const group of selectedGroups) { + assert(knownGroups.has(group), `unknown check group: ${group}`); +} + +function shouldRun(group) { + return selectedGroups.size === 0 || selectedGroups.has(group); +} + function validateHosts(spec) { assert(spec.schemaVersion === 1, "hosts schemaVersion must be 1"); assert(Array.isArray(spec.hosts), "hosts must be an array"); @@ -293,9 +303,16 @@ function detectedEnv(prefix) { }; } -for (const [name, command, args, cwd, env] of [ - ["generated-hosts", "node", ["scripts/sync-hosts.mjs", "--check"], rootPath], +for (const [group, name, command, args, cwd, env] of [ + [ + "source", + "generated-hosts", + "node", + ["scripts/sync-hosts.mjs", "--check"], + rootPath, + ], [ + "typescript", "typescript-format", "pnpm", [ @@ -312,16 +329,18 @@ for (const [name, command, args, cwd, env] of [ ], rootPath, ], - ["typescript", "pnpm", ["--dir", "ts", "test"], rootPath], - ["go", "go", ["test", "./..."], new URL("../go/", import.meta.url)], + ["typescript", "typescript", "pnpm", ["--dir", "ts", "test"], rootPath], + ["go", "go", "go", ["test", "./..."], new URL("../go/", import.meta.url)], [ + "go", "go-cobra", "go", ["test", "./..."], new URL("../go-cobra/", import.meta.url), ], - ["rust", "cargo", ["test"], new URL("../rust/", import.meta.url)], + ["rust", "rust", "cargo", ["test"], new URL("../rust/", import.meta.url)], [ + "rust", "rust-clippy", "cargo", [ @@ -336,6 +355,7 @@ for (const [name, command, args, cwd, env] of [ rootPath, ], [ + "python", "python-format", "uv", [ @@ -351,18 +371,21 @@ for (const [name, command, args, cwd, env] of [ new URL("../python/", import.meta.url), ], [ + "python", "python-lint", "uv", ["run", "ruff", "check", "src", "tests"], new URL("../python/", import.meta.url), ], [ + "python", "python", "uv", ["run", "pytest", "tests", "-q"], new URL("../python/", import.meta.url), ], [ + "typescript", "example-ts", "pnpm", ["--dir", "examples/ts", "install-skill"], @@ -370,6 +393,7 @@ for (const [name, command, args, cwd, env] of [ detectedEnv("kitup-example-ts-"), ], [ + "go", "example-go", "go", ["run", "."], @@ -377,6 +401,7 @@ for (const [name, command, args, cwd, env] of [ detectedEnv("kitup-example-go-"), ], [ + "rust", "example-rust", "cargo", ["run", "--quiet"], @@ -384,6 +409,7 @@ for (const [name, command, args, cwd, env] of [ detectedEnv("kitup-example-rust-"), ], [ + "python", "example-python", "uv", ["run", "python", "main.py"], @@ -391,6 +417,7 @@ for (const [name, command, args, cwd, env] of [ detectedEnv("kitup-example-python-"), ], ]) { + if (!shouldRun(group)) continue; console.log(`\n==> ${name}`); const result = spawnSync(command, args, { cwd,