From 8613f685abdfe5cbe192221eb14ec26a33d3683b Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Sat, 10 Aug 2024 19:37:25 +0100 Subject: [PATCH] tests: Skip AWS ECR login outside of CI jobs To avoid rate limiting errors, CI (currently Azure Devops) logs into the container registry (currently AWS ECR). Outside CI this is unnnecessary and makes it harder to run the tests, because very few people have access to a suitable AWS secret token. Following this change `aws ecr-public get-login-password` will only be run if the environment variable $TF_BUILD==True. This is set by Azure Pipelines jobs. If the CI platform is changed then another indicator should be used. https://adamj.eu/tech/2020/03/09/detect-if-your-tests-are-running-on-ci/ --- .ci/ansible_install.py | 2 +- .ci/debops_common_install.py | 2 +- .ci/mitogen_install.py | 2 +- .ci/mitogen_py24_install.py | 2 +- tox.ini | 3 +++ 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.ci/ansible_install.py b/.ci/ansible_install.py index 900303f6..3b217ff2 100755 --- a/.ci/ansible_install.py +++ b/.ci/ansible_install.py @@ -4,7 +4,7 @@ import ci_lib batches = [ [ - 'aws ecr-public get-login-password | docker login --username AWS --password-stdin public.ecr.aws', + 'if [ "${TF_BUILD:-false}" = "True" ]; then aws ecr-public get-login-password | docker login --username AWS --password-stdin public.ecr.aws; fi', ] ] diff --git a/.ci/debops_common_install.py b/.ci/debops_common_install.py index afafe39a..565f9488 100755 --- a/.ci/debops_common_install.py +++ b/.ci/debops_common_install.py @@ -10,7 +10,7 @@ ci_lib.run_batches([ 'python -m pip --no-python-version-warning --disable-pip-version-check "debops[ansible]==2.1.2"', ], [ - 'aws ecr-public get-login-password | docker login --username AWS --password-stdin public.ecr.aws', + 'if [ "${TF_BUILD:-false}" = "True" ]; then aws ecr-public get-login-password | docker login --username AWS --password-stdin public.ecr.aws; fi', ], ]) diff --git a/.ci/mitogen_install.py b/.ci/mitogen_install.py index b0b1eb14..23ff384b 100755 --- a/.ci/mitogen_install.py +++ b/.ci/mitogen_install.py @@ -7,7 +7,7 @@ batches = [ if ci_lib.have_docker(): batches.append([ - 'aws ecr-public get-login-password | docker login --username AWS --password-stdin public.ecr.aws', + 'if [ "${TF_BUILD:-false}" = "True" ]; then aws ecr-public get-login-password | docker login --username AWS --password-stdin public.ecr.aws; fi', ]) diff --git a/.ci/mitogen_py24_install.py b/.ci/mitogen_py24_install.py index bd6ecb24..8af90405 100755 --- a/.ci/mitogen_py24_install.py +++ b/.ci/mitogen_py24_install.py @@ -4,7 +4,7 @@ import ci_lib batches = [ [ - 'aws ecr-public get-login-password | docker login --username AWS --password-stdin public.ecr.aws', + 'if [ "${TF_BUILD:-false}" = "True" ]; then aws ecr-public get-login-password | docker login --username AWS --password-stdin public.ecr.aws; fi', ], [ 'curl https://dw.github.io/mitogen/binaries/ubuntu-python-2.4.6.tar.bz2 | sudo tar -C / -jxv', diff --git a/tox.ini b/tox.ini index a0b0e1ae..5dcb1bf2 100644 --- a/tox.ini +++ b/tox.ini @@ -104,6 +104,9 @@ passenv = AWS_DEFAULT_REGION AWS_SECRET_ACCESS_KEY HOME + # Azure DevOps, TF_BUILD is set to 'True' when running in a build task + # https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables + TF_BUILD setenv = # See also azure-pipelines.yml ANSIBLE_STRATEGY = mitogen_linear