From 2633c7cffd8f43140606edf2c299f1acff12042b Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Tue, 27 Nov 2018 22:02:22 +0100 Subject: [PATCH] build: setup cronjob to run tests against angular snapshots (#14217) * Sets up a cronjob workflow that runs the local browser tests against the Angular Github snapshot builds at midnight everyday. * No longer saves cache multiple times. This can cause unexpected behavior. * Sorts jobs in `config.yml` to group all `tests_XX` jobs. Closes #12516. --- .circleci/config.yml | 50 +++++++++++-------- scripts/circleci/run-local-browser-tests.sh | 21 ++++++++ ...apshot.sh => install-angular-snapshots.sh} | 0 3 files changed, 51 insertions(+), 20 deletions(-) create mode 100755 scripts/circleci/run-local-browser-tests.sh rename scripts/{install-angular-snapshot.sh => install-angular-snapshots.sh} (100%) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3ee0d6a5193..c3f64edef65 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -91,24 +91,6 @@ jobs: - run: bazel build src/... - run: bazel test src/... tools/public_api_guard/... - # ------------------------------------------------------------------------------------------ - # Job that runs the unit tests on locally installed browsers (Chrome and Firefox headless). - # The available browsers are installed through the angular/ngcontainer Docker image. - # ------------------------------------------------------------------------------------------ - tests_local_browsers: - docker: *docker-firefox-image - resource_class: xlarge - environment: - TEST_PLATFORM: local - steps: - - *checkout_code - - *restore_cache - - *yarn_install - - # Launches the unit tests. The platform is determined by the "TEST_PLATFORM" environment - # variable which has been configured above - - run: yarn gulp ci:test - # ---------------------------------------------------------------- # Job that runs the e2e tests with Protractor and Chrome Headless # ---------------------------------------------------------------- @@ -122,6 +104,20 @@ jobs: - run: yarn gulp ci:e2e + # ------------------------------------------------------------------------------------------ + # Job that runs the unit tests on locally installed browsers (Chrome and Firefox headless). + # The available browsers are installed through the angular/ngcontainer Docker image. + # ------------------------------------------------------------------------------------------ + tests_local_browsers: + docker: *docker-firefox-image + resource_class: xlarge + steps: + - *checkout_code + - *restore_cache + - *yarn_install + + - run: ./scripts/circleci/run-local-browser-tests.sh + # ---------------------------------------------------------------------------- # Job that runs the unit tests on Browserstack. The browsers that will be used # to run the unit tests on Browserstack are set in: test/browser-providers.js @@ -269,8 +265,6 @@ jobs: - run: ./scripts/circleci/publish-snapshots.sh - - *save_cache - # ---------------------------------------------------------------------------------------- # Workflow definitions. A workflow usually groups multiple jobs together. This is useful if # one job depends on another. @@ -313,6 +307,22 @@ workflows: jobs: - lint + # Snapshot tests workflow that is scheduled to run all specified jobs at midnight everyday. + # This workflow runs various jobs against the Angular snapshot builds from Github. + snapshot_tests: + jobs: + - tests_local_browsers + triggers: + - schedule: + cron: "0 0 * * *" + filters: + branches: + only: + # We only want to run the "master" branch against the snapshot builds because + # it's not guaranteed that older versions of Angular Material always work + # with the latest Angular version. + - master + # --------------------------- # General setup for CircleCI # --------------------------- diff --git a/scripts/circleci/run-local-browser-tests.sh b/scripts/circleci/run-local-browser-tests.sh new file mode 100755 index 00000000000..dafd32deead --- /dev/null +++ b/scripts/circleci/run-local-browser-tests.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# In case any command failed, we want to immediately exit the script with the +# proper exit code. +set -e + +# Go to project directory. +cd $(dirname ${0})/../.. + +# In case the "snapshot_tests" workflow is currently running this script, we +# want to run the local browser tests against the Angular snapshot builds. +if [[ "${CIRCLE_WORKFLOW_ID}" == "snapshot_tests" ]]; then + ./scripts/install-angular-snapshots.sh +fi + +# Setup the test platform environment variable that will be read +# by the Karma configuration script. +export TEST_PLATFORM="local" + +# Run the unit tests on the local browsers with Karma. +yarn gulp ci:test diff --git a/scripts/install-angular-snapshot.sh b/scripts/install-angular-snapshots.sh similarity index 100% rename from scripts/install-angular-snapshot.sh rename to scripts/install-angular-snapshots.sh