From 9cb2e52c5920a2b29c1bc6736cc0a65cbc695aba Mon Sep 17 00:00:00 2001 From: Tobias Henkel Date: Tue, 28 Jul 2020 21:45:36 +0200 Subject: [PATCH] Use npm mirrors in tox jobs Opendev runs a caching mirror for npm packages. Use it when running yarn install during tox tests. Due to the way yarn.lock files work at the moment we need to patch the lockfile on the fly to inject the mirror urls [1]. This can be handlel inside the pip.sh where we patch the lockfile, run yarn and reset it afterwards. [1] https://github.com/yarnpkg/yarn/issues/2566 Change-Id: Id1f2daac8327f3110e6beeb2d6391baccfd3ce34 --- .zuul.yaml | 22 ++++++---------------- tools/pip.sh | 12 +++++++++++- tox.ini | 1 + 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.zuul.yaml b/.zuul.yaml index 7494d9eca2..ff5f491c1d 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -238,22 +238,20 @@ - playbooks/zuul-migrate/.* nodeset: ubuntu-xenial timeout: 4800 # 80 minutes - vars: + vars: &zuul_tox_vars test_setup_environment: ZUUL_TEST_ROOT: /tmp/zuul-test + YARN_REGISTRY: "https://{{ zuul_site_mirror_fqdn }}:4443/registry.npmjs" tox_environment: ZUUL_TEST_ROOT: /tmp/zuul-test + YARN_REGISTRY: "https://{{ zuul_site_mirror_fqdn }}:4443/registry.npmjs" - tox-py38: irrelevant-files: - zuul/cmd/migrate.py - playbooks/zuul-migrate/.* timeout: 4800 # 80 minutes nodeset: ubuntu-bionic - vars: - test_setup_environment: - ZUUL_TEST_ROOT: /tmp/zuul-test - tox_environment: - ZUUL_TEST_ROOT: /tmp/zuul-test + vars: *zuul_tox_vars - zuul-build-dashboard-openstack-whitelabel - zuul-build-dashboard-software-factory - zuul-build-dashboard-opendev @@ -290,22 +288,14 @@ - playbooks/zuul-migrate/.* nodeset: ubuntu-xenial timeout: 4800 # 80 minutes - vars: - test_setup_environment: - ZUUL_TEST_ROOT: /tmp/zuul-test - tox_environment: - ZUUL_TEST_ROOT: /tmp/zuul-test + vars: *zuul_tox_vars - tox-py38: irrelevant-files: - zuul/cmd/migrate.py - playbooks/zuul-migrate/.* timeout: 4800 # 80 minutes nodeset: ubuntu-bionic - vars: - test_setup_environment: - ZUUL_TEST_ROOT: /tmp/zuul-test - tox_environment: - ZUUL_TEST_ROOT: /tmp/zuul-test + vars: *zuul_tox_vars - zuul-build-dashboard - nodejs-run-lint: vars: diff --git a/tools/pip.sh b/tools/pip.sh index de9724f4e9..914c7ffe74 100755 --- a/tools/pip.sh +++ b/tools/pip.sh @@ -42,8 +42,18 @@ then mkdir -p zuul/web/static ln -sfn ../zuul/web/static web/build pushd web/ - yarn install + if [[ -n "${YARN_REGISTRY}" ]] + then + echo "Using yarn registry: ${YARN_REGISTRY}" + sed -i "s#https://registry.yarnpkg.com#${YARN_REGISTRY}#" yarn.lock + fi + yarn install --verbose yarn build + if [[ -n "${YARN_REGISTRY}" ]] + then + echo "Resetting yarn registry" + sed -i "s#${YARN_REGISTRY}#https://registry.yarnpkg.com#" yarn.lock + fi popd fi pip install $* diff --git a/tox.ini b/tox.ini index f7ee8ea2a9..5742d83d9b 100644 --- a/tox.ini +++ b/tox.ini @@ -23,6 +23,7 @@ passenv = OS_LOG_DEFAULTS OS_STDERR_CAPTURE OS_STDOUT_CAPTURE + YARN_REGISTRY ZUUL_MYSQL_HOST ZUUL_POSTGRES_HOST ZUUL_TEST_ROOT