Skip to content

Commit 44cae65

Browse files
committed
Reduce 429 error responses when checking links
- set concurrency to 1 - retry 429 responses with retry-after header - set bearer token for GitHub links
1 parent ffcb10a commit 44cae65

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

.github/workflows/docs_test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ jobs:
3434
working-directory: docs/v2
3535
run: ./render.sh
3636
- name: Run docs tests
37+
env:
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3739
run: |
3840
bundle config set --local without 'development'
3941
bundle install

docs/v3/gulpfile.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,30 @@ async function checkPathAndExit(path, options, done) {
8585

8686
const url = 'http://localhost:8001/';
8787

88+
const githubToken = process.env.GITHUB_TOKEN;
89+
90+
if (githubToken) {
91+
console.log('Github token found, using it for link checking.');
92+
}
93+
8894
const config = {
8995
path: url,
9096
linksToSkip: options.linksToSkip || [],
9197
recurse: options.recurse,
9298
silent: options.silent,
9399
markdown: options.markdown,
100+
concurrency: 1,
101+
retry: true,
102+
beforeRequest: (url, options) => {
103+
// add the bearer token for GitHub links
104+
if (githubToken && url.host.endsWith('github.com')) {
105+
options.headers = {
106+
...(options.headers || {}),
107+
authorization: `Bearer ${githubToken}`,
108+
};
109+
}
110+
return options;
111+
},
94112
};
95113

96114
try {

0 commit comments

Comments
 (0)