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 28ae186
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,6 @@ jobs:
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 28ae186

Please sign in to comment.