Skip to content

Commit

Permalink
GitHub Action: Check local Markdown links on push (bevyengine#2067)
Browse files Browse the repository at this point in the history
Adds an GitHub Action to check all local (non http://, https:// ) links in all Markdown files of the repository for liveness.
Fails if a file is not found.

# Goal
This should help maintaining the quality of the documentation.

# Impact
Takes ~24 seconds currently and found 3 dead links (pull requests already created).

# Dependent PRs
* bevyengine#2064 
* bevyengine#2065 
* bevyengine#2066

# Info
See [markdown-link-check](https://github.com/marketplace/actions/markdown-link-check).

# Example output
```
FILE: ./docs/profiling.md

1 links checked.

FILE: ./docs/plugins_guidelines.md

37 links checked.

FILE: ./docs/linters.md
[✖] ../.github/linters/markdown-lint.yml → Status: 400 [Error: ENOENT: no such file or directory, access '/github/workspace/.github/linters/markdown-lint.yml'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'access',
  path: '/github/workspace/.github/linters/markdown-lint.yml'
}
```

# Improvements
* Can also be used to check external links, but fails because of:
  * Too many requests (429) responses:
```
FILE: ./CHANGELOG.md
[✖] bevyengine#1762 → Status: 429
```
   * crates.io links respond 404
```
FILE: ./README.md
[✖] https://crates.io/crates/bevy → Status: 404
```
  • Loading branch information
FlyingRatBull committed May 2, 2021
1 parent 5390be0 commit b399a37
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/bors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ status = [
"build-wasm (nightly, ubuntu-latest)",
"build-android",
"markdownlint",
"check-markdown-links",
"run-examples",
"check-doc",
]
Expand Down
21 changes: 21 additions & 0 deletions .github/linters/markdown-link-check.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"ignorePatterns": [
{
"pattern": "^https?://github\\.com/"
}
],
"replacementPatterns": [],
"httpHeaders": [
{
"urls": ["https://crates.io"],
"headers": {
"Accept": "text/html"
}
}
],
"timeout": "20s",
"retryOn429": true,
"retryCount": 5,
"fallbackRetryDelay": "30s",
"aliveStatusCodes": [200, 206]
}
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ jobs:
# Not needed here as only one Linter is used.
#GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

check-markdown-links:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: gaurav-nelson/github-action-markdown-link-check@0fe4911067fa322422f325b002d2038ba5602170
with:
use-quiet-mode: 'yes'
use-verbose-mode: 'yes'
config-file: '.github/linters/markdown-link-check.json'

run-examples:
runs-on: ubuntu-latest

Expand Down
2 changes: 1 addition & 1 deletion docs/linters.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Explanation:
### [markdownlint](https://github.com/DavidAnson/markdownlint)

`markdownlint` is provided by `super-linter` and is responsible for `.md` files.
Its configuration is saved in the [.markdown-lint.yml](../.github/linters/markdown-lint.yml) file.
Its configuration is saved in the [.markdown-lint.yml](../.github/linters/.markdown-lint.yml) file.

The provided rules are documented [here](https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md) and information about setting the config can be seen [here](https://github.com/DavidAnson/markdownlint#optionsconfig).

Expand Down
4 changes: 3 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,9 @@ Please reference `cargo-apk` [README](https://crates.io/crates/cargo-apk) for ot

### Old phones

Bevy by default targets Android API level 29 in its examples which is the [Play Store's minimum API to upload or update apps](https://developer.android.com/distribute/best-practices/develop/target-sdk). Users of older phones may want to use an older API when testing.
Bevy by default targets Android API level 29 in its examples which is the <!-- markdown-link-check-disable -->
[Play Store's minimum API to upload or update apps](https://developer.android.com/distribute/best-practices/develop/target-sdk). <!-- markdown-link-check-enable -->
Users of older phones may want to use an older API when testing.

To use a different API, the following fields must be updated in Cargo.toml:

Expand Down

0 comments on commit b399a37

Please sign in to comment.