-
Notifications
You must be signed in to change notification settings - Fork 4
354 lines (315 loc) · 13.2 KB
/
Copy pathci-pythinker-cli.yml
File metadata and controls
354 lines (315 loc) · 13.2 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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
name: CI (pythinker-code)
on:
# No path filter on pull_request: check / test / release-validate are required
# status checks, so they must run on every PR. Path-filtering them left
# docs-only (and sdks/examples-only) PRs permanently blocked — the required
# contexts never reported. Running the real checks on every PR keeps one check
# run per context (no duplicate-context false-greens) and gives real signal.
pull_request:
push:
branches:
- main
paths:
- ".github/workflows/**"
- "packages/**"
- "src/**"
- "tests/**"
- "tests_e2e/**"
- "tests_ai/**"
- "web/**"
- "pyproject.toml"
- "uv.lock"
env:
NO_COLOR: "1"
TERM: dumb
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
jobs:
check:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # pinned from v6.0.2
- name: Set up Python 3.14
id: setup-python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # pinned from v6.2.0
with:
python-version: "3.14"
allow-prereleases: true
- name: Set up uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # pinned from v8.1.0
with:
version: "0.8.5"
enable-cache: true
cache-dependency-glob: uv.lock
- name: Prepare building environment
env:
UV_PYTHON: ${{ steps.setup-python.outputs.python-path }}
run: make prepare
- name: Run checks
env:
UV_PYTHON: ${{ steps.setup-python.outputs.python-path }}
run: make check-pythinker-code
test:
strategy:
fail-fast: false
matrix:
python-version: ["3.12", "3.13", "3.14"]
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # pinned from v6.0.2
- name: Set up Python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # pinned from v6.2.0
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Set up uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # pinned from v8.1.0
with:
version: "0.8.5"
enable-cache: true
cache-dependency-glob: uv.lock
- name: Prepare building environment
env:
UV_PYTHON: ${{ steps.setup-python.outputs.python-path }}
run: make prepare
- name: Run tests
env:
UV_PYTHON: ${{ steps.setup-python.outputs.python-path }}
PYTHONUTF8: "1"
run: make cov-pythinker-code
- name: Upload coverage to Codecov
uses: codecov/codecov-action@75cd11691c0faa626561e295848008c8a7dddffe # pinned from v5.5.4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: pythinker-code
name: pythinker-code-${{ matrix.python-version }}
fail_ci_if_error: false
build:
strategy:
# The release-blocking entries stay fail-fast. The experimental VS 2026
# probe below is opted out via continue-on-error so its failures do not
# cancel sibling jobs.
fail-fast: true
matrix:
include:
- runner: ubuntu-22.04
target: x86_64-unknown-linux-gnu
binary_path: dist/onefile/pythinker
- runner: ubuntu-22.04-arm
target: aarch64-unknown-linux-gnu
binary_path: dist/onefile/pythinker
- runner: macos-14
target: aarch64-apple-darwin
binary_path: dist/onefile/pythinker
- runner: windows-2022
target: x86_64-pc-windows-msvc
binary_path: dist/onefile/pythinker.exe
# Forward-compat probe for windows-latest -> VS 2026 migration
# (rolling out 2026-06-08 to 2026-06-15). Same Rust target as the
# release-blocking windows-2022 entry but built against VS 2026 /
# MSVC v144 to surface toolchain regressions before windows-2022
# is deprecated.
- runner: windows-2025-vs2026
target: x86_64-pc-windows-msvc
binary_path: dist/onefile/pythinker.exe
experimental: true
runs-on: ${{ matrix.runner }}
continue-on-error: ${{ matrix.experimental == true }}
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # pinned from v6.0.2
- name: Install GNU Make (Windows)
if: runner.os == 'Windows'
run: choco install make -y
- name: Set up Python 3.13
id: setup-python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # pinned from v6.2.0
with:
python-version: "3.13"
- name: Set up uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # pinned from v8.1.0
with:
version: "0.8.5"
enable-cache: true
cache-dependency-glob: uv.lock
- name: Set up Node.js (web build)
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # pinned from v6.4.0
with:
node-version: "24"
cache: "npm"
cache-dependency-path: web/package-lock.json
- name: Prepare building environment
env:
UV_PYTHON: ${{ steps.setup-python.outputs.python-path }}
run: make prepare
- name: Build standalone binary
env:
UV_PYTHON: ${{ steps.setup-python.outputs.python-path }}
run: make build-bin
- name: Smoke test binary --help
shell: python
run: |
import os
import subprocess
import sys
binary = os.path.abspath(os.environ["BINARY_PATH"])
result = subprocess.run([binary, "--help"], capture_output=True, text=True)
if result.returncode != 0:
print(f"Binary exited {result.returncode}", file=sys.stderr)
print("--- stdout ---", file=sys.stderr)
print(result.stdout, file=sys.stderr)
print("--- stderr ---", file=sys.stderr)
print(result.stderr, file=sys.stderr)
raise SystemExit(result.returncode)
if "Pythinker" not in result.stdout:
print("--- stdout ---", file=sys.stderr)
print(result.stdout, file=sys.stderr)
raise SystemExit("'Pythinker' not found in --help output")
env:
BINARY_PATH: ${{ matrix.binary_path }}
- name: Upload binary artifact
# The experimental windows-2025-vs2026 probe shares its target string
# with the release-blocking windows-2022 entry, so uploading would
# collide on the artifact name. The probe only needs the build to
# succeed; we do not consume its binary.
if: success() && !matrix.experimental
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # pinned from v7.0.1
with:
name: pythinker-${{ matrix.target }}
path: ${{ matrix.binary_path }}
if-no-files-found: error
retention-days: 7
release-validate:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # pinned from v6.0.2
with:
fetch-depth: 0
- name: Set up Python 3.14
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # pinned from v6.2.0
with:
python-version: "3.14"
allow-prereleases: true
- name: Set up uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # pinned from v8.1.0
with:
version: "0.8.5"
enable-cache: true
cache-dependency-glob: uv.lock
- name: Detect version bump
id: version
shell: python
run: |
import os
import subprocess
import tomllib
output_path = os.environ["GITHUB_OUTPUT"]
event_name = os.environ.get("GITHUB_EVENT_NAME", "")
base_ref = os.environ.get("GITHUB_BASE_REF")
if event_name != "pull_request" or not base_ref:
with open(output_path, "a", encoding="utf-8") as output:
output.write("bump=false\n")
raise SystemExit(0)
subprocess.run(["git", "fetch", "origin", base_ref, "--depth=1"], check=True)
base_blob = subprocess.check_output(
["git", "show", f"origin/{base_ref}:pyproject.toml"],
)
base_version = tomllib.loads(base_blob.decode())["project"]["version"]
with open("pyproject.toml", "rb") as handle:
head_version = tomllib.load(handle)["project"]["version"]
bumped = base_version != head_version
with open(output_path, "a", encoding="utf-8") as output:
output.write(f"bump={'true' if bumped else 'false'}\n")
output.write(f"base_version={base_version}\n")
output.write(f"head_version={head_version}\n")
- name: Show version bump info
if: steps.version.outputs.bump == 'true'
run: |
echo "version bump: ${{ steps.version.outputs.base_version }} -> ${{ steps.version.outputs.head_version }}"
- name: Check dependency versions
if: steps.version.outputs.bump == 'true'
run: |
uv run python scripts/check_pythinker_dependency_versions.py \
--root-pyproject pyproject.toml \
--pythinker-core-pyproject packages/pythinker-core/pyproject.toml \
--pythinker-host-pyproject packages/pythinker-host/pyproject.toml \
--pythinker-review-pyproject packages/pythinker-review/pyproject.toml \
--pythinker-sdk-pyproject sdks/pythinker-sdk/pyproject.toml
- name: Check pythinker-code version alignment
if: steps.version.outputs.bump == 'true'
env:
EXPECTED_VERSION: ${{ steps.version.outputs.head_version }}
run: |
python scripts/check_version_tag.py \
--pyproject pyproject.toml \
--expected-version "$EXPECTED_VERSION"
# Hard constraint: every pyproject version bump must be accompanied
# by a README "What's New" section + pinned upgrade snippet and a
# CHANGELOG entry. This is the same gate the release workflow
# enforces at tag time, run here on the PR so we never tag a
# version whose README/CHANGELOG drifted.
- name: Verify README references the new version
if: steps.version.outputs.bump == 'true'
env:
RELEASE_VERSION: ${{ steps.version.outputs.head_version }}
run: |
set -euo pipefail
missing=()
if ! grep -qF "What's New in ${RELEASE_VERSION}" README.md; then
missing+=("a '## What\'s New in ${RELEASE_VERSION}' section")
fi
if ! grep -qF "pythinker-code==${RELEASE_VERSION}" README.md; then
missing+=("a 'pip install --upgrade pythinker-code==${RELEASE_VERSION}' upgrade snippet")
fi
if [ "${#missing[@]}" -gt 0 ]; then
printf '::error title=README out of sync with version bump %s::Update README.md in the same PR as the version bump. Missing: %s\n' \
"${RELEASE_VERSION}" "${missing[*]}"
exit 1
fi
echo "README.md references release ${RELEASE_VERSION}"
- name: Verify CHANGELOG references the new version
if: steps.version.outputs.bump == 'true'
env:
RELEASE_VERSION: ${{ steps.version.outputs.head_version }}
run: |
set -euo pipefail
if ! grep -qE "^## ${RELEASE_VERSION} \\(" CHANGELOG.md; then
printf '::error title=CHANGELOG out of sync with version bump %s::Add a "## %s (YYYY-MM-DD)" entry to CHANGELOG.md in the same PR as the version bump.\n' \
"${RELEASE_VERSION}" "${RELEASE_VERSION}"
exit 1
fi
echo "CHANGELOG.md has an entry for ${RELEASE_VERSION}"
nix-test:
strategy:
fail-fast: true
matrix:
include:
- runner: ubuntu-22.04
target: x86_64-unknown-linux-gnu
binary_path: dist/pythinker
- runner: ubuntu-22.04-arm
target: aarch64-unknown-linux-gnu
binary_path: dist/pythinker
- runner: macos-14
target: aarch64-apple-darwin
binary_path: dist/pythinker
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # pinned from v6.0.2
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@1d87d45818068401a10cf16bdc5f00b24994a83f # pinned from main
- name: Run nix package
run: nix run .#pythinker-code -- --version && nix run . -- --help
- name: Run nix app (apps.default) and assert PYTHINKER_MANAGED
run: |
set -euo pipefail
nix run .#default -- --version
nix build .#default
grep -Eq 'PYTHINKER_MANAGED.*nix' result/bin/pythinker
echo "apps.default runs and the wrapper sets PYTHINKER_MANAGED=nix"