diff --git a/bin/run_codecov.py b/bin/run_codecov.py new file mode 100644 index 00000000..bf1a4ca7 --- /dev/null +++ b/bin/run_codecov.py @@ -0,0 +1,16 @@ +"""Workaround for https://github.com/codecov/codecov-python/issues/158.""" +# std imports +import sys + +# 3rd party +import codecov +import tenacity + +@tenacity.retry(wait=tenacity.wait_random(min=1, max=5), + stop=tenacity.stop_after_delay(60)) +def main(): + codecov.main(sys.argv[1:]) + + +if __name__ == '__main__': + main() diff --git a/run_codecov.py b/run_codecov.py deleted file mode 100644 index 49e7d7ff..00000000 --- a/run_codecov.py +++ /dev/null @@ -1,47 +0,0 @@ -""" -Workaround for https://github.com/codecov/codecov-python/issues/158 -""" - -# std imports -import sys -import time - -# local -import codecov - -RETRIES = 5 -TIMEOUT = 2 - - -def main(): - """ - Run codecov up to RETRIES times - On the final attempt, let it exit normally - """ - - # Make a copy of argv and make sure --required is in it - args = sys.argv[1:] - if '--required' not in args: - args.append('--required') - - for num in range(1, RETRIES + 1): - - print('Running codecov attempt %d: ' % num) - # On the last, let codecov handle the exit - if num == RETRIES: - codecov.main() - - try: - codecov.main(*args) - except SystemExit as err: - # If there's no exit code, it was successful - if err.code: - time.sleep(TIMEOUT) - else: - sys.exit(err.code) - else: - break - - -if __name__ == '__main__': - main() diff --git a/tox.ini b/tox.ini index f53c54ce..d358bba9 100644 --- a/tox.ini +++ b/tox.ini @@ -60,7 +60,7 @@ import_heading_firstparty = local import_heading_localfolder = local sections=FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER no_lines_before=LOCALFOLDER -known_third_party = jinxed +known_third_party = jinxed,codecov,tenacity atomic = true [flake8] @@ -214,9 +214,10 @@ commands = {envbindir}/sphinx-build -v -W -d {toxinidir}/docs/_build/doctrees -b basepython = python{env:TOXPYTHON:{env:TRAVIS_PYTHON_VERSION:3.8}} passenv = TOXENV CI TRAVIS TRAVIS_* CODECOV_* deps = codecov>=1.4.0 + tenacity==6.1.0 # commands = codecov -e TOXENV # Workaround for https://github.com/codecov/codecov-python/issues/158 -commands = {envpython} run_codecov.py -e TOXENV +commands = {envpython} bin/run_codecov.py --required -e TOXENV [testenv:publish_static] # Synchronize the artifacts in docs/_static/ with https://dxtz6bzwq9sxx.cloudfront.net/