-
Notifications
You must be signed in to change notification settings - Fork 0
178 lines (171 loc) · 5.94 KB
/
ci.yml
File metadata and controls
178 lines (171 loc) · 5.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
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
bundle-smoke:
name: esbuild bundle smoke test (Node ${{ matrix.node-version }})
runs-on: ubuntu-latest
needs: test
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x, 22.x]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- run: npm ci
- run: npm run build
- name: Shebang count must be exactly 1
run: |
COUNT=$(grep -c "#!/usr/bin/env node" dist/index.js)
if [ "$COUNT" -ne 1 ]; then
echo "FAIL: Expected 1 shebang, found $COUNT"
exit 1
fi
echo "OK: shebang count = $COUNT"
- name: Node.js syntax check
run: node --check dist/index.js
- name: --version smoke test (exits 0, outputs correct semver)
run: |
PKG=$(node -p "require('./package.json').version")
CLI=$(node dist/index.js --version)
echo "package.json=$PKG bundle=$CLI"
if [ "$PKG" != "$CLI" ]; then
echo "FAIL: version mismatch"
exit 1
fi
- name: Bundle size check
run: npm test -- tests/build/
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
pack-install-smoke:
name: Packed install smoke (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: test
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
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: npm pack -> npm install tarball -> switchbot --version / policy new / policy validate
run: npm run smoke:pack-install
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."