Skip to content

Commit 67e803d

Browse files
ivanmilevtuesclaude
andcommitted
feat: name each preview artifact for its pull request and head
The app attributes an artifact to a pull request per run, and every preview shares the setup PR's run, so the name carries the pull request and the head it reviewed, as the legacy codeboarding-pr-<pr>-<head> names did. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 348515a commit 67e803d

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

‎action.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ runs:
725725
# where a new user's open pull requests get their first review: the ones the app listed
726726
# in the setup PR's description, each applied to the commit this run just analysed and
727727
# analysed incrementally from it (see review-preview-pr.sh). Nothing is posted on them.
728-
# The app finds each as codeboarding-preview-<run>-<attempt>-pr<number> plus its metadata.
728+
# The app finds each as codeboarding-preview-<run>-<attempt>-pr<number>-<head sha>.
729729
# Not codeboarding-review-<run>-...: the app takes the newest artifact with that prefix as
730730
# the setup PR's own review, so a preview named that way would replace the setup PR's map.
731731
# All best effort: the setup PR's map is already uploaded and must not fail because of them.
@@ -774,7 +774,7 @@ runs:
774774
continue-on-error: true
775775
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
776776
with:
777-
name: codeboarding-preview-${{ github.run_id }}-${{ github.run_attempt }}-pr${{ steps.preview_1.outputs.pr_number }}
777+
name: codeboarding-preview-${{ github.run_id }}-${{ github.run_attempt }}-pr${{ steps.preview_1.outputs.pr_number }}-${{ steps.preview_1.outputs.head_sha }}
778778
path: ${{ steps.preview_1.outputs.artifact_dir }}
779779
if-no-files-found: error
780780
retention-days: 14
@@ -829,7 +829,7 @@ runs:
829829
continue-on-error: true
830830
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
831831
with:
832-
name: codeboarding-preview-${{ github.run_id }}-${{ github.run_attempt }}-pr${{ steps.preview_2.outputs.pr_number }}
832+
name: codeboarding-preview-${{ github.run_id }}-${{ github.run_attempt }}-pr${{ steps.preview_2.outputs.pr_number }}-${{ steps.preview_2.outputs.head_sha }}
833833
path: ${{ steps.preview_2.outputs.artifact_dir }}
834834
if-no-files-found: error
835835
retention-days: 14
@@ -863,7 +863,7 @@ runs:
863863
continue-on-error: true
864864
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
865865
with:
866-
name: codeboarding-preview-${{ github.run_id }}-${{ github.run_attempt }}-pr${{ steps.preview_3.outputs.pr_number }}
866+
name: codeboarding-preview-${{ github.run_id }}-${{ github.run_attempt }}-pr${{ steps.preview_3.outputs.pr_number }}-${{ steps.preview_3.outputs.head_sha }}
867867
path: ${{ steps.preview_3.outputs.artifact_dir }}
868868
if-no-files-found: error
869869
retention-days: 14

‎scripts/action/review-preview-pr.sh‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# reported as its changes. A pull request that does not apply cleanly there is skipped.
1010
#
1111
# Usage: review-preview-pr.sh <n>. Outputs pr_number=, title= and artifact_dir= when a
12-
# preview was built; nothing when there is no n-th entry or it was skipped.
12+
# preview was built, plus head_sha=; nothing when there is no n-th entry or it was skipped.
1313
set -euo pipefail
1414
# shellcheck source=scripts/action/analysis-state.sh
1515
source "$(dirname "$0")/analysis-state.sh"
@@ -58,4 +58,4 @@ BASE_ARTIFACT_NAME="$(jq -r '.base_artifact // ""' "$review_meta")" \
5858
PR_NUMBER="$pr" SEED_SOURCE=base CHAIN_DEPTH=1 ANALYSED_FILES_CHANGED="$analysed" \
5959
BASIS=preview SETUP_PR="$SETUP_PR" \
6060
"$ACTION_PATH/scripts/action/build-review-artifact.sh"
61-
printf 'pr_number=%s\ntitle=%s\n' "$pr" "${title//$'\n'/ }" >> "$GITHUB_OUTPUT"
61+
printf 'pr_number=%s\nhead_sha=%s\ntitle=%s\n' "$pr" "$head_sha" "${title//$'\n'/ }" >> "$GITHUB_OUTPUT"

‎tests/test_setup_previews.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ def _run(self, pr_head: str | None = None) -> dict[str, str]:
186186
def test_the_pull_request_is_applied_to_the_analysed_commit(self) -> None:
187187
out = self._run()
188188
self.assertEqual(out["pr_number"], "412")
189+
self.assertEqual(out["head_sha"], self.pr_head, "the artifact name carries it, so the app needs no download")
189190
seen = (self.preview_dir / "state-1" / "seen-files").read_text().split()
190191
# Z's file is there because the base is Z; the PR's file because it was applied; nothing else.
191192
self.assertIn("ledger.txt", seen)

0 commit comments

Comments
 (0)