diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f06b551..3de7a7b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -75,3 +75,19 @@ jobs: echo "Bump CORE_VERSION in src/template.rs and let the starter job prove it still boots." exit 1 fi + + # install.sh has had a test since the installer landed, and no workflow ever + # ran it. It exercises the script against a file:// fixture — no network — and + # checks both halves that matter: a good archive installs, and a bad checksum + # aborts without leaving a binary behind. + installer: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-14] + steps: + - uses: actions/checkout@v4 + - run: shellcheck install.sh test_install.sh + if: matrix.os == 'ubuntu-latest' + - run: ./test_install.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d74412f..aceb473 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -78,6 +78,11 @@ jobs: - name: Upload to release uses: softprops/action-gh-release@v2 with: + # A tag with a hyphen is a prerelease (26.9.0-beta.1). Unflagged, it + # would answer /releases/latest — which is what install.sh resolves + # with no MATCHA_VERSION — so the first stable release would be + # displaced by the next beta published after it. + prerelease: ${{ contains(github.ref_name, '-') }} files: | matcha-${{ matrix.target }}.tar.gz matcha-${{ matrix.target }}.tar.gz.sha256 diff --git a/CHANGELOG.md b/CHANGELOG.md index 61b04c4..29b9df3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -104,6 +104,24 @@ is pinned to is `CORE_VERSION` in `src/template.rs`, and each entry below says w was `TS2868: Cannot find name 'Bun'` — meaning `tsc --noEmit`, and therefore `matcha create --check`, failed on every bun project the CLI has ever scaffolded. +- **`install.sh` resolves `latest` without the release API.** The API is rate-limited to + 60 requests an hour per IP unauthenticated — an office behind one NAT or a CI runner + burns through it — and a throttled response carries no `tag_name`, so the installer + failed with "could not resolve latest release tag" and no hint of the cause. It now + follows the `/releases/latest` redirect, which has no such limit and which Gitea + implements the same way, keeping the API as the fallback for the wget path. The error + that remains names the rate limit and points at `MATCHA_VERSION`. + +- **A beta release is flagged as a prerelease.** Nothing set the flag, so every beta + answered `/releases/latest` — which is what `install.sh` resolves when no + `MATCHA_VERSION` is given. Harmless while every release is a beta, and wrong the moment + a stable one exists: the next beta published after it would displace it for everyone + installing with the default. + +- **CI runs `test_install.sh`.** It has existed since the installer landed and no workflow + ever ran it. It now runs on Linux and macOS, with `shellcheck` alongside, and covers a + third case: an unresolvable `latest` must explain itself and install nothing. + - **`MIT` is a file, not just a manifest field.** `Cargo.toml` declared `license = "MIT"` and the published crate carried no license text. Added along with the `DCO` the README has been requiring sign-off against, and a `CONTRIBUTING.md` saying how. diff --git a/README.md b/README.md index 27d2b80..dec3632 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,8 @@ the alias can go once that is fixed. ```bash cargo test # unit + CLI integration scripts/starter-smoke.sh node # scaffold, install, type-check, boot, introspect -scripts/starter-smoke.sh deno # (also bun) — needs that runtime installed +scripts/starter-smoke.sh deno # (also bun, edge) — needs that runtime installed +./test_install.sh # install.sh against a file:// fixture, no network ``` `starter-smoke.sh` is the check that `cargo test` cannot be: `cargo test` proves diff --git a/install.sh b/install.sh index b69bf33..995155b 100755 --- a/install.sh +++ b/install.sh @@ -51,11 +51,30 @@ case "$os" in *) err "unsupported OS: $os — try: cargo install --git $REPO_BASE" ;; esac +# Resolving "latest" prefers the /releases/latest redirect over the release API. +# The API is rate-limited to 60 requests an hour per IP unauthenticated, which an +# office behind one NAT or a CI runner burns through — and when it trips, the +# response carries no tag_name, so the old code failed with "could not resolve +# latest release tag" and no hint of why. The redirect has no such limit and +# Gitea implements it the same way. The API stays as the fallback, since that is +# the path wget can follow without parsing headers. +resolve_latest() { + if command -v curl >/dev/null 2>&1; then + effective=$(curl -fsSLI -o /dev/null -w '%{url_effective}' "$REPO_BASE/releases/latest" 2>/dev/null || true) + case "$effective" in + */releases/tag/*) echo "${effective##*/}"; return 0 ;; + esac + fi + fetch "$API_BASE/releases/latest" 2>/dev/null \ + | grep -o '"tag_name":[[:space:]]*"[^"]*"' | head -1 | cut -d'"' -f4 +} + version="${MATCHA_VERSION:-latest}" if [ "$version" = "latest" ]; then - tag=$(fetch "$API_BASE/releases/latest" \ - | grep -o '"tag_name":[[:space:]]*"[^"]*"' | head -1 | cut -d'"' -f4) - [ -n "$tag" ] || err "could not resolve latest release tag" + tag=$(resolve_latest) + [ -n "$tag" ] || err "could not resolve the latest release tag. + The release API may be rate-limited (60/hour per IP without a token). + Pin a version instead: curl -fsSL /install.sh | MATCHA_VERSION=v26.8.0-beta.0 sh" else tag="$version" fi diff --git a/test_install.sh b/test_install.sh index cc246e6..686eebe 100755 --- a/test_install.sh +++ b/test_install.sh @@ -43,4 +43,19 @@ if MATCHA_REPO_BASE="file://$work/fixture" MATCHA_VERSION="$tag" MATCHA_INSTALL_ fi [ -e "$bin2/matcha" ] && fail "matcha must NOT be installed on checksum mismatch" +# --- case 3: an unresolvable "latest" explains itself and installs nothing --- +# Both bases point at a path that does not exist, so the redirect and the API +# fallback each come back empty. The branch is worth a test because its failure +# mode is a message: the old one said only "could not resolve latest release +# tag", which is also what a rate-limited API produces. +bin3="$work/bin3" +out=$(MATCHA_REPO_BASE="file://$work/nowhere" MATCHA_API_BASE="file://$work/nowhere" \ + MATCHA_INSTALL_DIR="$bin3" sh "$here/install.sh" 2>&1) && \ + fail "install.sh should have failed with no resolvable latest" +case "$out" in + *MATCHA_VERSION*) ;; + *) fail "the unresolvable-latest error must point at MATCHA_VERSION; got: $out" ;; +esac +[ -e "$bin3/matcha" ] && fail "matcha must NOT be installed when latest cannot resolve" + echo "PASS: test_install.sh"