Merge pull request #32 from OpenWonderLabs/refactor/post-3.1.1-improv… #98
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| docs-lint: | |
| name: Markdown lint (changelog) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20.x | |
| cache: npm | |
| - run: npm ci | |
| - run: npm run lint:md:changelog | |
| test: | |
| runs-on: ubuntu-latest | |
| needs: docs-lint | |
| strategy: | |
| matrix: | |
| node-version: [18.x, 20.x, 22.x] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: npm | |
| - run: npm ci | |
| - run: npm run build | |
| - name: CLI --version matches package.json | |
| run: | | |
| PKG=$(node -p "require('./package.json').version") | |
| CLI=$(node dist/index.js --version) | |
| if [ "$PKG" != "$CLI" ]; then | |
| echo "Version drift: package.json=$PKG, CLI=$CLI" | |
| exit 1 | |
| fi | |
| - run: npm test | |
| offline-smoke: | |
| name: Offline size budgets | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20.x | |
| cache: npm | |
| - run: npm ci | |
| - run: npm run build | |
| - name: Seed device-cache fixture | |
| run: | | |
| mkdir -p "$HOME/.switchbot" | |
| cat > "$HOME/.switchbot/devices.json" <<'JSON' | |
| { | |
| "lastUpdated": "2026-04-20T00:00:00.000Z", | |
| "devices": { | |
| "BOT001": { "type": "Bot", "name": "Test Bot", "category": "physical" }, | |
| "METER001": { "type": "Meter", "name": "Test Meter", "category": "physical" }, | |
| "STRIP001": { "type": "Strip Light 3", "name": "Test Strip", "category": "physical" }, | |
| "IRTV001": { "type": "TV", "name": "Test TV", "category": "ir" } | |
| } | |
| } | |
| JSON | |
| - name: agent-bootstrap --compact must stay under 20 KB | |
| run: | | |
| OUT=$(node dist/index.js agent-bootstrap --compact) | |
| BYTES=$(printf '%s' "$OUT" | wc -c) | |
| echo "agent-bootstrap --compact = $BYTES bytes" | |
| if [ "$BYTES" -ge 20000 ]; then | |
| echo "FAIL: budget is 20000, got $BYTES" | |
| exit 1 | |
| fi | |
| - name: schema export --compact --used must stay under 15 KB | |
| run: | | |
| OUT=$(node dist/index.js schema export --compact --used) | |
| BYTES=$(printf '%s' "$OUT" | wc -c) | |
| echo "schema export --compact --used = $BYTES bytes" | |
| if [ "$BYTES" -ge 15000 ]; then | |
| echo "FAIL: budget is 15000, got $BYTES" | |
| exit 1 | |
| fi | |
| policy-schema-sync: | |
| name: Policy schema sync with skill repo | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Fetch skill repo's mirrored schema | |
| run: | | |
| HTTP=$(curl -o /tmp/skill-policy.schema.json -w "%{http_code}" -fsSL --retry 3 \ | |
| https://raw.githubusercontent.com/OpenWonderLabs/openclaw-switchbot-skill/main/examples/policy.schema.json \ | |
| 2>/dev/null || echo "000") | |
| if [ "$HTTP" = "404" ] || [ "$HTTP" = "000" ]; then | |
| echo "SKIP: skill repo schema not yet published (HTTP $HTTP). Skipping drift check." | |
| exit 0 | |
| fi | |
| if [ "$HTTP" != "200" ]; then | |
| echo "WARN: unexpected HTTP $HTTP fetching skill schema. Skipping drift check." | |
| exit 0 | |
| fi | |
| echo "Fetched skill schema (HTTP $HTTP). Diffing against CLI v0.2 source of truth..." | |
| if ! diff -u /tmp/skill-policy.schema.json src/policy/schema/v0.2.json; then | |
| echo "" | |
| echo "FAIL: policy schema drift detected." | |
| echo " CLI source: src/policy/schema/v0.2.json" | |
| echo " Skill copy: https://github.com/OpenWonderLabs/openclaw-switchbot-skill/blob/main/examples/policy.schema.json" | |
| echo "" | |
| echo "Sync the skill's examples/policy.schema.json from the CLI file and cut a matching skill release." | |
| exit 1 | |
| fi | |
| echo "OK: policy schema matches skill repo." |