Skip to content

Commit

Permalink
Remove useless workaround for RTD failures, and add retries for RTD f…
Browse files Browse the repository at this point in the history
…ailure in docs/conf.py
  • Loading branch information
YannickJadoul committed Nov 27, 2022
1 parent caa1b60 commit 2b2f650
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,6 @@ jobs:
if: github.ref_type == 'branch' && !startsWith(github.ref_name, 'actions')
needs: [wheels]

steps:
- name: Ensure RTD wheel is available
uses: actions/download-artifact@v3
with:
name: rtd-wheel
path: wheelhouse

- name: Trigger ReadTheDocs webhook
run: |
curl -X POST -d "branches=${{ github.ref_name }}" -d "token=${{ secrets.READTHEDOCS_WEBHOOK_TOKEN }}" https://readthedocs.org/api/v2/webhook/parselmouth/15985/
Expand Down
11 changes: 10 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import subprocess
import sys
import tempfile
import time
import zipfile

on_rtd = os.environ.get('READTHEDOCS') == 'True'
Expand Down Expand Up @@ -82,7 +83,15 @@
runs = g.get_repo('YannickJadoul/Parselmouth').get_workflow("wheels.yml").get_runs(branch=branch)
artifacts_url = next(r for r in runs if r.head_sha == head_sha).artifacts_url

archive_download_url = next(artifact for artifact in requests.get(artifacts_url).json()['artifacts'] if artifact['name'] == 'rtd-wheel')['archive_download_url']
archive_download_url = None
for i in range(5):
try:
archive_download_url = next(artifact for artifact in requests.get(artifacts_url).json()['artifacts'] if artifact['name'] == 'rtd-wheel')['archive_download_url']
break
except StopIteration:
if i == 4:
raise
time.sleep(15)
artifact_bin = io.BytesIO(requests.get(archive_download_url, headers={'Authorization': f'token {github_token}'}, stream=True).content)

with zipfile.ZipFile(artifact_bin) as zf, tempfile.TemporaryDirectory() as tmpdir:
Expand Down

0 comments on commit 2b2f650

Please sign in to comment.