Skip to content

feat(hack): generate docs from a pre-tag ref and fail loudly on fetch errors - #631

Open
myasnikovdaniil wants to merge 2 commits into
mainfrom
feat/prerelease-fetch-ref
Open

feat(hack): generate docs from a pre-tag ref and fail loudly on fetch errors#631
myasnikovdaniil wants to merge 2 commits into
mainfrom
feat/prerelease-fetch-ref

Conversation

@myasnikovdaniil

Copy link
Copy Markdown
Contributor

What this PR does

Today make update-all RELEASE_TAG=vX.Y.Z can fetch content only from a ref named exactly like the release tag: the Makefile pins BRANCH := $(RELEASE_TAG), and every fetch goes to raw.githubusercontent.com/cozystack/cozystack/${BRANCH}/.... That forces docs generation to wait until the final tag exists — which is why the docs PR can only be opened after the release is already public. The upcoming promote-flow change in cozystack/cozystack wants to open this PR at promote time, before the stable tag is cut, generating from the digest-pinned release-X.Y.Z staging branch.

Two changes:

  1. Makefile: new FETCH_REF ?= $(BRANCH) — the ref content is fetched from. It defaults to BRANCH (which stays pinned to RELEASE_TAG when set), so every existing invocation, including the current tags.yaml one, behaves byte-identically. Passing FETCH_REF=<staging-branch|rc-tag|sha> fetches content from that ref while version routing (DOC_VERSION, release-next, update-versions gating) still keys on RELEASE_TAG. The six update_apps.sh/update_versions.sh invocations now pass --branch "$(FETCH_REF)"; show-target echoes it.

  2. hack/update_apps.sh: fail loudly instead of stubbing. Previously the script rewrote the destination doc (template copy + autogenerated notice) before fetching, and a failed fetch only printed a warning and continued with exit 0 — so a bad ref or a transient raw.githubusercontent error produced stub docs indistinguishable from a real update, which could be committed and merged. Now the README is fetched into a temp file first (curl --retry 3, BOM strip and heading drop unchanged); any fetch failure or empty body exits non-zero naming the app and URL, leaving existing docs byte-identical. A trap cleans the temp file on non-fetch error paths too.

Intended strictness worth acking in review: make update-all against an older tag whose tree lacks a currently-listed app now fails the docs job instead of committing a stub for that app. That couples the app roster to the fetched ref, deliberately — a stub merged into version docs is worse than a red job.

Deliberately out of scope: the manual template-* targets (fill_templates.sh) keep using $(BRANCH) and their soft-fail behavior; they are not part of the automated release path.

Verification

make show-target in all modes: legacy BRANCH=... RELEASE_TAG=... resolves FETCH_REF to the tag (byte-identical behavior), FETCH_REF=release-1.6.0-rc.4 RELEASE_TAG=v1.6.0 keeps routing on the tag while fetching from the staging ref, plain no-var runs stay on main. Live positive run: update_apps.sh --branch v1.6.0 produces real (non-stub) docs for all apps. Live negative run: --branch this-ref-does-not-exist exits 1 with the app and URL named and the destination tree byte-identical. Empty-body guard exercised. make update-all RELEASE_TAG=v1.6.0 FETCH_REF=v1.6.0 passes end-to-end; bash -n clean.

… errors

update-all could only fetch content from a ref named exactly like
RELEASE_TAG (the Makefile overrides BRANCH with it), which forces docs
generation to wait until the final tag exists. The new FETCH_REF
variable (default: BRANCH, so every existing invocation is
byte-identical) lets the release flow point content fetching at a
staging branch, rc tag, or SHA while version routing still keys on
RELEASE_TAG — enabling the docs PR to be prepared at promote time,
before the stable tag is cut.

update_apps.sh also rewrote destination docs before fetching and
swallowed curl failures, so a bad ref or a raw.githubusercontent hiccup
silently produced stub docs that could be committed and merged. Fetch
now goes to a temp file first with curl --retry 3; any fetch failure or
empty body aborts non-zero with the app and URL named, leaving existing
docs byte-identical. A trap covers temp cleanup on the non-fetch error
paths.

Note the intended strictness: update-all against an older tag whose
tree lacks a currently-listed app now fails the job instead of
committing a stub for it.

Assisted-By: GPT-5 <noreply@openai.com>
Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Myasnikov Daniil <myasnikovdaniil2001@gmail.com>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@netlify

netlify Bot commented Jul 24, 2026

Copy link
Copy Markdown

Deploy Preview for cozystack ready!

Name Link
🔨 Latest commit 08f1200
🔍 Latest deploy log https://app.netlify.com/projects/cozystack/deploys/6a670eddf8b53c0008f77c52
😎 Deploy Preview https://deploy-preview-631--cozystack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@myasnikovdaniil, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 13 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 11e4435f-0395-43c7-bec4-1591c8f0f8cc

📥 Commits

Reviewing files that changed from the base of the PR and between f4ab8c2 and 08f1200.

📒 Files selected for processing (2)
  • Makefile
  • hack/update_apps.sh
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/prerelease-fetch-ref

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@IvanHunters IvanHunters left a comment

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.

LGTM — no blockers.

Fail-loud on fetch error verified across all branches: set -euo pipefail + curl -f + if ! ... wrapper + empty-$tmp guard, with pipefail propagating curl's exit through sed/awk. Happy-path output is byte-identical to before (only --retry 3 added), and template/notice writes now happen strictly after both guards, so a fetch failure can no longer publish an empty stub. All 6 call sites switched to $(FETCH_REF); template-* targets deliberately kept on $(BRANCH).

Non-blocking notes:

  • hack/update_apps.sh:116 — the [[ ! -s "$tmp" ]] guard treats a README that is a single H1/H2 line as failure (awk at :110 drops the first heading line → empty output → the whole docs job fails). Unrealistic for real app READMEs, but a behavioral edge distinct from the "empty body" case in the description.
  • hack/update_apps.sh:76 — shellcheck SC2034: SRC_DIR unused (pre-existing).
  • No automated regression test for the fail-loud behavior; relies on the manual runs documented in the PR body (consistent with hack/ having no test harness).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants