-
Notifications
You must be signed in to change notification settings - Fork 153
[DevOps] Create broken link tests for markdown files across all documentation folders #1691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
Co-authored-by: flanakin <399533+flanakin@users.noreply.github.com>
.github/workflows/dev.yml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a separate workflow documentation tests and only run the broken link test there. Don't change the PowerShell code tests. Rename dev.yml to powershell.yml.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created separate documentation.yml
workflow for broken link tests and renamed dev.yml
to powershell.yml
. The PowerShell code tests remain unchanged. Commit bccd13f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the src/scripts/Test-PowerShell.ps1
script to add a -Markdown
option that runs this broken links test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added -Markdown
parameter to Test-PowerShell.ps1
that runs the broken links test. The script can now be called with src/scripts/Test-PowerShell.ps1 -Markdown
. Commit bccd13f
Co-authored-by: flanakin <399533+flanakin@users.noreply.github.com>
name: Broken Links | ||
runs-on: Windows-latest | ||
steps: | ||
- name: Install and cache PowerShell modules | ||
uses: potatoqualitee/psmodulecache@v6.2.1 | ||
with: | ||
modules-to-cache: Pester | ||
shell: pwsh | ||
- uses: actions/checkout@v3 | ||
- name: Run Broken Links Test | ||
shell: pwsh | ||
run: | | ||
src/scripts/Test-PowerShell.ps1 -Markdown |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium documentation
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 12 hours ago
To fix the issue, we will add a permissions
block to the root of the workflow file. This block will specify the least privileges required for the workflow to function. Since the workflow only needs to read the repository contents to check for broken links, we will set contents: read
. This ensures that the workflow has no write access to the repository.
The permissions
block will be added at the root level, applying to all jobs in the workflow.
-
Copy modified lines R12-R14
@@ -11,2 +11,5 @@ | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: |
This PR implements comprehensive broken link testing for all markdown files in the repository, with folder-specific validation rules and automated GitHub workflow integration.
What's New
BrokenLinks.Tests.ps1
insrc/powershell/Tests/Lint
that validates links across all markdown filesdocs/
: Relative links for files within docs, root-relative for MS Learn content, fully qualified for external links, Jekyll template supportdocs-mslearn/
: Folder-relative for same folder files, root-relative for learn.microsoft.com content, fully qualified for external (prohibits explicit learn.microsoft.com URLs)docs-wiki/
: Relative links for files within docs-wiki, fully qualified for external linksDocs
,DocsMslearn
,DocsWiki
,Other
)dev.yml
to trigger broken link tests when markdown files change in any documentation folderTechnical Implementation
The tests automatically integrate with the existing lint test infrastructure and validate:
Test Results
Successfully identifies 70 broken links across the repository, demonstrating the tests are working correctly to catch real issues.
Fixes #1690.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.