Skip to content
Open
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
4 changes: 2 additions & 2 deletions site/static/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ esac
# Get latest release version via GitHub redirect (avoids api.github.com rate limits)
echo "Fetching latest release information..."
VERSION=$(curl -fsSL -o /dev/null -w "%{url_effective}" "https://github.com/${REPO}/releases/latest" | sed 's|.*/||' || true)
if [ -z "$VERSION" ] || [ "$VERSION" = "releases" ]; then
if [ -z "$VERSION" ] || [ "$VERSION" = "releases" ] || [ "$VERSION" = "latest" ]; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Section 3: Test coverage must follow the pyramid

According to Rule 3 of Section 3, any bug fix must be accompanied by a regression test at the lowest adequate layer. Since this PR fixes a bug in the install.sh script where an unresolved redirect results in a failed download of a malformed URL, please add a regression test.

Since this is a bash script, the appropriate layer is an E2E test using Bats (e.g., in tests/e2e/). The test should stub curl to simulate an unresolved redirect (returning latest or failing) and verify that:

  1. The script correctly falls back to the GitHub API if that succeeds.
  2. The script fails with the clear error message Error: Could not find the latest release. if the API fallback also fails, rather than attempting to download from a malformed URL.
References
  1. Section 3, Rule 3: Every behavior change ships with a test at the lowest adequate layer. Flag missing regression tests for bug fixes. A PR whose description says 'fix', 'bypass', 'canonicalize', 'race', 'leak' or similar must add a test that fails on the parent commit. (link)

VERSION=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases?per_page=1" | grep '"tag_name":' | head -n 1 | sed -E 's/.*"([^"]+)".*/\1/' || true)
fi

if [ -z "$VERSION" ] || [ "$VERSION" = "releases" ]; then
if [ -z "$VERSION" ] || [ "$VERSION" = "releases" ] || [ "$VERSION" = "latest" ]; then
echo "Error: Could not find the latest release."
exit 1
fi
Expand Down
Loading