Skip to content

Commit 2598a20

Browse files
tclemCopilot
andcommitted
Reject stale no-op dependency artifacts
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 8cab084 commit 2598a20

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

.github/scripts/apply-dependency-update

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ case "$ecosystem" in
3030
;;
3131
esac
3232

33+
for path in state base.sha; do
34+
if [[ ! -f "$bundle_dir/$path" ]]; then
35+
echo "missing artifact file: $path" >&2
36+
exit 1
37+
fi
38+
done
39+
40+
expected_base=$(tr -d '[:space:]' < "$bundle_dir/base.sha")
41+
.github/scripts/verify-dependency-base "$expected_base" >/dev/null
42+
3343
state=$(tr -d '[:space:]' < "$bundle_dir/state")
3444
case "$state" in
3545
noop)
@@ -43,16 +53,13 @@ case "$state" in
4353
;;
4454
esac
4555

46-
for path in base.sha deterministic.patch final.patch title.txt body.md; do
56+
for path in deterministic.patch final.patch title.txt body.md; do
4757
if [[ ! -f "$bundle_dir/$path" ]]; then
4858
echo "missing artifact file: $path" >&2
4959
exit 1
5060
fi
5161
done
5262

53-
expected_base=$(tr -d '[:space:]' < "$bundle_dir/base.sha")
54-
.github/scripts/verify-dependency-base "$expected_base" >/dev/null
55-
5663
tree_from_patch() {
5764
local patch=$1
5865
local index

.github/scripts/test-dependency-automation

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,22 @@ if (cd "$git_fixture/work" && "$verify_base" "${main_oid}0") >/dev/null 2>&1; th
6969
exit 1
7070
fi
7171

72+
stale_noop=$test_root/stale-noop
73+
mkdir -p "$stale_noop" "$git_fixture/work/.github/scripts"
74+
printf 'noop\n' > "$stale_noop/state"
75+
printf '%s\n' "$main_oid" > "$stale_noop/base.sha"
76+
cp "$apply" "$verify_base" "$git_fixture/work/.github/scripts/"
77+
printf 'advanced\n' >> "$git_fixture/work/base"
78+
git -C "$git_fixture/work" commit -am advanced >/dev/null
79+
git -C "$git_fixture/work" push origin main >/dev/null
80+
if (cd "$git_fixture/work" && .github/scripts/apply-dependency-update npm "$stale_noop") \
81+
>"$test_root/stale-noop.log" 2>&1; then
82+
echo "stale no-op artifact was accepted after origin/main advanced" >&2
83+
exit 1
84+
fi
85+
grep -Fq 'dependency artifact was generated from a different origin/main' \
86+
"$test_root/stale-noop.log"
87+
7288
npm_fixture=$test_root/npm
7389
mkdir -p "$npm_fixture"
7490
cat > "$npm_fixture/package.json" <<'EOF'

0 commit comments

Comments
 (0)