Skip to content

test: pin contributor template link form and fix the PR template's CONTRIBUTING link - #1018

Merged
mrbobbytables merged 1 commit into
mainfrom
quality/test-template-link-form
Oct 3, 2026
Merged

mrbobbytables merged 1 commit into
mainfrom
quality/test-template-link-form

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Test Improvement

.github/PULL_REQUEST_TEMPLATE.md is read in two places, and its only link
worked in just one of them. In the GitHub file viewer — where anyone editing
the template looks at it — [CONTRIBUTING.md](../CONTRIBUTING.md) resolves.
Where the template is actually read it does not: GitHub prefills it into a pull
request body, and a relative target there is resolved against the /compare
URL the contributor is on rather than against the repository, so the checklist
item every contributor sees points at a 404.

Nothing in the repository would have caught it:

  • tests/issue-template-contract.test.mjs was the only thing reading the file,
    and it asserted presence and non-emptiness only.
  • npm run check:links never sees it. _check:links-md in package.json is
    for f in *.md, which iterates root-level markdown and never descends into
    .github/.
  • npm run check:markdown lints style, not resolution.

So this PR fixes the link and adds the guard that makes the next one fail at
npm run test:unit instead of reaching contributors.

What this adds

Five tests in tests/issue-template-contract.test.mjs, built on three helpers:

  • markdownLinkTargets() — reads targets out of markdown, ignoring the title
    in [a](url "t") and skipping HTML comments, since a link parked in a
    comment is shown to nobody.
  • badLinkTarget() — accepts an https:// URL or a #anchor, and explains
    why anything else is unusable in a rendered body.
  • formLinkProblems() — applies that to everything GitHub renders out of an
    issue form: the form description, each markdown element's value, and
    each field's attributes.description.

Two decisions worth reviewing:

  • Form, not liveness. The guard judges a target by its shape and never
    resolves it. Fetching targets is exactly what check:links is exempted from
    CI for in tests/workflow-scripts.test.mjs (GATES_NOT_RUN_BY_CI): a
    third-party outage must not fail an unrelated pull request. The same
    reasoning applies here.
  • The guard is checked against the templates losing their links. An
    assertion that "no link is relative" passes just as well over a template with
    no links at all, so one test pins that the PR template still carries a
    CONTRIBUTING.md link for the others to judge.

The issue forms carry no relative links today
(grep -nE '\]\([^)h#][^)]*\)' .github/ISSUE_TEMPLATE/*.yml is empty), so for
them the guard is preventive; formLinkProblems is covered directly by a
synthetic form rather than by a defect that does not exist.

Files and functions claimed

  • .github/PULL_REQUEST_TEMPLATE.md — the checklist's CONTRIBUTING.md link
    only.
  • tests/issue-template-contract.test.mjs — new markdownLinkTargets,
    badLinkTarget, renderedFormText, formLinkProblems, and five tests. The
    existing tests are unchanged except that the PR template path moved into a
    shared PULL_REQUEST_TEMPLATE constant.

No production code, no workflow changes. Disjoint from every open PR: none of
#989, #991, #994, #996, #998, #1000, #1002, #1004, #1007, #1008, #1010, #1012,
#1014 or #1016 touches .github/PULL_REQUEST_TEMPLATE.md,
.github/ISSUE_TEMPLATE/** or tests/issue-template-contract.test.mjs
(verified with gh pr view <n> --json files over all fourteen).

Verification

  • TZ=UTC node --test tests/issue-template-contract.test.mjs — 15/15 pass.
  • The guard is red on the defect. With the template reverted to
    ../CONTRIBUTING.md, the pull request template links only with absolute URLs or anchors fails with
    ../CONTRIBUTING.md is relative; GitHub resolves it against the /compare URL when the template is rendered into a body, not against the repository.
  • npm run test:unit:coverage:check — exits 0.
    src files 100.00% lines (8351/8351), 100.00% regions (2395/2395),
    unchanged. Repository-wide region coverage moves 95.02% → 95.04%.
  • npx prettier --check — clean on both files.

Related Issue

Closes #1017


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

— hive: agent=quality backend=copilot model=claude-opus-5 copilot=1.0.88

…NTRIBUTING link

GitHub prefills .github/PULL_REQUEST_TEMPLATE.md into the pull request
body, where a relative link target is resolved against the /compare URL
rather than the repository. The checklist's only link, ../CONTRIBUTING.md,
therefore 404s for every contributor opening a PR, even though it resolves
correctly in the file viewer where it was written.

Point it at an absolute URL, and guard the form of every link in a file
GitHub renders into an issue or PR body so the next relative target is
rejected by npm run test:unit instead of reaching contributors.

check:links never saw this: _check:links-md is 'for f in *.md', which
iterates root-level markdown and never descends into .github/.

The guard asserts link form, not liveness, for the same reason
check:links is listed in GATES_NOT_RUN_BY_CI.

Signed-off-by: quality <quality@hive.kubestellar.io>
@hivecommons-hive hivecommons-hive Bot added the hold label Oct 3, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

Important

Held for human review 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. Non-outreach agents are held at ACMM L3–L5; the outreach agent is always held because it publishes project-facing communication.

Hive will automatically remove the hold label once current policy no longer requires a level hold for "quality". If this is an outreach PR, a human must review it and remove the label.

Comment thread tests/issue-template-contract.test.mjs Dismissed
@mrbobbytables
mrbobbytables added this pull request to the merge queue Oct 3, 2026
Merged via the queue into main with commit 9cef7e9 Oct 3, 2026
7 checks passed
@mrbobbytables
mrbobbytables deleted the quality/test-template-link-form branch October 7, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] PR template's relative CONTRIBUTING.md link 404s in the pull request body, and no test guards template link form

2 participants