-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lint markdown files for broken links. (#497)
## Ticket Resolves #490 ## Changes * Add a lint `make` target for markdown files. Add a linter that checks for broken links. * Fix broken link in markdown files found by this linter. ## Context for reviewers PLEASE: double check the fixed links to ensure I found the right one. 🙂 This linter only checks broken links. There are other markdown linters we can consider adding should the need arise. This linter will be run when running the specific make command `make infra-lint-markdown` as well as the general lint command `make infra-lint`. Therefore, it will also be picked up as part of the CI pipeline which runs all the linters. For the action, I largely copied the action used in [GoogleChrome](https://github.com/GoogleChrome/lighthouse/blob/main/.github/workflows/cron-weekly.yml). ## Testing ### Before Running locally before fixing the errors (snippet image) <img width="897" alt="image" src="https://github.com/navapbc/template-infra/assets/5387486/571de648-5d10-49b3-8ebd-10efaf6c249f"> And see the CI failing for just this new check before fixing the errors it finds: <img width="972" alt="image" src="https://github.com/navapbc/template-infra/assets/5387486/39ce0034-eb81-409f-b4ca-fbf9b1b0550f"> Snippet of failing checks <img width="625" alt="image" src="https://github.com/navapbc/template-infra/assets/5387486/b5358832-2480-4873-a3e1-eb745d661342"> ### After Locally, `make` command completes without error when finding no issues. <img width="395" alt="image" src="https://github.com/navapbc/template-infra/assets/5387486/08452792-8659-44f7-ba57-2105a85f9432"> All the beautiful checks in the CI for PRs pass! (Love those green checkmarks!) <img width="892" alt="image" src="https://github.com/navapbc/template-infra/assets/5387486/512e31e1-5218-41c1-a297-b984ac301cd0">
- Loading branch information
Showing
7 changed files
with
67 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: CI Documentation Checks | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
|
||
jobs: | ||
lint-markdown: | ||
name: Lint markdown | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
# This is the GitHub Actions-friendly port of the linter used in the Makefile. | ||
- uses: gaurav-nelson/github-action-markdown-link-check@1.0.15 | ||
with: | ||
use-quiet-mode: 'yes' # errors only. | ||
config-file: '.github/workflows/markdownlint-config.json' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"ignorePatterns" : [ | ||
{ | ||
"pattern": "0005-example.md" | ||
} | ||
], | ||
"replacementPatterns": [ | ||
{ | ||
"pattern": "^/", | ||
"replacement": "{{BASEURL}}/" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
# To make things simpler, ensure we're in the repo's root directory (one directory up) before | ||
# running, regardless where the user is when invoking this script. | ||
|
||
# Grab the full directory name for where this script lives. | ||
SCRIPT_DIR=$(readlink -f "$0" | xargs dirname) | ||
|
||
# Move up to the root since we want to do everything relative to that. Note that this only impacts | ||
# this script, but will leave the user wherever they were when the script exists. | ||
cd "${SCRIPT_DIR}/.." >/dev/null || exit 1 | ||
|
||
|
||
LINK_CHECK_CONFIG=".github/workflows/markdownlint-config.json" | ||
|
||
# Recursively find all markdown files (*.md) in this directory. Pass them in as args to the lint | ||
# command using the handy `xargs` command. | ||
find . -name \*.md -print0 | xargs -0 -n1 markdown-link-check --config $LINK_CHECK_CONFIG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters