Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion scripts/compare-actions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ OUTDATED_COUNT=0
: >actions-outdated.txt

while IFS='|' read -r action current_sha current_tag latest_sha latest_tag; do
if [[ "$current_sha" != "$latest_sha" ]]; then
# Flag outdated on SHA mismatch OR on tag mismatch when SHAs coincide
# (e.g. pin comment says "# v1" but latest release is "v1.0.0" — same
# commit today because v1 floats, but the pin label is stale; refresh
# it to the exact release name so consumers see what version they're on).
if [[ "$current_sha" != "$latest_sha" ]] ||
{ [[ -n "$current_tag" ]] && [[ -n "$latest_tag" ]] && [[ "$current_tag" != "$latest_tag" ]]; }; then
echo " Outdated: ${action} ${current_tag:-unknown} -> ${latest_tag}"
echo "${action}|${current_sha}|${current_tag}|${latest_sha}|${latest_tag}" >>actions-outdated.txt
((OUTDATED_COUNT++)) || true
Expand Down
37 changes: 37 additions & 0 deletions tests/compare-actions.bats
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,40 @@ EOF
[[ "$output" != *"actions/setup-node"* ]]
assert_output_contains "has_outdated=true"
}

@test "compare-actions: flags outdated when SHAs match but tags differ (floating pin behind exact release)" {
cat > actions-latest.txt <<EOF
nerdalytics/check-action-versions|same-sha|v1|same-sha|v1.0.0
EOF

run bash "${SCRIPT_DIR}/compare-actions.sh"
[ "$status" -eq 0 ]
run cat actions-outdated.txt
[[ "$output" == *"nerdalytics/check-action-versions|same-sha|v1|same-sha|v1.0.0"* ]]
assert_output_contains "has_outdated=true"
}

@test "compare-actions: up-to-date when both SHAs and tags match exactly" {
cat > actions-latest.txt <<EOF
actions/checkout|same-sha|v5.0.0|same-sha|v5.0.0
EOF

run bash "${SCRIPT_DIR}/compare-actions.sh"
[ "$status" -eq 0 ]
run cat actions-outdated.txt
[ -z "$output" ]
assert_output_contains "has_outdated=false"
}

@test "compare-actions: up-to-date when SHAs match and current_tag is empty" {
# No comment in the pin -> current_tag is empty. Only SHA comparison matters.
cat > actions-latest.txt <<EOF
actions/checkout|same-sha||same-sha|v5.0.0
EOF

run bash "${SCRIPT_DIR}/compare-actions.sh"
[ "$status" -eq 0 ]
run cat actions-outdated.txt
[ -z "$output" ]
assert_output_contains "has_outdated=false"
}