diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 6287e68db8..84e1316185 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -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) + || '' + }} post-toxenv-preparation-command: >- ${{ matrix.toxenv == 'pre-commit' diff --git a/docs/changelog-fragments.d/851.contrib.rst b/docs/changelog-fragments.d/851.contrib.rst new file mode 100644 index 0000000000..a87711ee7b --- /dev/null +++ b/docs/changelog-fragments.d/851.contrib.rst @@ -0,0 +1,13 @@ +Removed the long-standing blanket +:external+sphinx:confval:`linkcheck_ignore` exclusion of +`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-` diff --git a/docs/conf.py b/docs/conf.py index 89292604d8..d041fc17e4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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. ( @@ -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: