From 643766637ee6bd94b729ad8c38012e224a23c6c4 Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Thu, 10 May 2018 13:42:58 +0100 Subject: [PATCH] ci(docs-infra): factor out the aio-builds-setup environment variables --- .../dockerbuild/scripts-sh/clean-up.sh | 0 .../dockerbuild/scripts-sh/init.sh | 0 .../dockerbuild/scripts-sh/test-env.sh | 19 +++++++++++++++++++ .../scripts-sh/upload-server-prod.sh | 2 +- .../scripts-sh/upload-server-test.sh | 14 +------------- .../dockerbuild/scripts-sh/verify-setup.sh | 4 ++++ 6 files changed, 25 insertions(+), 14 deletions(-) mode change 100755 => 100644 aio/aio-builds-setup/dockerbuild/scripts-sh/clean-up.sh mode change 100755 => 100644 aio/aio-builds-setup/dockerbuild/scripts-sh/init.sh create mode 100644 aio/aio-builds-setup/dockerbuild/scripts-sh/test-env.sh mode change 100755 => 100644 aio/aio-builds-setup/dockerbuild/scripts-sh/upload-server-prod.sh diff --git a/aio/aio-builds-setup/dockerbuild/scripts-sh/clean-up.sh b/aio/aio-builds-setup/dockerbuild/scripts-sh/clean-up.sh old mode 100755 new mode 100644 diff --git a/aio/aio-builds-setup/dockerbuild/scripts-sh/init.sh b/aio/aio-builds-setup/dockerbuild/scripts-sh/init.sh old mode 100755 new mode 100644 diff --git a/aio/aio-builds-setup/dockerbuild/scripts-sh/test-env.sh b/aio/aio-builds-setup/dockerbuild/scripts-sh/test-env.sh new file mode 100644 index 0000000000..130d8151d0 --- /dev/null +++ b/aio/aio-builds-setup/dockerbuild/scripts-sh/test-env.sh @@ -0,0 +1,19 @@ + # Set up env variables for testing + export AIO_NGINX_HOSTNAME=$TEST_AIO_NGINX_HOSTNAME + export AIO_NGINX_PORT_HTTP=$TEST_AIO_NGINX_PORT_HTTP + export AIO_NGINX_PORT_HTTPS=$TEST_AIO_NGINX_PORT_HTTPS + + export AIO_ARTIFACT_PATH=$TEST_AIO_ARTIFACT_PATH + export AIO_BUILDS_DIR=$TEST_AIO_BUILDS_DIR + export AIO_DOMAIN_NAME=$TEST_AIO_DOMAIN_NAME + export AIO_GITHUB_ORGANIZATION=$TEST_AIO_GITHUB_ORGANIZATION + export AIO_GITHUB_REPO=$TEST_AIO_GITHUB_REPO + export AIO_GITHUB_TEAM_SLUGS=$TEST_AIO_GITHUB_TEAM_SLUGS + export AIO_SIGNIFICANT_FILES_PATTERN=$TEST_AIO_SIGNIFICANT_FILES_PATTERN + export AIO_TRUSTED_PR_LABEL=$TEST_AIO_TRUSTED_PR_LABEL + export AIO_UPLOAD_HOSTNAME=$TEST_AIO_UPLOAD_HOSTNAME + export AIO_UPLOAD_PORT=$TEST_AIO_UPLOAD_PORT + export AIO_UPLOAD_MAX_SIZE=$TEST_AIO_UPLOAD_MAX_SIZE + + export AIO_CIRCLE_CI_TOKEN=TEST_CIRCLE_CI_TOKEN + export AIO_GITHUB_TOKEN=TEST_GITHUB_TOKEN diff --git a/aio/aio-builds-setup/dockerbuild/scripts-sh/upload-server-prod.sh b/aio/aio-builds-setup/dockerbuild/scripts-sh/upload-server-prod.sh old mode 100755 new mode 100644 index 3e31be22c6..a69ceca113 --- a/aio/aio-builds-setup/dockerbuild/scripts-sh/upload-server-prod.sh +++ b/aio/aio-builds-setup/dockerbuild/scripts-sh/upload-server-prod.sh @@ -2,8 +2,8 @@ set -eu -o pipefail # Set up env variables for production +export AIO_CIRCLE_CI_TOKEN=$(head -c -1 /aio-secrets/CIRCLE_CI_TOKEN 2>/dev/null || echo "MISSING_CIRCLE_CI_TOKEN") export AIO_GITHUB_TOKEN=$(head -c -1 /aio-secrets/GITHUB_TOKEN 2>/dev/null || echo "MISSING_GITHUB_TOKEN") -export AIO_PREVIEW_DEPLOYMENT_TOKEN=$(head -c -1 /aio-secrets/PREVIEW_DEPLOYMENT_TOKEN 2>/dev/null || echo "MISSING_PREVIEW_DEPLOYMENT_TOKEN") # Start the upload-server instance action=$([ "$1" == "stop" ] && echo "stop" || echo "start") diff --git a/aio/aio-builds-setup/dockerbuild/scripts-sh/upload-server-test.sh b/aio/aio-builds-setup/dockerbuild/scripts-sh/upload-server-test.sh index 1aeb4e2fa0..f24550d127 100644 --- a/aio/aio-builds-setup/dockerbuild/scripts-sh/upload-server-test.sh +++ b/aio/aio-builds-setup/dockerbuild/scripts-sh/upload-server-test.sh @@ -1,24 +1,12 @@ #!/bin/bash set -eu -o pipefail -# Set up env variables for testing -export AIO_BUILDS_DIR=$TEST_AIO_BUILDS_DIR -export AIO_DOMAIN_NAME=$TEST_AIO_DOMAIN_NAME -export AIO_GITHUB_ORGANIZATION=$TEST_AIO_GITHUB_ORGANIZATION -export AIO_GITHUB_TEAM_SLUGS=$TEST_AIO_GITHUB_TEAM_SLUGS -export AIO_REPO_SLUG=$TEST_AIO_REPO_SLUG -export AIO_TRUSTED_PR_LABEL=$TEST_AIO_TRUSTED_PR_LABEL -export AIO_UPLOAD_HOSTNAME=$TEST_AIO_UPLOAD_HOSTNAME -export AIO_UPLOAD_PORT=$TEST_AIO_UPLOAD_PORT - -export AIO_GITHUB_TOKEN=$(head -c -1 /aio-secrets/TEST_GITHUB_TOKEN 2>/dev/null || echo "TEST_GITHUB_TOKEN") -export AIO_PREVIEW_DEPLOYMENT_TOKEN=$(head -c -1 /aio-secrets/TEST_PREVIEW_DEPLOYMENT_TOKEN 2>/dev/null || echo "TEST_PREVIEW_DEPLOYMENT_TOKEN") - # Start the upload-server instance appName=aio-upload-server-test if [[ "$1" == "stop" ]]; then pm2 delete $appName else + source aio-test-env pm2 start $AIO_SCRIPTS_JS_DIR/dist/lib/verify-setup/start-test-upload-server.js \ --uid $AIO_WWW_USER \ --log /var/log/aio/upload-server-test.log \ diff --git a/aio/aio-builds-setup/dockerbuild/scripts-sh/verify-setup.sh b/aio/aio-builds-setup/dockerbuild/scripts-sh/verify-setup.sh index 0011d7fcd9..d6c9000561 100644 --- a/aio/aio-builds-setup/dockerbuild/scripts-sh/verify-setup.sh +++ b/aio/aio-builds-setup/dockerbuild/scripts-sh/verify-setup.sh @@ -23,6 +23,7 @@ function countdown { } function onExit { + echo -e "Stopping Test Server" aio-upload-server-test stop echo -e "Full logs in '$logFile'.\n" > /dev/fd/3 } @@ -31,10 +32,13 @@ function onExit { trap 'onExit' EXIT # Start an upload-server instance for testing +echo -e "Starting Test Server" aio-upload-server-test start --log $uploadServerLogFile # Give the upload-server some time to start :( countdown "Starting" 5 > /dev/fd/3 # Run the tests +echo Running the tests +source aio-test-env node $AIO_SCRIPTS_JS_DIR/dist/lib/verify-setup | tee /dev/fd/3