diff --git a/.travis.yml b/.travis.yml index bdb0dde978c5..a0261553c637 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,9 +28,10 @@ jobs: - env: "MODE=browserstack_required" - env: "MODE=travis_required" - stage: Deploy - script: ./scripts/ci/publish-artifacts.sh - env: "MODE=release" - + env: "DEPLOY_MODE=build-artifacts" + - env: "DEPLOY_MODE=docs-content" + - env: "DEPLOY_MODE=screenshot-tool" + - env: "DEPLOY_MODE=dashboard" env: global: - LOGS_DIR=/tmp/angular-material2-build/logs @@ -51,7 +52,7 @@ before_script: - mkdir -p $LOGS_DIR script: - - ./scripts/ci/build-and-test.sh + - ./scripts/ci/travis-script.sh cache: directories: diff --git a/scripts/ci/env.sh b/scripts/ci/env.sh old mode 100644 new mode 100755 diff --git a/scripts/ci/publish-artifacts.sh b/scripts/ci/publish-artifacts.sh deleted file mode 100755 index cc7d49fd0cd5..000000000000 --- a/scripts/ci/publish-artifacts.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -# Script that runs after the testing stage of Travis passed. -# Build artifacts and docs content will be published to different repositories. - -# The script should immediately exit if any command in the script fails. -set -e - -# Go to the project root directory -cd $(dirname $0)/../.. - -if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then - echo "Build artifacts and docs content will only be deployed in Travis push builds." - exit 0; -fi - -echo "Starting to publish the build artifacts and docs content..." -echo "" - -# Build Material, CDK and the docs before publishing artifacts -$(npm bin)/gulp cdk:build-release:clean -$(npm bin)/gulp material:build-release -$(npm bin)/gulp material-examples:build-release -$(npm bin)/gulp docs - -# Run publishing of artifacts in parallel. -# This is possible because the output has been built before. -./scripts/deploy/publish-build-artifacts.sh --no-build & -./scripts/deploy/publish-docs-content.sh --no-build & - -# Deploy the screenshot and dashboard functions for each push build. -./scripts/deploy/deploy-screenshot-functions.sh & -./scripts/deploy/deploy-dashboard.sh & - -wait diff --git a/scripts/ci/travis-deploy.sh b/scripts/ci/travis-deploy.sh new file mode 100755 index 000000000000..4a3af4c6456b --- /dev/null +++ b/scripts/ci/travis-deploy.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# Script that runs in the deploy stage after the testing stage of Travis passed. +# Build artifacts and docs content will be published to different repositories. + +# The script should immediately exit if any command in the script fails. +set -e + +# Go to the project root directory +cd $(dirname $0)/../.. + +# If the current Travis job is triggered by a pull request skip the deployment. +# This check is necessary because Travis still tries to run the deploy build-stage for +# pull requests. +if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then + echo "Build artifacts and docs content will only be deployed in Travis push builds." + exit 0; +fi + +echo "" +echo "Starting the deployment script. Running mode: ${DEPLOY_MODE}" +echo "" + +if [[ "${DEPLOY_MODE}" == "build-artifacts" ]]; then + ./scripts/deploy/publish-build-artifacts.sh +fi + +if [[ "${DEPLOY_MODE}" == "docs-content" ]]; then + ./scripts/deploy/publish-docs-content.sh +fi + +if [[ "${DEPLOY_MODE}" == "screenshot-tool" ]]; then + ./scripts/deploy/deploy-screenshot-functions.sh +fi + +if [[ "${DEPLOY_MODE}" == "dashboard" ]]; then + ./scripts/deploy/deploy-dashboard.sh +fi diff --git a/scripts/ci/travis-script.sh b/scripts/ci/travis-script.sh new file mode 100755 index 000000000000..cc3ca0d44133 --- /dev/null +++ b/scripts/ci/travis-script.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# Script that runs in every Travis CI container. The script is responsible for delegating +# to the different scripts that should run for specific Travis jobs in a build stage. + +# The script should immediately exit if any command in the script fails. +set -e + +# Go to project directory +cd $(dirname $0)/../.. + +if [[ -z "$TRAVIS" ]]; then + echo "This script can only run inside of Travis build jobs." + exit 1 +fi + +if [[ "${MODE}" ]]; then + ./scripts/ci/travis-testing.sh +elif [[ "${DEPLOY_MODE}" ]]; then + ./scripts/ci/travis-deploy.sh +fi diff --git a/scripts/ci/build-and-test.sh b/scripts/ci/travis-testing.sh similarity index 88% rename from scripts/ci/build-and-test.sh rename to scripts/ci/travis-testing.sh index f9a9fd15e932..e790d41f3cbb 100755 --- a/scripts/ci/build-and-test.sh +++ b/scripts/ci/travis-testing.sh @@ -1,5 +1,8 @@ #!/bin/bash +# Script that runs in the testing build stage of Travis and is responsible for testing +# the project in different Travis jobs of the current build stage. + # The script should immediately exit if any command in the script fails. set -e