Skip to content

Commit 23f7da4

Browse files
authored
Merge pull request #92 from githubnext/codex/restore-basic-migration-ci
ci: restore basic and migration checks
2 parents 2bfcc12 + cfe9db1 commit 23f7da4

4 files changed

Lines changed: 444 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
merge_group:
7+
branches: [main]
8+
types: [checks_requested]
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: read
13+
14+
env:
15+
PYTHON_VERSION: "3.12"
16+
17+
jobs:
18+
lint:
19+
name: Lint
20+
runs-on: ubuntu-24.04
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ env.PYTHON_VERSION }}
27+
28+
- uses: astral-sh/setup-uv@v6
29+
with:
30+
enable-cache: true
31+
32+
- name: Ruff lint
33+
run: uv run --extra dev ruff check src/ tests/
34+
35+
- name: Ruff format check
36+
run: uv run --extra dev ruff format --check src/ tests/
37+
38+
python-tests:
39+
name: Python Unit Tests
40+
runs-on: ubuntu-24.04
41+
steps:
42+
- uses: actions/checkout@v4
43+
44+
- uses: actions/setup-python@v5
45+
with:
46+
python-version: ${{ env.PYTHON_VERSION }}
47+
48+
- uses: astral-sh/setup-uv@v6
49+
with:
50+
enable-cache: true
51+
52+
- name: Install dependencies
53+
run: uv sync --extra dev
54+
55+
- name: Run unit tests
56+
run: uv run pytest tests/unit tests/test_console.py -n auto --dist worksteal
57+
58+
go-tests:
59+
name: Go Tests
60+
runs-on: ubuntu-24.04
61+
steps:
62+
- uses: actions/checkout@v4
63+
64+
- uses: actions/setup-python@v5
65+
with:
66+
python-version: ${{ env.PYTHON_VERSION }}
67+
68+
- uses: astral-sh/setup-uv@v6
69+
with:
70+
enable-cache: true
71+
72+
- uses: actions/setup-go@v5
73+
if: hashFiles('go.mod') != ''
74+
with:
75+
go-version-file: go.mod
76+
cache: true
77+
78+
- name: Install Python reference CLI
79+
if: hashFiles('go.mod') != ''
80+
run: |
81+
uv sync --extra dev
82+
test -x "$GITHUB_WORKSPACE/.venv/bin/apm"
83+
echo "APM_PYTHON_BIN=$GITHUB_WORKSPACE/.venv/bin/apm" >> "$GITHUB_ENV"
84+
85+
- name: Run Go tests
86+
if: hashFiles('go.mod') != ''
87+
run: go test ./...

.github/workflows/migration-ci.yml

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
name: Migration Parity and Benchmarks
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
paths:
7+
- ".crane/**"
8+
- ".github/workflows/migration-ci.yml"
9+
- "cmd/**"
10+
- "internal/**"
11+
- "pkg/**"
12+
- "go.mod"
13+
- "go.sum"
14+
- "pyproject.toml"
15+
- "scripts/ci/**"
16+
- "src/**"
17+
- "tests/benchmarks/**"
18+
- "tests/unit/test_crane_score.py"
19+
workflow_dispatch:
20+
21+
permissions:
22+
contents: read
23+
24+
env:
25+
PYTHON_VERSION: "3.12"
26+
27+
jobs:
28+
detect-changes:
29+
name: Detect Migration Changes
30+
runs-on: ubuntu-24.04
31+
outputs:
32+
should-run: ${{ steps.filter.outputs.should-run }}
33+
steps:
34+
- uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0
37+
38+
- name: Check changed paths
39+
id: filter
40+
shell: bash
41+
run: |
42+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
43+
echo "should-run=true" >> "$GITHUB_OUTPUT"
44+
exit 0
45+
fi
46+
47+
git diff --name-only \
48+
"${{ github.event.pull_request.base.sha }}" \
49+
"${{ github.event.pull_request.head.sha }}" \
50+
| tee "$RUNNER_TEMP/changed-files.txt"
51+
52+
if grep -Eq '^(\.crane/|cmd/|internal/|pkg/|go\.mod$|go\.sum$|pyproject\.toml$|src/|tests/benchmarks/|tests/unit/test_crane_score\.py$)' "$RUNNER_TEMP/changed-files.txt"; then
53+
echo "should-run=true" >> "$GITHUB_OUTPUT"
54+
else
55+
echo "should-run=false" >> "$GITHUB_OUTPUT"
56+
fi
57+
58+
parity:
59+
name: Python-vs-Go Parity Gate
60+
needs: [detect-changes]
61+
if: needs.detect-changes.outputs.should-run == 'true'
62+
runs-on: ubuntu-24.04
63+
steps:
64+
- uses: actions/checkout@v4
65+
66+
- uses: actions/setup-python@v5
67+
with:
68+
python-version: ${{ env.PYTHON_VERSION }}
69+
70+
- uses: astral-sh/setup-uv@v6
71+
with:
72+
enable-cache: true
73+
74+
- uses: actions/setup-go@v5
75+
with:
76+
go-version-file: go.mod
77+
cache: true
78+
79+
- name: Install Python reference CLI
80+
run: |
81+
uv sync --extra dev
82+
test -x "$GITHUB_WORKSPACE/.venv/bin/apm"
83+
echo "APM_PYTHON_BIN=$GITHUB_WORKSPACE/.venv/bin/apm" >> "$GITHUB_ENV"
84+
85+
- name: Run Go parity tests
86+
run: go test ./...
87+
88+
- name: Compute migration score
89+
run: |
90+
go test -json ./... | tee "$RUNNER_TEMP/go-test-events.json" | go run .crane/scripts/score.go | tee "$RUNNER_TEMP/migration-score.json"
91+
python - "$RUNNER_TEMP/migration-score.json" <<'PY'
92+
import json
93+
import sys
94+
95+
with open(sys.argv[1], encoding="utf-8") as fh:
96+
score = json.load(fh)
97+
98+
print(json.dumps(score, indent=2, sort_keys=True))
99+
if score.get("migration_score") != 1.0:
100+
raise SystemExit("migration_score must be 1.0 for completion parity")
101+
PY
102+
103+
- name: Upload parity evidence
104+
if: always()
105+
uses: actions/upload-artifact@v4
106+
with:
107+
name: migration-parity-evidence
108+
path: |
109+
${{ runner.temp }}/go-test-events.json
110+
${{ runner.temp }}/migration-score.json
111+
if-no-files-found: ignore
112+
retention-days: 14
113+
114+
benchmarks:
115+
name: Migration Benchmarks
116+
needs: [parity]
117+
runs-on: ubuntu-24.04
118+
steps:
119+
- uses: actions/checkout@v4
120+
121+
- uses: actions/setup-python@v5
122+
with:
123+
python-version: ${{ env.PYTHON_VERSION }}
124+
125+
- uses: astral-sh/setup-uv@v6
126+
with:
127+
enable-cache: true
128+
129+
- uses: actions/setup-go@v5
130+
with:
131+
go-version-file: go.mod
132+
cache: true
133+
134+
- name: Install dependencies
135+
run: uv sync --extra dev
136+
137+
- name: Build Go CLI
138+
run: go build -o "$RUNNER_TEMP/apm-go" ./cmd/apm
139+
140+
- name: Run Python performance guards
141+
run: |
142+
uv run pytest tests/benchmarks/test_scaling_guards.py -v
143+
uv run pytest tests/benchmarks -v --tb=short -m benchmark
144+
145+
- name: Run Python-vs-Go CLI benchmark
146+
run: |
147+
python scripts/ci/migration_cli_benchmark.py \
148+
--python-bin "$GITHUB_WORKSPACE/.venv/bin/apm" \
149+
--go-bin "$RUNNER_TEMP/apm-go" \
150+
--json-out "$RUNNER_TEMP/migration-cli-benchmark.json" \
151+
--markdown-out "$RUNNER_TEMP/migration-cli-benchmark.md" \
152+
--max-ratio 5.0
153+
154+
- name: Add benchmark summary
155+
if: always()
156+
run: |
157+
if [ -f "$RUNNER_TEMP/migration-cli-benchmark.md" ]; then
158+
cat "$RUNNER_TEMP/migration-cli-benchmark.md" >> "$GITHUB_STEP_SUMMARY"
159+
fi
160+
161+
- name: Upload benchmark evidence
162+
if: always()
163+
uses: actions/upload-artifact@v4
164+
with:
165+
name: migration-benchmark-evidence
166+
path: |
167+
${{ runner.temp }}/migration-cli-benchmark.json
168+
${{ runner.temp }}/migration-cli-benchmark.md
169+
if-no-files-found: ignore
170+
retention-days: 14

0 commit comments

Comments
 (0)