Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: CI

on:
pull_request:
branches: [main]
merge_group:
branches: [main]
types: [checks_requested]
workflow_dispatch:

permissions:
contents: read

env:
PYTHON_VERSION: "3.12"

jobs:
lint:
name: Lint
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- uses: astral-sh/setup-uv@v6
with:
enable-cache: true

- name: Ruff lint
run: uv run --extra dev ruff check src/ tests/

- name: Ruff format check
run: uv run --extra dev ruff format --check src/ tests/

python-tests:
name: Python Unit Tests
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- uses: astral-sh/setup-uv@v6
with:
enable-cache: true

- name: Install dependencies
run: uv sync --extra dev

- name: Run unit tests
run: uv run pytest tests/unit tests/test_console.py -n auto --dist worksteal

go-tests:
name: Go Tests
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- uses: astral-sh/setup-uv@v6
with:
enable-cache: true

- uses: actions/setup-go@v5
if: hashFiles('go.mod') != ''
with:
go-version-file: go.mod
cache: true

- name: Install Python reference CLI
if: hashFiles('go.mod') != ''
run: |
uv sync --extra dev
test -x "$GITHUB_WORKSPACE/.venv/bin/apm"
echo "APM_PYTHON_BIN=$GITHUB_WORKSPACE/.venv/bin/apm" >> "$GITHUB_ENV"

- name: Run Go tests
if: hashFiles('go.mod') != ''
run: go test ./...
170 changes: 170 additions & 0 deletions .github/workflows/migration-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
name: Migration Parity and Benchmarks

on:
pull_request:
branches: [main]
paths:
- ".crane/**"
- ".github/workflows/migration-ci.yml"
- "cmd/**"
- "internal/**"
- "pkg/**"
- "go.mod"
- "go.sum"
- "pyproject.toml"
- "scripts/ci/**"
- "src/**"
- "tests/benchmarks/**"
- "tests/unit/test_crane_score.py"
workflow_dispatch:

permissions:
contents: read

env:
PYTHON_VERSION: "3.12"

jobs:
detect-changes:
name: Detect Migration Changes
runs-on: ubuntu-24.04
outputs:
should-run: ${{ steps.filter.outputs.should-run }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Check changed paths
id: filter
shell: bash
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "should-run=true" >> "$GITHUB_OUTPUT"
exit 0
fi

git diff --name-only \
"${{ github.event.pull_request.base.sha }}" \
"${{ github.event.pull_request.head.sha }}" \
| tee "$RUNNER_TEMP/changed-files.txt"

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
echo "should-run=true" >> "$GITHUB_OUTPUT"
else
echo "should-run=false" >> "$GITHUB_OUTPUT"
fi

parity:
name: Python-vs-Go Parity Gate
needs: [detect-changes]
if: needs.detect-changes.outputs.should-run == 'true'
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- uses: astral-sh/setup-uv@v6
with:
enable-cache: true

- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true

- name: Install Python reference CLI
run: |
uv sync --extra dev
test -x "$GITHUB_WORKSPACE/.venv/bin/apm"
echo "APM_PYTHON_BIN=$GITHUB_WORKSPACE/.venv/bin/apm" >> "$GITHUB_ENV"

- name: Run Go parity tests
run: go test ./...

- name: Compute migration score
run: |
go test -json ./... | tee "$RUNNER_TEMP/go-test-events.json" | go run .crane/scripts/score.go | tee "$RUNNER_TEMP/migration-score.json"
python - "$RUNNER_TEMP/migration-score.json" <<'PY'
import json
import sys

with open(sys.argv[1], encoding="utf-8") as fh:
score = json.load(fh)

print(json.dumps(score, indent=2, sort_keys=True))
if score.get("migration_score") != 1.0:
raise SystemExit("migration_score must be 1.0 for completion parity")
PY

- name: Upload parity evidence
if: always()
uses: actions/upload-artifact@v4
with:
name: migration-parity-evidence
path: |
${{ runner.temp }}/go-test-events.json
${{ runner.temp }}/migration-score.json
if-no-files-found: ignore
retention-days: 14

benchmarks:
name: Migration Benchmarks
needs: [parity]
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- uses: astral-sh/setup-uv@v6
with:
enable-cache: true

- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true

- name: Install dependencies
run: uv sync --extra dev

- name: Build Go CLI
run: go build -o "$RUNNER_TEMP/apm-go" ./cmd/apm

- name: Run Python performance guards
run: |
uv run pytest tests/benchmarks/test_scaling_guards.py -v
uv run pytest tests/benchmarks -v --tb=short -m benchmark

- name: Run Python-vs-Go CLI benchmark
run: |
python scripts/ci/migration_cli_benchmark.py \
--python-bin "$GITHUB_WORKSPACE/.venv/bin/apm" \
--go-bin "$RUNNER_TEMP/apm-go" \
--json-out "$RUNNER_TEMP/migration-cli-benchmark.json" \
--markdown-out "$RUNNER_TEMP/migration-cli-benchmark.md" \
--max-ratio 5.0

- name: Add benchmark summary
if: always()
run: |
if [ -f "$RUNNER_TEMP/migration-cli-benchmark.md" ]; then
cat "$RUNNER_TEMP/migration-cli-benchmark.md" >> "$GITHUB_STEP_SUMMARY"
fi

- name: Upload benchmark evidence
if: always()
uses: actions/upload-artifact@v4
with:
name: migration-benchmark-evidence
path: |
${{ runner.temp }}/migration-cli-benchmark.json
${{ runner.temp }}/migration-cli-benchmark.md
if-no-files-found: ignore
retention-days: 14
Loading
Loading