Skip to content

Commit d6e277f

Browse files
committed
ci: restore basic and migration checks
1 parent f77d95e commit d6e277f

3 files changed

Lines changed: 409 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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: astral-sh/setup-uv@v6
25+
with:
26+
enable-cache: true
27+
28+
- name: Ruff lint
29+
run: uv run --extra dev ruff check src/ tests/
30+
31+
- name: Ruff format check
32+
run: uv run --extra dev ruff format --check src/ tests/
33+
34+
python-tests:
35+
name: Python Unit Tests
36+
runs-on: ubuntu-24.04
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- uses: actions/setup-python@v5
41+
with:
42+
python-version: ${{ env.PYTHON_VERSION }}
43+
44+
- uses: astral-sh/setup-uv@v6
45+
with:
46+
enable-cache: true
47+
48+
- name: Install dependencies
49+
run: uv sync --extra dev
50+
51+
- name: Run unit tests
52+
run: uv run pytest tests/unit tests/test_console.py -n auto --dist worksteal
53+
54+
go-tests:
55+
name: Go Tests
56+
runs-on: ubuntu-24.04
57+
steps:
58+
- uses: actions/checkout@v4
59+
60+
- uses: actions/setup-python@v5
61+
with:
62+
python-version: ${{ env.PYTHON_VERSION }}
63+
64+
- uses: astral-sh/setup-uv@v6
65+
with:
66+
enable-cache: true
67+
68+
- uses: actions/setup-go@v5
69+
if: hashFiles('go.mod') != ''
70+
with:
71+
go-version-file: go.mod
72+
cache: true
73+
74+
- name: Install Python reference CLI
75+
if: hashFiles('go.mod') != ''
76+
run: |
77+
uv sync --extra dev
78+
test -x "$GITHUB_WORKSPACE/.venv/bin/apm"
79+
echo "APM_PYTHON_BIN=$GITHUB_WORKSPACE/.venv/bin/apm" >> "$GITHUB_ENV"
80+
81+
- name: Run Go tests
82+
if: hashFiles('go.mod') != ''
83+
run: go test ./...
84+

.github/workflows/migration-ci.yml

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
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+
parity:
29+
name: Python-vs-Go Parity Gate
30+
runs-on: ubuntu-24.04
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- uses: actions/setup-python@v5
35+
with:
36+
python-version: ${{ env.PYTHON_VERSION }}
37+
38+
- uses: astral-sh/setup-uv@v6
39+
with:
40+
enable-cache: true
41+
42+
- uses: actions/setup-go@v5
43+
with:
44+
go-version-file: go.mod
45+
cache: true
46+
47+
- name: Install Python reference CLI
48+
run: |
49+
uv sync --extra dev
50+
test -x "$GITHUB_WORKSPACE/.venv/bin/apm"
51+
echo "APM_PYTHON_BIN=$GITHUB_WORKSPACE/.venv/bin/apm" >> "$GITHUB_ENV"
52+
53+
- name: Run Go parity tests
54+
run: go test ./...
55+
56+
- name: Compute migration score
57+
run: |
58+
go test -json ./... | tee "$RUNNER_TEMP/go-test-events.json" | go run .crane/scripts/score.go | tee "$RUNNER_TEMP/migration-score.json"
59+
python - "$RUNNER_TEMP/migration-score.json" <<'PY'
60+
import json
61+
import sys
62+
63+
with open(sys.argv[1], encoding="utf-8") as fh:
64+
score = json.load(fh)
65+
66+
print(json.dumps(score, indent=2, sort_keys=True))
67+
if score.get("migration_score") != 1.0:
68+
raise SystemExit("migration_score must be 1.0 for completion parity")
69+
PY
70+
71+
- name: Upload parity evidence
72+
if: always()
73+
uses: actions/upload-artifact@v4
74+
with:
75+
name: migration-parity-evidence
76+
path: |
77+
${{ runner.temp }}/go-test-events.json
78+
${{ runner.temp }}/migration-score.json
79+
if-no-files-found: ignore
80+
retention-days: 14
81+
82+
benchmarks:
83+
name: Migration Benchmarks
84+
needs: [parity]
85+
runs-on: ubuntu-24.04
86+
steps:
87+
- uses: actions/checkout@v4
88+
89+
- uses: actions/setup-python@v5
90+
with:
91+
python-version: ${{ env.PYTHON_VERSION }}
92+
93+
- uses: astral-sh/setup-uv@v6
94+
with:
95+
enable-cache: true
96+
97+
- uses: actions/setup-go@v5
98+
with:
99+
go-version-file: go.mod
100+
cache: true
101+
102+
- name: Install dependencies
103+
run: uv sync --extra dev
104+
105+
- name: Build Go CLI
106+
run: go build -o "$RUNNER_TEMP/apm-go" ./cmd/apm
107+
108+
- name: Run Python performance guards
109+
run: |
110+
uv run pytest tests/benchmarks/test_scaling_guards.py -v
111+
uv run pytest tests/benchmarks -v --tb=short -m benchmark
112+
113+
- name: Run Python-vs-Go CLI benchmark
114+
run: |
115+
python scripts/ci/migration_cli_benchmark.py \
116+
--python-bin "$GITHUB_WORKSPACE/.venv/bin/apm" \
117+
--go-bin "$RUNNER_TEMP/apm-go" \
118+
--json-out "$RUNNER_TEMP/migration-cli-benchmark.json" \
119+
--markdown-out "$RUNNER_TEMP/migration-cli-benchmark.md" \
120+
--max-ratio 5.0
121+
122+
- name: Add benchmark summary
123+
if: always()
124+
run: |
125+
if [ -f "$RUNNER_TEMP/migration-cli-benchmark.md" ]; then
126+
cat "$RUNNER_TEMP/migration-cli-benchmark.md" >> "$GITHUB_STEP_SUMMARY"
127+
fi
128+
129+
- name: Upload benchmark evidence
130+
if: always()
131+
uses: actions/upload-artifact@v4
132+
with:
133+
name: migration-benchmark-evidence
134+
path: |
135+
${{ runner.temp }}/migration-cli-benchmark.json
136+
${{ runner.temp }}/migration-cli-benchmark.md
137+
if-no-files-found: ignore
138+
retention-days: 14

0 commit comments

Comments
 (0)