Skip to content

test: cover non-GitHub REPOSITORY_URL fallback in the real e2e build - #456

Closed
hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-e2e-getgithub-repourl-nonmatch
Closed

hivecommons-hive[bot] wants to merge 1 commit into
mainfrom
quality/test-e2e-getgithub-repourl-nonmatch

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

Adds an e2e deploy-preview build (e2e/linkRewrite.test.mjs) that sets REPOSITORY_URL to a non-GitHub URL (e.g. a GitLab mirror) and breaks the git-remote fallback (GIT_DIR/GIT_WORK_TREE pointed at a nonexistent path), asserting the rewritten .csv asset link falls back to the hard-coded repo/main instead of the unparseable URL.

normalizeGitHubUrl's final return undefined fallback (reached when REPOSITORY_URL is present but matches neither the SSH nor HTTPS GitHub regex) was 100% unit-covered in isolation (lib/getGitHubRepoUrl.test.mts) but never reached by a real build: before this change, npx c8 --all --include lib/getGitHubRepoUrl.ts node --test e2e/linkRewrite.test.mjs reported 93.93% stmt/line for the file; after, it reports 100%.

REPOSITORY_URL is an overridable input the production code reads directly, so this exercises the exact same code path a real deploy-preview build would take if Netlify (or a mirror setup) ever populated it with something that isn't github.com-shaped - no fabricated wiring is required.

Related Issue

Refs #451 (tracker issue for e2e/linkRewrite.test.mjs coverage gaps; this PR closes the getGitHubRepoUrl.ts non-GitHub-URL fallback variant folded into it, other variants remain open)


Filed by quality agent (hold-gated mode). Human review required.

-- hive: agent=quality backend=copilot model=claude-opus-4-6 copilot=1.0.88

normalizeGitHubUrl's final fallback (return undefined, reached when
REPOSITORY_URL is set but matches neither the SSH nor HTTPS GitHub
regex) was 100% unit-covered in isolation but never exercised by a
real docusaurus build. Add an e2e deploy-preview build that sets
REPOSITORY_URL to a non-GitHub URL and breaks the git-remote fallback,
asserting the rewritten asset link falls back to the hard-coded
repo/main instead of the unparseable URL.

Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive hivecommons-hive Bot added the ready-for-review Hive's work is done; a maintainer reviews, then removes this label to let it merge. label Nov 25, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Important

Ready for review: held for a maintainer by the hive's ACMM level gate.

This PR was opened by the "quality" agent while Hive policy required a human checkpoint for that agent. Agent PRs are held at ACMM L3-L5; an outreach PR that targets a repository this hive does not manage is held at every level because it publishes project-facing communication into someone else's project.

The hive's work on this PR is done. Hive will keep the ready-for-review label until a maintainer reviews the PR and removes it; it blocks merging the same way hold does. Operators can make a deliberate one-off release during an ACMM level change with release_level_holds=true, but level changes never release this hold automatically.

@netlify

netlify Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for cncf-techdocs ready!

Name Link
🔨 Latest commit 0ce4d98
🔍 Latest deploy log https://app.netlify.com/projects/cncf-techdocs/deploys/6b069eacd2b68ab71541e3c9
😎 Deploy Preview https://deploy-preview-456--cncf-techdocs.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.

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Read the production path this exercises, not just the diff. The test is correct and covers a genuinely distinct branch:

  • With REPOSITORY_URL=https://gitlab.com/example-org/example-repo, normalizeGitHubUrl (lib/getGitHubRepoUrl.ts:3-13) matches neither the SSH nor HTTPS GitHub regex and returns undefined, so execution continues past the env branch (lib/getGitHubRepoUrl.ts:19-22) into the git-remote fallback - the exact path the existing suites never reach, since they set REPOSITORY_URL to a GitHub URL or clear it.
  • Pointing GIT_DIR/GIT_WORK_TREE at a nonexistent path makes git remote get-url origin throw, so getGitHubRepoUrl returns undefined and getBuildContext.ts:18 falls back to the hard-coded repo. Same mechanism for getCurrentBranch -> main. The asserted URL is exactly what assetBaseUrl produces.
  • This is not a duplicate of the both-fail suite above it (empty REPOSITORY_URL): that one never calls normalizeGitHubUrl from the env branch. The doesNotMatch(/gitlab\.com/) assertion distinguishes the outcomes.
  • The fixture link exists (analyses/2023/backstage/index.md:18 references backstage-doc-survey.csv), matching the pattern of the sibling suites in e2e/linkRewrite.test.mjs.

One known caveat, not a defect of this PR: no CI workflow runs the test suites (only format/link/spell checks run), so green checks here do not prove this suite executes - it follows the same verified pattern as its siblings, and I confirmed the logic by reading the tree.

Looks correct to me. I cannot approve; leaving that signature to a maintainer.

-- hive: agent=reviewer backend=copilot model=claude-fable-5 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Merge-order note: this PR and #444/#454/#455/#456 (the others in this set) all add tests to e2e/linkRewrite.test.mjs from the same base. Confirmed with git merge-tree:

Recommended order: land #444 first, then rebase #454, #455, and #456 on top individually - rebasing the three small diffs once each onto the restructured file is cheaper than rebasing the large restructuring diff three times. No action needed from a human beyond normal review order; this is a heads-up so whichever lands later isn't surprised by the conflict.


🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-boq9 | SHA: 3c1e2b5

@nate-double-u

Copy link
Copy Markdown
Member

closing to save spend.

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

Labels

ready-for-review Hive's work is done; a maintainer reviews, then removes this label to let it merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant