|
| 1 | +name: acpx canary |
| 2 | + |
| 3 | +# Tests the newest acpx against the contract suite and proposes a pin bump. |
| 4 | +# Only `contract` executes acpx, so it gets no write permissions and no persisted |
| 5 | +# token; the jobs that write to the repo never run acpx. |
| 6 | + |
| 7 | +on: |
| 8 | + schedule: |
| 9 | + - cron: "17 9 * * 1" |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +permissions: {} |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: acpx-canary |
| 16 | + cancel-in-progress: false |
| 17 | + |
| 18 | +env: |
| 19 | + BUMP_BRANCH: ci/acpx-bump |
| 20 | + ISSUE_TITLE: "acpx canary: newest acpx fails the contract suite" |
| 21 | + |
| 22 | +jobs: |
| 23 | + resolve: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + timeout-minutes: 5 |
| 26 | + permissions: |
| 27 | + contents: read |
| 28 | + outputs: |
| 29 | + latest: ${{ steps.versions.outputs.latest }} |
| 30 | + pin: ${{ steps.versions.outputs.pin }} |
| 31 | + |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v6 |
| 34 | + with: |
| 35 | + persist-credentials: false |
| 36 | + |
| 37 | + # A concrete version, never `latest`: the suite asserts `acpx --version` equals it. |
| 38 | + - name: Resolve newest acpx and the current pin |
| 39 | + id: versions |
| 40 | + run: | |
| 41 | + latest=$(npm view acpx version) |
| 42 | + pin=$(sed -nE 's/^export const ACPX_PIN = "([0-9]+\.[0-9]+\.[0-9]+)"$/\1/p' tests/helpers/acpx-pin.ts) |
| 43 | + for v in "$latest" "$pin"; do |
| 44 | + [[ "$v" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "::error::unexpected version string: '$v'"; exit 1; } |
| 45 | + done |
| 46 | + echo "latest=$latest" >> "$GITHUB_OUTPUT" |
| 47 | + echo "pin=$pin" >> "$GITHUB_OUTPUT" |
| 48 | + if [ "$latest" = "$pin" ]; then |
| 49 | + echo "acpx $pin is already the newest release; nothing to do." >> "$GITHUB_STEP_SUMMARY" |
| 50 | + fi |
| 51 | +
|
| 52 | + contract: |
| 53 | + needs: resolve |
| 54 | + if: needs.resolve.outputs.latest != needs.resolve.outputs.pin |
| 55 | + runs-on: ubuntu-latest |
| 56 | + timeout-minutes: 10 |
| 57 | + permissions: |
| 58 | + contents: read |
| 59 | + |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@v6 |
| 62 | + with: |
| 63 | + persist-credentials: false |
| 64 | + |
| 65 | + # acpx requires Node >= 22.13. |
| 66 | + - name: Setup Node |
| 67 | + uses: actions/setup-node@v6 |
| 68 | + with: |
| 69 | + node-version: "22" |
| 70 | + |
| 71 | + - name: Setup Bun |
| 72 | + uses: oven-sh/setup-bun@v2 |
| 73 | + with: |
| 74 | + bun-version: latest |
| 75 | + |
| 76 | + - name: Install dependencies |
| 77 | + run: bun install |
| 78 | + |
| 79 | + - name: acpx contract suite against acpx ${{ needs.resolve.outputs.latest }} |
| 80 | + shell: bash |
| 81 | + env: |
| 82 | + ACPX_VERSION: ${{ needs.resolve.outputs.latest }} |
| 83 | + run: bun run test:acpx-contract 2>&1 | tee "$RUNNER_TEMP/contract.log" |
| 84 | + |
| 85 | + - name: Keep the contract log |
| 86 | + if: always() |
| 87 | + uses: actions/upload-artifact@v4 |
| 88 | + with: |
| 89 | + name: acpx-contract-log |
| 90 | + path: ${{ runner.temp }}/contract.log |
| 91 | + if-no-files-found: ignore |
| 92 | + |
| 93 | + propose: |
| 94 | + needs: [resolve, contract] |
| 95 | + runs-on: ubuntu-latest |
| 96 | + timeout-minutes: 10 |
| 97 | + permissions: |
| 98 | + contents: write |
| 99 | + pull-requests: write |
| 100 | + actions: write |
| 101 | + |
| 102 | + steps: |
| 103 | + - uses: actions/checkout@v6 |
| 104 | + |
| 105 | + - name: Setup Bun |
| 106 | + uses: oven-sh/setup-bun@v2 |
| 107 | + with: |
| 108 | + bun-version: latest |
| 109 | + |
| 110 | + # The registry is read as text by the bump script; nothing from the package runs. |
| 111 | + - name: Fetch the acpx package without running it |
| 112 | + env: |
| 113 | + VERSION: ${{ needs.resolve.outputs.latest }} |
| 114 | + run: | |
| 115 | + mkdir -p "$RUNNER_TEMP/acpx" |
| 116 | + npm pack "acpx@$VERSION" --ignore-scripts --pack-destination "$RUNNER_TEMP/acpx" |
| 117 | + tar -xzf "$RUNNER_TEMP/acpx/acpx-$VERSION.tgz" -C "$RUNNER_TEMP/acpx" |
| 118 | +
|
| 119 | + - name: Bump the pin |
| 120 | + env: |
| 121 | + VERSION: ${{ needs.resolve.outputs.latest }} |
| 122 | + run: | |
| 123 | + bun scripts/bump-acpx-pin.ts --version "$VERSION" --from-package "$RUNNER_TEMP/acpx/package" > "$RUNNER_TEMP/bump.md" |
| 124 | + cat "$RUNNER_TEMP/bump.md" |
| 125 | +
|
| 126 | + - name: Open or update the bump PR |
| 127 | + env: |
| 128 | + GH_TOKEN: ${{ github.token }} |
| 129 | + VERSION: ${{ needs.resolve.outputs.latest }} |
| 130 | + run: | |
| 131 | + title="fix(cross-model): bump acpx to $VERSION" |
| 132 | + git config user.name "github-actions[bot]" |
| 133 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 134 | + git switch -C "$BUMP_BRANCH" |
| 135 | + git diff --quiet && { echo "::error::the bump script changed no files"; exit 1; } |
| 136 | + git commit -am "$title" |
| 137 | + git push --force origin "$BUMP_BRANCH" |
| 138 | + { |
| 139 | + echo "Weekly acpx canary: acpx $VERSION passed the contract suite (run $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID)." |
| 140 | + echo |
| 141 | + cat "$RUNNER_TEMP/bump.md" |
| 142 | + echo |
| 143 | + echo "Before merging, run a local live smoke for each adapter whose spec changed above: the contract suite drives a stub agent, not the real adapters." |
| 144 | + echo |
| 145 | + echo "CI was dispatched on \`$BUMP_BRANCH\` because a PR opened with GITHUB_TOKEN does not trigger workflows." |
| 146 | + echo |
| 147 | + # --body-file bypasses the PR template, so its required sections are written here. |
| 148 | + echo "## Security Disclosure" |
| 149 | + echo |
| 150 | + echo "Changes which acpx version, and which codex and claude adapter version ranges, the cross-model peers fetch from npm and run on users' machines. The new version passed the contract suite against a stub agent only; review its release notes before merging." |
| 151 | + echo |
| 152 | + echo "## Agent Disclosure" |
| 153 | + echo "- **Model:** No agent used. Generated by the acpx canary workflow." |
| 154 | + } > "$RUNNER_TEMP/body.md" |
| 155 | + pr=$(gh pr list --head "$BUMP_BRANCH" --state open --json number --jq '.[0].number') |
| 156 | + if [ -n "$pr" ]; then |
| 157 | + gh pr edit "$pr" --title "$title" --body-file "$RUNNER_TEMP/body.md" |
| 158 | + else |
| 159 | + gh pr create --head "$BUMP_BRANCH" --title "$title" --body-file "$RUNNER_TEMP/body.md" |
| 160 | + fi |
| 161 | +
|
| 162 | + - name: Run CI on the bump branch |
| 163 | + env: |
| 164 | + GH_TOKEN: ${{ github.token }} |
| 165 | + run: gh workflow run ci.yml --ref "$BUMP_BRANCH" |
| 166 | + |
| 167 | + report: |
| 168 | + needs: [resolve, contract] |
| 169 | + if: failure() && needs.contract.result == 'failure' |
| 170 | + runs-on: ubuntu-latest |
| 171 | + timeout-minutes: 5 |
| 172 | + permissions: |
| 173 | + issues: write |
| 174 | + |
| 175 | + steps: |
| 176 | + - name: Fetch the contract log |
| 177 | + uses: actions/download-artifact@v4 |
| 178 | + continue-on-error: true |
| 179 | + with: |
| 180 | + name: acpx-contract-log |
| 181 | + path: ${{ runner.temp }}/log |
| 182 | + |
| 183 | + # The log came from a job that ran untrusted code; it is only quoted, never executed. |
| 184 | + - name: Open or update the tracking issue |
| 185 | + env: |
| 186 | + GH_TOKEN: ${{ github.token }} |
| 187 | + GH_REPO: ${{ github.repository }} |
| 188 | + VERSION: ${{ needs.resolve.outputs.latest }} |
| 189 | + PIN: ${{ needs.resolve.outputs.pin }} |
| 190 | + run: | |
| 191 | + failures=$(grep -E '^\(fail\)' "$RUNNER_TEMP/log/contract.log" 2>/dev/null || true) |
| 192 | + { |
| 193 | + echo "acpx $VERSION failed the contract suite (pin stays at $PIN). Run: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" |
| 194 | + echo |
| 195 | + echo "Failing scenarios:" |
| 196 | + echo |
| 197 | + echo '```' |
| 198 | + echo "${failures:-none recorded; see the run log}" |
| 199 | + echo '```' |
| 200 | + } > "$RUNNER_TEMP/body.md" |
| 201 | + issue=$(gh issue list --state open --search "in:title \"$ISSUE_TITLE\"" --json number,title \ |
| 202 | + --jq "map(select(.title == \"$ISSUE_TITLE\")) | .[0].number // empty") |
| 203 | + if [ -n "$issue" ]; then |
| 204 | + gh issue comment "$issue" --body-file "$RUNNER_TEMP/body.md" |
| 205 | + else |
| 206 | + gh issue create --title "$ISSUE_TITLE" --body-file "$RUNNER_TEMP/body.md" |
| 207 | + fi |
0 commit comments