Repository navigation
276 lines (235 loc) · 9.59 KB
/
Copy pathci.yaml
File metadata and controls
276 lines (235 loc) · 9.59 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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
gitleaks:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
# The gitleaks GitHub Action requires a paid licence for organisation-owned
# repositories. The CLI is free, so install and run it directly. Secret
# scanning is a CI gate only — there is no make target for it.
- name: Install gitleaks
run: |
set -euo pipefail
curl -sSfL "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" \
| tar -xz -C /usr/local/bin gitleaks
env:
GITLEAKS_VERSION: 8.29.0
- name: Run Gitleaks
run: gitleaks detect --source . --config .gitleaks.toml
ci:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12", "3.13"]
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup uv
uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
- name: Setup pnpm
uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
- name: Setup Node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: package.json
cache: pnpm
- name: Install Python dependencies
run: uv sync --all-extras --locked
- name: Install Node dependencies (MCP mock server)
run: pnpm install --frozen-lockfile
# Run the tools directly rather than through make: the make targets write
# to the tree, and CI must verify what was committed, not fix it.
- name: Run Lint
run: |
uv run ruff check .
uv run ruff format --check .
- name: Run Ty
run: uv run ty check stackone_ai
- name: Type check examples against the current SDK
run: uv run ty check examples
- name: Run Tests
run: uv run pytest
# pyproject allows mcp 1 and 2 and the lockfile pins 2, so the oldest mcp 1 is tested too.
- name: Run Tests against mcp 1
run: uv run --with "mcp==1.30.0" pytest
# Enforces the wire contract in docs/SDK-UCA-CONTRACT.md.
# StackOneHQ/sdk-conformance is private and requires CONFORMANCE_REPO_TOKEN.
# Fork PRs and Dependabot runs cannot access this secret and skip this gate;
# internal branches and PRs require the secret and fail if it is absent or expired.
check-secret:
runs-on: ubuntu-latest
outputs:
can-skip: ${{ steps.check.outputs.can-skip }}
steps:
- id: check
env:
TOKEN: ${{ secrets.CONFORMANCE_REPO_TOKEN }}
IS_FORK: ${{ github.event.pull_request.head.repo.fork == true }}
IS_DEPENDABOT: ${{ github.actor == 'dependabot[bot]' }}
run: |
if [ -z "$TOKEN" ] && { [ "$IS_FORK" = "true" ] || [ "$IS_DEPENDABOT" = "true" ]; }; then
echo "can-skip=true" >> "$GITHUB_OUTPUT"
else
echo "can-skip=false" >> "$GITHUB_OUTPUT"
fi
# Runs the full suite, both SDKs side by side, so a change here that the Node SDK does not
# match fails here rather than drifting.
conformance:
needs: check-secret
if: needs.check-secret.outputs.can-skip != 'true'
runs-on: ubuntu-latest
env:
# Pinned to a commit on stackone-ai-node's main, not the branch, so a Node change never
# silently changes what this job grades. Bump it deliberately.
NODE_SDK_REF: 8c7af617a4c62c0eedccda4fea1254b77de10e8e
steps:
- name: Check conformance token is configured
env:
TOKEN: ${{ secrets.CONFORMANCE_REPO_TOKEN }}
run: |
if [ -z "$TOKEN" ]; then
echo "::error::CONFORMANCE_REPO_TOKEN is not set or has expired."
exit 1
fi
- name: Checkout SDK
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
path: sdk
- name: Checkout conformance suite
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: StackOneHQ/sdk-conformance
ref: 6aba490ee49b298643e3a0bb9fbbaecf36c0edd7
token: ${{ secrets.CONFORMANCE_REPO_TOKEN }}
path: sdk-conformance
persist-credentials: false
# Public, so no token.
- name: Checkout Node SDK
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: StackOneHQ/stackone-ai-node
ref: ${{ env.NODE_SDK_REF }}
path: stackone-ai-node
persist-credentials: false
# tests/test_shared_vectors.py grades the SDK against this copy; it must be the
# pinned commit's vectors/ byte for byte. Refresh with scripts/sync_vectors.sh.
- name: Vendored vectors match the pinned sdk-conformance
run: diff -r sdk/tests/vectors sdk-conformance/vectors
- name: Setup uv
uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
with:
python-version: "3.13"
enable-cache: true
- name: Setup pnpm
uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
# pnpm from sdk-conformance's packageManager; in each SDK checkout pnpm switches to that
# repo's own packageManager version, so one setup serves all three installs.
with:
package_json_file: sdk-conformance/package.json
# The Node SDK's devEngines pins the exact Node version, and the suite runs on it too.
- name: Setup Node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: stackone-ai-node/package.json
- name: Install Node SDK dependencies
working-directory: stackone-ai-node
run: pnpm install --frozen-lockfile
# The runner imports the built dist, not src, so the harness grades the publishable
# artifact. It refuses a dist older than src.
- name: Build Node SDK
working-directory: stackone-ai-node
run: pnpm run build
- name: Install conformance dependencies
working-directory: sdk-conformance
run: pnpm install --frozen-lockfile
- name: Run conformance suite
working-directory: sdk-conformance
env:
NODE_SDK_DIST: ${{ github.workspace }}/stackone-ai-node/dist/index.mjs
PYTHON_SDK_DIR: ${{ github.workspace }}/sdk
run: pnpm test -- --strict-schema
# Make this the one required status check. Individually required checks go
# missing when a job is renamed or a matrix entry is added, and nothing notices.
ci-ok:
if: always()
needs: [check-secret, gitleaks, ci, conformance]
runs-on: ubuntu-latest
steps:
- name: Require every job to have passed
run: |
if [ "${{ needs.gitleaks.result != 'success' || needs.ci.result != 'success' }}" = "true" ]; then
echo "::error::A required job did not pass (gitleaks: ${{ needs.gitleaks.result }}, ci: ${{ needs.ci.result }})"
exit 1
fi
if [ "${{ needs.conformance.result != 'success' && needs.check-secret.outputs.can-skip != 'true' }}" = "true" ]; then
echo "::error::Conformance check did not pass (result: ${{ needs.conformance.result }})"
exit 1
fi
coverage:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup uv
uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
with:
python-version: "3.13"
enable-cache: true
- name: Setup pnpm
uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1
- name: Setup Node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: package.json
cache: pnpm
- name: Install Python dependencies
run: uv sync --all-extras --locked
- name: Install Node dependencies (MCP mock server)
run: pnpm install --frozen-lockfile
- name: Run Tests with Coverage
run: uv run pytest --cov --cov-report=term --cov-report=json --cov-report=html
- name: Create Coverage Badge
uses: jaywcjlove/coverage-badges-cli@998665f7962b1a3935ba8c3e786171a99436e5d1 # v2.3.0
with:
source: coverage/coverage.json
output: coverage/badges.svg
jsonPath: totals.percent_covered
- name: Upload coverage artifact
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
path: coverage/
deploy-coverage:
needs: coverage
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1