Link Checker: Allow relative links in configurable file path patterns#14400
Link Checker: Allow relative links in configurable file path patterns#14400weshaggard merged 11 commits intomainfrom
Conversation
…sFile parameter Co-authored-by: weshaggard <9010698+weshaggard@users.noreply.github.com>
…idance checks active Co-authored-by: weshaggard <9010698+weshaggard@users.noreply.github.com>
…-links.txt Co-authored-by: weshaggard <9010698+weshaggard@users.noreply.github.com>
…thub/** needs no ** prefix Co-authored-by: weshaggard <9010698+weshaggard@users.noreply.github.com>
…ll repos Co-authored-by: weshaggard <9010698+weshaggard@users.noreply.github.com>
|
/azp run azure-sdk-tools - sync - eng-common |
|
The filtering logic for comment lines checks StartsWith("#") without trimming leading whitespace. This contradicts the parameter docs (“lines beginning with '#' are treated as comments”) and will treat lines like ' # comment' as patterns. Consider using TrimStart() (or checking after Trim()) before StartsWith('#') so indented comment lines are ignored as intended. This converts each glob pattern to a regex on every page check. If many pages are scanned, this is avoidable overhead. Consider precomputing and storing normalized/compiled regex objects once when loading $allowRelativeLinkPatterns, then simply iterating the compiled regex list in Test-PageUriMatchesRelativeLinkPattern. The default path is built via string concatenation with a hard-coded /. While it often works, it’s more robust/cross-platform to build paths with Join-Path (or [System.IO.Path]::Combine) to avoid separator quirks and improve readability. The comment says this allowlist is for “all markdown files under the .github folder”, but the glob .github/** is not restricted to markdown, and eng/** broadens the scope further without explanation. Please update the comment(s) to match the actual behavior, or (if intended) narrow the patterns (e.g., .github//*.md) and document why eng/ is included. |
…, remove eng/** Co-authored-by: weshaggard <9010698+weshaggard@users.noreply.github.com>
Done in 1359805:
|
|
@copilot I still want |
Co-authored-by: weshaggard <9010698+weshaggard@users.noreply.github.com>
|
/azp run azure-sdk-tools - sync - eng-common |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
The following pipelines have been queued for testing: |
Sync eng/common directory with azure-sdk-tools for PR Azure/azure-sdk-tools#14400 See [eng/common workflow](https://github.com/Azure/azure-sdk-tools/blob/main/eng/common/README.md#workflow) --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: weshaggard <9010698+weshaggard@users.noreply.github.com> Co-authored-by: Wes Haggard <weshaggard@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sync eng/common directory with azure-sdk-tools for PR Azure/azure-sdk-tools#14400 See [eng/common workflow](https://github.com/Azure/azure-sdk-tools/blob/main/eng/common/README.md#workflow) --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: weshaggard <9010698+weshaggard@users.noreply.github.com> Co-authored-by: Wes Haggard <weshaggard@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
The link checker's
checkLinkGuidancemode unconditionally rejected relative links, making it impractical for.github/markdown files (e.g. copilot instructions) that benefit from relative cross-references between files.Changes
Verify-Links.ps1: Added-allowRelativeLinksFileparameter. When provided, loads a list of glob patterns; pages whose paths match any pattern skip the relative-link restriction while still having all other link guidance enforced (http→https, uppercase anchors, locale checks). Defaults to(Join-Path $PSScriptRoot "allow-relative-links.txt")(i.e. the file next to the script). Glob-to-regex compilation is done once at load time for efficiency. Comment-line filtering correctly handles indented# commentlines.Verify-Links.ps1: Removed the ad-hocinstructions.mdspecial case (previously added for copilot instruction files) — this is now handled generically viaallow-relative-links.txt.verify-links.yml(DevOps template): AddedAllowRelativeLinksFileparameter, defaulting to$(Build.SourcesDirectory)/eng/common/scripts/allow-relative-links.txt. Passed through to the script.eng/common/scripts/allow-relative-links.txt(new): Default config file placed next toVerify-Links.ps1ineng/common/scripts/so it syncs acrosseng/commonto all Azure SDK repos. Pre-populated with.github/**(all files under the.githubfolder, e.g. copilot instructions) andeng/**(all files under theengfolder, e.g. engineering system scripts and templates). Repo-specific patterns should be added per-repo as needed.eng/common-tests/Verify-Links-AllowRelativeLinks.Tests.ps1(new): Pester tests for the pattern-matching logic.Config file format
One glob pattern per line;
#lines are comments (indented comments are also supported). Both*(single segment) and**(multi-segment) wildcards are supported. A leading**is not required — patterns are matched as substrings against the full path.💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.