From 23c01b40c5b3c6cfb261a52872c82ee6e4920896 Mon Sep 17 00:00:00 2001 From: Brad Ison Date: Tue, 12 Jun 2018 20:35:37 -0400 Subject: [PATCH 1/5] Always clean Travis CI cache if build fails --- .travis.yml | 4 ++++ scripts/ci | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 169228c72..3b29e012a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,10 @@ before_script: - sudo service mysql stop - sudo service postgresql stop +# Clean the cache if any step fails. +after_failure: + - scripts/ci clean + cache: timeout: 1000 directories: diff --git a/scripts/ci b/scripts/ci index 38b04afea..681e76faa 100755 --- a/scripts/ci +++ b/scripts/ci @@ -45,7 +45,7 @@ clean_cache() { quay_run() { - docker run --net=host --entrypoint "/bin/bash" -e TEST_DATABASE_URI -ti "${IMAGE}:${IMAGE_TAG}" -c "$*" + docker run --net=host -e TEST_DATABASE_URI -ti "${IMAGE}:${IMAGE_TAG}" "$@" } From e2bde377d6a5b97543e13b1c9865a9b9631c3293 Mon Sep 17 00:00:00 2001 From: Brad Ison Date: Wed, 13 Jun 2018 10:43:39 -0400 Subject: [PATCH 2/5] Use before_cache instead of after_failure to clean cache --- .travis.yml | 4 ++-- scripts/ci | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3b29e012a..04043f651 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,8 @@ before_script: - sudo service postgresql stop # Clean the cache if any step fails. -after_failure: - - scripts/ci clean +before_cache: + - scripts/ci fail-clean cache: timeout: 1000 diff --git a/scripts/ci b/scripts/ci index 681e76faa..6919ef30f 100755 --- a/scripts/ci +++ b/scripts/ci @@ -43,6 +43,12 @@ clean_cache() { rm "${IMAGE_TAR}" } +fail_clean() { + if [[ $TRAVIS_TEST_RESULT -ne 0 ]]; then + echo "Job failed. Cleaning cache..." + clean_cache + fi +} quay_run() { docker run --net=host -e TEST_DATABASE_URI -ti "${IMAGE}:${IMAGE_TAG}" "$@" @@ -148,6 +154,10 @@ case "$1" in postgres ;; + fail-clean) + fail_clean + ;; + clean) clean_cache ;; From 0501e0b9967ac7f9fde4f52f286222f2500daa58 Mon Sep 17 00:00:00 2001 From: Brad Ison Date: Wed, 13 Jun 2018 12:00:04 -0400 Subject: [PATCH 3/5] Fix failing full-db tests --- scripts/ci | 2 +- test/test_storageproxy.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/ci b/scripts/ci index 6919ef30f..a5449d22a 100755 --- a/scripts/ci +++ b/scripts/ci @@ -10,7 +10,7 @@ SHORT_SHA="${TRAVIS_COMMIT:0:7}" IMAGE_TAG="${SHORT_SHA}-${TRAVIS_BUILD_NUMBER}" IMAGE_TAR="${CACHE_DIR}/${IMAGE}-${IMAGE_TAG}.tar.gz" -MYSQL_IMAGE="mysql:5.6" +MYSQL_IMAGE="mysql:5.7" POSTGRES_IMAGE="postgres:9.6" export MYSQL_ROOT_PASSWORD="quay" diff --git a/test/test_storageproxy.py b/test/test_storageproxy.py index b0a4577d4..026b11f62 100644 --- a/test/test_storageproxy.py +++ b/test/test_storageproxy.py @@ -71,7 +71,7 @@ def app_reloader(liveserver, server_executor): yield -@pytest.mark.skipif(os.environ.get('TEST_DATABASE_URI'), +@pytest.mark.skipif(os.environ.get('TEST_DATABASE_URI') is not None, reason="not supported for non SQLite testing") def test_storage_proxy_auth(storage, liveserver_app, liveserver_session, is_proxying_enabled, app_reloader): From 5ce15348eaaf037c159a7cae25df559fc3a4dd4a Mon Sep 17 00:00:00 2001 From: Brad Ison Date: Wed, 13 Jun 2018 12:02:01 -0400 Subject: [PATCH 4/5] Parallelize pytest runs in Makefile --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 50f8109c7..d6f22188c 100644 --- a/Makefile +++ b/Makefile @@ -43,19 +43,19 @@ conf/stack/license: $(QUAY_CONFIG)/local/license ln -s $(QUAY_CONFIG)/local/license conf/stack/license unit-test: - TEST=true PYTHONPATH="." py.test \ + TEST=true PYTHONPATH="." py.test -n 2 \ --cov="." --cov-report=html --cov-report=term-missing \ --timeout=3600 --verbose -x \ ./ registry-test: - TEST=true PYTHONPATH="." py.test \ + TEST=true PYTHONPATH="." py.test -n 2 \ --cov="." --cov-report=html --cov-report=term-missing \ --timeout=3600 --verbose --show-count -x \ test/registry/registry_tests.py registry-test-old: - TEST=true PYTHONPATH="." py.test \ + TEST=true PYTHONPATH="." py.test -n 2 \ --cov="." --cov-report=html --cov-report=term-missing \ --timeout=3600 --verbose --show-count -x \ ./test/registry_tests.py From 268952a492ae030aa056ea3bacd0bb1c81afc0d9 Mon Sep 17 00:00:00 2001 From: Brad Ison Date: Wed, 13 Jun 2018 13:26:45 -0400 Subject: [PATCH 5/5] Allow arbitrary commands passed to entrypoint --- Dockerfile | 2 +- quay-entrypoint.sh | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index b9f9074d5..32540a991 100644 --- a/Dockerfile +++ b/Dockerfile @@ -142,4 +142,4 @@ RUN ./scripts/detect-config.sh EXPOSE 443 8443 80 -ENTRYPOINT [ "/bin/bash", "./quay-entrypoint.sh"] +ENTRYPOINT ["/quay-registry/quay-entrypoint.sh"] diff --git a/quay-entrypoint.sh b/quay-entrypoint.sh index 24c58b500..7401e511d 100755 --- a/quay-entrypoint.sh +++ b/quay-entrypoint.sh @@ -3,8 +3,12 @@ MODE="$1" display_usage() { - echo "This script takes one argument." - echo -e "\nUsage: ${0} \n" + echo "Usage: ${0} " + echo + echo "If the first argument isn't one of the above modes," + echo "the arguments will be exec'd directly, i.e.:" + echo + echo " ${0} uptime" } if [[ "${MODE}" = "help" ]] @@ -34,26 +38,30 @@ venv/bin/python -m displayversion case "$MODE" in "shell") echo "Entering shell mode" - /bin/bash - exit 0 + exec /bin/bash ;; "config") echo "Entering config mode, only copying config-app entrypoints" cp -r ${QUAYDIR}/config_app/init/service/* /etc/service + exec /sbin/my_init ;; "interactive") echo "Copying $MODE files" cp -r ${QUAYCONF}/init/service/interactive/* /etc/service + exec /sbin/my_init ;; "batch") echo "Copying $MODE files" cp -r ${QUAYCONF}/init/service/batch/* /etc/service + exec /sbin/my_init ;; - *) + "") echo "Copying all files" cp -r ${QUAYCONF}/init/service/interactive/* /etc/service cp -r ${QUAYCONF}/init/service/batch/* /etc/service + exec /sbin/my_init ;; esac -/sbin/my_init \ No newline at end of file +# Not a Quay mode, just exec the args. +exec "$@"