Skip to content

Commit

Permalink
Don't fail build when symbols can't be uploaded (PR #11433)
Browse files Browse the repository at this point in the history
Failing to upload symbols to Mozilla should not cause our build to fail.
The symbols are already saved as artefacts, if the upload to Mozilla
fails, it can be fixed manually.

Make the attempt more robust by trying multiple times with a short wait
in between.
  • Loading branch information
feerrenrut committed Jul 28, 2020
1 parent 9f56cfb commit 9afc1c6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
10 changes: 8 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ before_test:
$installerProcess | wait-process -Timeout 180
$errorCode=$installerProcess.ExitCode
} catch {
echo NVDA installer process timed out
echo "NVDA installer process timed out"
$errorCode=1
Add-AppveyorMessage "Unable to install NVDA prior to tests."
}
Expand Down Expand Up @@ -253,9 +253,15 @@ deploy_script:
artifacts=$artifacts
}
ConvertTo-Json -InputObject $data -Compress | ssh nvaccess@exbi.nvaccess.org nvdaAppveyorHook
# Upload symbols to Mozilla.
py -m pip install --no-warn-script-location requests
py appveyor\mozillaSyms.py
py appveyor\mozillaSyms.py
if($LastExitCode -ne 0) {
$errorCode=$LastExitCode
echo "Unable to upload symbols to Mozilla"
Add-AppveyorMessage "Unable to upload symbols to Mozilla"
}
}
on_finish:
Expand Down
32 changes: 26 additions & 6 deletions appveyor/mozillaSyms.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,33 @@ def generate():
count += 1
print('Added %d files to %s' % (count, ZIP_FILE))


def upload():
r = requests.post(URL,
files={'symbols.zip': open(ZIP_FILE, 'rb')},
headers={'Auth-Token': os.getenv('mozillaSymsAuthToken')},
allow_redirects=False
)
if r.status_code >= 200 and r.status_code < 300:
errors = [] # capture errors, to report if all attempts fail.
for i in range(7):
if i > 0:
print("Sleeping for 15 seconds before next attempt.")
import time
time.sleep(15)
try:
r = requests.post(
URL,
files={'symbols.zip': open(ZIP_FILE, 'rb')},
headers={'Auth-Token': os.getenv('mozillaSymsAuthToken')},
allow_redirects=False
)
break # success
except Exception as e:
print(f"Attempt {i + 1} failed: {e!r}")
errors.append(repr(e))
else: # no break in for loop
allErrors = "\n".join(
f"Attempt {index + 1} error: \n{e}"
for index, e in enumerate(errors)
)
raise RuntimeError(allErrors)

if 200 <= r.status_code < 300:
print('Uploaded successfully!')
elif r.status_code < 400:
print('Error: bad auth token? (%d)' % r.status_code)
Expand Down

0 comments on commit 9afc1c6

Please sign in to comment.