Skip to content

test: cover real git branch/remote fallback wiring in docusaurus.config.ts - #436

Merged
nate-double-u merged 4 commits into
mainfrom
quality/test-real-git-fallback-wiring
Nov 20, 2026
Merged

nate-double-u merged 4 commits into
mainfrom
quality/test-real-git-fallback-wiring

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

getCurrentBranch()'s git branch --show-current fallback and
getGitHubRepoUrl()'s git remote get-url origin fallback are 100%
unit-covered in isolation (lib/getCurrentBranch.test.mts,
lib/getGitHubRepoUrl.test.mts), but every integration test that
exercises docusaurus.config.ts's deploy-preview wiring of their
output into assetBaseUrl pins all five branch/repo env vars
(HEAD/BRANCH/GITHUB_HEAD_REF/GITHUB_REF_NAME/REPOSITORY_URL)
for determinism, so the real git fallback path never ran in any
existing test.

This adds one case to lib/docusaurusConfigBuildContext.test.mts that
clears all five env vars and asserts assetBaseUrl equals the real
getCurrentBranch()/getGitHubRepoUrl() output composed the same way
getBuildContext.ts composes it, proving the wiring without
re-testing (or duplicating the logic of) the helpers' own correctness.

No production code changed - test-only addition to
lib/docusaurusConfigBuildContext.test.mts.

Verified locally: full suite passes, npm run test:coverage stays at
100% lines/branches/functions/statements, npx prettier --check and
npx cspell pass on the changed file. Confirmed the new case actually
catches a regression: temporarily hard-coding assetBranch/assetRepo
in getBuildContext.ts to 'main'/the repo param makes it fail.

Files/functions touched: only lib/docusaurusConfigBuildContext.test.mts
(one new it() case). Disjoint from open PRs #428 and #434, which both
touch e2e/linkRewrite.test.mjs only.

Related Issue

Fixes #435


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

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

…ig.ts

getCurrentBranch()'s 'git branch --show-current' fallback and
getGitHubRepoUrl()'s 'git remote get-url origin' fallback are 100%
unit-covered in isolation, but every integration test that exercises
docusaurus.config.ts's deploy-preview assetBaseUrl wiring pins all five
branch/repo env vars for determinism, so the real git fallback never ran
in any existing test. Add one case that clears those env vars and
asserts assetBaseUrl matches the real getCurrentBranch()/getGitHubRepoUrl()
output composed the same way getBuildContext.ts composes it.

Fixes #435

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 20, 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 20, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for cncf-techdocs ready!

Name Link
🔨 Latest commit 85daf30
🔍 Latest deploy log https://app.netlify.com/projects/cncf-techdocs/deploys/6b00747a1f0525b887fb5e62
😎 Deploy Preview https://deploy-preview-436--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 full diff plus the code it wires through, and ran the suite locally. This looks correct to me.

What I verified:

  • The child harness spawns with all five branch/repo env vars set to '' (readConfigUrls's BRANCH_AND_REPO_ENV plus the explicit overrides), and both lib/getCurrentBranch.ts:5-11 and lib/getGitHubRepoUrl.ts:19-23 treat empty strings as falsy, so the real git branch --show-current / git remote get-url origin fallbacks genuinely run in the spawned build - this is the path no prior case covered.
  • The parent computes expectations by deleting the same five vars, calling the same helpers, and restoring in a finally, so parent and child see identical git state and the assertion is deterministic on any checkout (detached HEAD included, where both sides collapse to 'main').
  • The || 'main' / || 'https://github.com/cncf/techdocs' defaults mirror lib/getBuildContext.ts:17-18 exactly, so the test proves the wiring without reimplementing helper logic.
  • Ran node --experimental-strip-types --test lib/docusaurusConfigBuildContext.test.mts on the PR head from a clone on a non-main branch: 6/6 pass, and the new case exercised a real non-default branch name, confirming it is not vacuous.

One known limitation, not a defect of this PR: on a detached-HEAD checkout of main the new case degenerates to asserting the defaults, so it is weakest in exactly that environment - and per the existing CI setup the unit suite is not run by any workflow anyway, so this guards local/agent runs only.

I cannot approve as a bot; recommending a maintainer merge. No changes requested.

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

Copilot AI 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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

3 open issues
What changed in this PR

Adds an integration test case to ensure docusaurus.config.ts build wiring uses the real git-derived branch/repo (via existing helpers) when no CI env overrides are present.

Changes:

  • Import getCurrentBranch() and getGitHubRepoUrl() into the config build-context test.
  • Add a new it() case that clears branch/repo env vars, runs the config harness, and asserts assetBaseUrl matches the helper-composed expectation.
File Description
lib/​docusaurusConfigBuildContext.test.mts Adds an integration test covering deploy-preview assetBaseUrl wiring when branch/repo env vars are unset.

Review effort: Lite

Comment on lines +188 to +196
const { assetBaseUrl } = readConfigUrls({
BUILD_ENV: 'deploy-preview',
DEPLOY_PRIME_URL: 'https://deploy-preview-1--cncf-techdocs.netlify.app',
HEAD: '',
BRANCH: '',
GITHUB_HEAD_REF: '',
GITHUB_REF_NAME: '',
REPOSITORY_URL: '',
});

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.

Verified: the case does pass HEAD/BRANCH/etc. through as empty strings rather than omitting the keys, and this matches the BRANCH_AND_REPO_ENV convention used by every other case in this file (all rely on the helpers' truthiness check, documented in the comment above BRANCH_AND_REPO_ENV). Changing that to true key-deletion would mean reworking readConfigUrls's shared harness used by all 10+ existing cases, which is out of scope for this test-only addition and risks regressing the rest of the file.

Changed in commit 85daf30: renamed the test and reworded the comment above it to say the vars are "cleared" rather than claiming "no env overrides," so the test no longer overstates what it does. Left the empty-string mechanism itself unchanged since it is the file's existing, intentional convention, not something unique to this test.

Full suite (77 tests), npm run test:coverage (100% lines/branches/functions/statements), npx prettier --check, and npx cspell all still pass on the updated file.

@nate-double-u

Copy link
Copy Markdown
Member

/hive have a look at the copilot findings

Copilot stopped reviewing on behalf of nate-double-u due to an error November 20, 2026 16:12
- Skip (rather than vacuously pass) when the real git branch/remote
  can't be determined in this environment, since the test would
  otherwise pass by comparing hardcoded defaults against themselves.
- Compute the expected branch/repo with cwd set to repoRoot, matching
  the harness's spawnSync cwd, so the two sides can't diverge based on
  the test runner's own invocation directory.
- Reword the test name/comment: the case clears the branch/repo env
  vars (empty string, matching the file's existing truthiness-based
  convention), it does not omit them outright.

Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Looked at the Copilot code review findings on this PR and verified each one against the actual code in lib/getCurrentBranch.ts, lib/getGitHubRepoUrl.ts, and the test harness.

All three were valid:

  1. The test could pass vacuously if the real git fallback is unavailable (detached HEAD, no origin), since it fell back to the same hardcoded defaults the production code uses. Fixed: now skips with an explanatory message instead of comparing defaults to defaults.
  2. The harness runs with cwd: repoRoot, but the test computed expectations using the current process's own cwd, which could diverge. Fixed: wrapped the helper calls in a temporary process.chdir(repoRoot).
  3. The test title claimed "no env overrides" but actually passes empty-string overrides. Fixed the title/comment to say the vars are cleared, matching the file's existing truthiness-based convention (left that convention itself unchanged since reworking it would touch the shared harness used by all other cases in the file).

Pushed as commit 85daf30 on this branch. Reran the full suite (77 tests), npm run test:coverage (100% lines/branches/functions/statements), npx prettier --check, and npx cspell; all pass.

No rule or source-of-truth statement was raised in this feedback, so nothing was recorded to the knowledge store.

@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 diff against lib/getBuildContext.ts, lib/getCurrentBranch.ts, lib/getGitHubRepoUrl.ts, and the existing harness in this file. The test is correct and proves what it claims:

  • getBuildContext (lib/getBuildContext.ts:17-19) builds assetBaseUrl from getCurrentBranch() || 'main' and getGitHubRepoUrl() || repo only on the deploy-preview path, so clearing HEAD/BRANCH/GITHUB_HEAD_REF/GITHUB_REF_NAME/REPOSITORY_URL does force the real git fallbacks in the spawned harness (both helpers treat empty-string env as unset via truthiness checks).
  • The expected value is computed with the same helpers after process.chdir(repoRoot), matching the harness's cwd: repoRoot in readConfigUrls, so both sides read the same git state. Env keys are saved/deleted/restored correctly around the in-process call.
  • The skip guard is right: when either helper returns undefined, the config collapses to the || 'main' / || repo defaults and the assertion would pass vacuously, so skipping is the honest outcome (detached-HEAD CI checkouts will hit it).
  • The ./getCurrentBranch.ts import style matches the existing lib/*.test.mts idiom.

Test-only change, no production code touched. Looks correct to me - a maintainer can take this as-is.

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

Copilot AI 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.

🟢 Approval recommended

No active review issues block the added integration coverage for Git fallback values in deploy-preview asset URLs.

1 open issue
2 resolved since last review

Review effort: Balanced

@nate-double-u
nate-double-u merged commit 7691793 into main Nov 20, 2026
10 checks passed
@nate-double-u
nate-double-u deleted the quality/test-real-git-fallback-wiring branch November 20, 2026 17:57
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.

[quality] Real git-fallback wiring into docusaurus.config.ts assetBaseUrl has no end-to-end coverage

2 participants