Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,16 @@ jobs:
}}
dists-artifact-name: >-
${{ needs.pre-setup.outputs.dists-artifact-name }}
# NOTE: Raises linkcheck's GitHub request rate limit from 60/hour
# NOTE: (anonymous) to 5000/hour (authenticated). See `docs/conf.py`.
# NOTE: `github.token` (not `secrets.GITHUB_TOKEN`) because the
# NOTE: `secrets` context isn't accessible in a `with:` input.
environment-variables: >-
${{
matrix.toxenv == 'linkcheck-docs'
&& format('GITHUB_TOKEN={0}', github.token)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't realize there was this additional challenge. I'll need to think whether it's worth doing from the security PoV. And also, it's an interesting problem to explore since I'll face this in other projects too.

I've documented the question @ tox-dev/workflow#10. I suppose, we'll have to keep this PR in draft for now. But feel free to leave your thoughts on the issue in the reusable workflow repo.

|| ''
}}
post-toxenv-preparation-command: >-
${{
matrix.toxenv == 'pre-commit'
Expand Down
13 changes: 13 additions & 0 deletions docs/changelog-fragments.d/851.contrib.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Removed the long-standing blanket
:external+sphinx:confval:`linkcheck_ignore` exclusion of
`github.com <https://github.com>`_ commit/issue/pull-request/file
links: that workaround
predated Sphinx gaining proper rate-limit handling (backing off and
retrying on HTTP 429), so it was silently leaving hundreds of GitHub
links in the changelog and history unchecked. Also authenticated
those requests via
:external+sphinx:confval:`linkcheck_request_headers`, using the
``GITHUB_TOKEN`` CI already provisions for every workflow run, to
raise the anonymous 60-per-hour rate limit to 5000 per hour.

-- by :user:`julianz-`
29 changes: 16 additions & 13 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,6 @@
r'http://localhost:\d+/', # local URLs
r'https://codecov\.io/gh/cherrypy/cheroot/branch/master/graph/badge\.svg',
r'https://github\.com/cherrypy/cheroot/actions', # 404 if no auth
# Too many links to GitHub so they cause
# "429 Client Error: too many requests for url"
# Ref: https://github.com/sphinx-doc/sphinx/issues/7388
r'https://github\.com/cherrypy/cheroot/blob',
r'https://github\.com/cherrypy/cheroot/commit',
r'https://github\.com/cherrypy/cheroot/issues',
r'https://github\.com/cherrypy/cheroot/pull',
r'https://github\.com/cherrypy/cheroot/tree',
r'https://github\.com/cherrypy/cherrypy/blob',
r'https://github\.com/cherrypy/cherrypy/commit',
r'https://github\.com/cherrypy/cherrypy/issues',
r'https://github\.com/cherrypy/cherrypy/pull',
r'https://github\.com/cherrypy/cherrypy/tree',
# Has an ephemeral anchor (line-range) but actual HTML has separate per-
# line anchors.
(
Expand All @@ -131,6 +118,22 @@
r'^https://forums\.sabnzbd\.org/', # these generate HTTP 403 Forbidden
r'^https://web\.archive\.org/web/', # these timeout
]
linkcheck_request_headers = (
{
'https://github.com/': {
'Authorization': f'Bearer {os.environ["GITHUB_TOKEN"]}',
},
'https://api.github.com/': {
'Authorization': f'Bearer {os.environ["GITHUB_TOKEN"]}',
},
}
if os.environ.get('GITHUB_TOKEN')
# Anonymous GitHub requests are capped at 60/hour; an authenticated
# token raises that to 5000/hour, keeping `linkcheck` from needing
# to back off and retry when checking the many GitHub links in the
# changelog/history.
else {}
)
linkcheck_anchors_ignore = [
r'^!', # default
# ignore anchors that start with a '/', e.g. Wikipedia media files:
Expand Down
Loading