-
Notifications
You must be signed in to change notification settings - Fork 0
ci(kai-ci): make the pin job re-runnable #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -271,6 +271,7 @@ jobs: | |
| token: ${{ steps.token.outputs.token }} | ||
|
|
||
| - name: Bump the pinned digest | ||
| id: bump | ||
| env: | ||
| DIGEST: ${{ needs.build.outputs.digest }} | ||
| PROVENANCE: ${{ needs.build.outputs.provenance }} | ||
|
|
@@ -280,6 +281,23 @@ jobs: | |
| set -euo pipefail | ||
| NEW="${IMAGE}@${DIGEST}" | ||
| BR="kai-ci/pin-${DIGEST:7:12}" | ||
| echo "branch=$BR" >> "$GITHUB_OUTPUT" | ||
|
|
||
| # RE-RUNNABLE. The branch name is derived from the digest, so a re-run | ||
| # of the same build computes the same name — and the first attempt may | ||
| # already have pushed it and then failed later (which is exactly how | ||
| # this was found: attempt 1 pushed the branch and died opening the PR, | ||
| # attempt 2 rebuilt an identical commit and was rejected non-fast- | ||
| # forward). Same digest means the same edit, so an existing branch is | ||
| # already the right branch: reuse it and move on to the PR. | ||
| # | ||
| # Not a force-push. Overwriting a branch someone may have reviewed, to | ||
| # replace it with identical content, is all cost and no benefit. | ||
| if git ls-remote --exit-code --heads origin "$BR" >/dev/null 2>&1; then | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the reuse early-exit trusts the pre-existing remote branch's content without re-deriving it, so a same-digest re-run after |
||
| echo "$BR already exists — an earlier attempt pushed it; reusing" | ||
| exit 0 | ||
| fi | ||
|
Comment on lines
+296
to
+299
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a later dispatch produces the same digest with a different Prompt To Fix With AIThis is a comment left during a code review.
Path: .github/workflows/build-kai-ci.yml
Line: 296-299
Comment:
**Digest-only reuse drops pin changes**
When a later dispatch produces the same digest with a different `pin` selection, this branch-existence check skips the new edit and then reuses the existing PR, causing requested targets such as `defaultReviewImage` to remain stale.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly. |
||
|
|
||
| git config user.name "kai-ci" | ||
| git config user.email "noreply@kaicontext.com" | ||
| git checkout -b "$BR" | ||
|
|
@@ -322,8 +340,19 @@ jobs: | |
| PIN: ${{ inputs.pin }} | ||
| run: | | ||
| set -euo pipefail | ||
| BR="kai-ci/pin-${DIGEST:7:12}" | ||
|
|
||
| # Same idempotency question, other end: a re-run whose branch already | ||
| # carries a PR must not fail trying to open a second one. | ||
| EXISTING="$(gh pr list --repo kaicontext/kai-server --head "$BR" \ | ||
| --state open --json number --jq '.[0].number // empty')" | ||
| if [ -n "$EXISTING" ]; then | ||
| echo "PR #$EXISTING already open for $BR — nothing to do" | ||
| exit 0 | ||
| fi | ||
|
|
||
| gh pr create --repo kaicontext/kai-server \ | ||
| --head "kai-ci/pin-${DIGEST:7:12}" --base main \ | ||
| --head "$BR" --base main \ | ||
| --title "build(kai-ci): pin the $PIN image to ${DIGEST:7:12}" \ | ||
| --body "$(cat <<EOF | ||
| A new \`kai-ci\` image, built from known refs by [run ${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}). | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id: bumpand thebranch=$BRoutput are never read anywhere, and the branch name is recomputed independently in the PR step, so the two can silently drift.