|
| 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