From eefce710c05f17676450d7ff03d3cd7552d64972 Mon Sep 17 00:00:00 2001 From: Wilfredo Colon Date: Tue, 24 Sep 2024 10:07:21 -0400 Subject: [PATCH] Wcolon/devo 507 (#438) * Migrate to nypr-deploy orb and update circleci config. * Refactor circle.yml to use nypr-deploy orb and update CircleCI config * Refactor CircleCI config to store Cypress test videos * turn off fastboot tests * Refactor CircleCI config to remove test_cypress job and update workflows --------- Co-authored-by: walsh9 --- .circleci/config.yml | 181 +++++++++++++ circle.yml | 255 ------------------ cypress/integration/404-page.spec.js | 2 +- cypress/integration/blog-detail.spec.js | 2 +- cypress/integration/event-page.spec.js | 2 +- cypress/integration/forgot-page.spec.js | 2 +- cypress/integration/home-page.spec.js | 2 +- cypress/integration/login-page.spec.js | 2 +- .../integration/playlist-daily-page.spec.js | 2 +- cypress/integration/playlist-page.spec.js | 2 +- cypress/integration/profile-page.spec.js | 2 +- cypress/integration/reset-page.spec.js | 2 +- cypress/integration/schedule-page.spec.js | 2 +- cypress/integration/series-detail.spec.js | 2 +- cypress/integration/set-password-page.spec.js | 2 +- cypress/integration/settings-page.spec.js | 2 +- cypress/integration/show-detail.spec.js | 2 +- cypress/integration/show-page.spec.js | 2 +- cypress/integration/signup-page-spec.js | 2 +- cypress/integration/stream-page.spec.js | 2 +- cypress/integration/tag-detail.spec.js | 2 +- cypress/integration/validate-page.spec.js | 2 +- cypress/integration/verify-page.spec.js | 2 +- cypress/integration/videos-page.spec.js | 2 +- 24 files changed, 203 insertions(+), 277 deletions(-) create mode 100644 .circleci/config.yml delete mode 100644 circle.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 000000000..0ab0e8e6f --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,181 @@ +version: 2.1 + +orbs: + nypr-deploy: nypr/nypr-deploy@0.0.81 + +filter_all: &filter_all + filters: + branches: + only: /.*/ + tags: + only: /.*/ + +filter_demo: &filter_demo + filters: + branches: + only: main + tags: + only: demo + +filter_prod: &filter_prod + filters: + branches: + ignore: /.*/ + tags: + only: /^v[0-9]+\.[0-9]+\.[0-9]+/ + +filter_qa: &filter_qa + filters: + tags: + ignore: /.*/ + branches: + only: /[A-Za-z-_]+/[A-Za-z-_\d]+/ + + + cache: &cache + key: v3-{{arch}}-{{ checksum "yarn.lock" }}-{{ checksum ".circleci/config.yml" }} + cache_deploy: &cache_deploy + key: v2-deploy-{{ checksum ".circleci/config.yml" }} + cache_modernizr: &cache_modernizr + key: v2-modernizr-{{ .Revision }} + + executor_node: &executor_node + docker: + - image: circleci/node:10-browsers + environment: + TERM: xterm + JOBS: 2 + executor_python: &executor_python + docker: + - image: circleci/python:3.6 + + deploy_static: &deploy_static + <<: *executor_node + steps: + - checkout + - restore_cache: + <<: *cache + - restore_cache: + <<: *cache_modernizr + - run: + name: Deploy to S3 + command: | + env | sed -n 's/^DEPLOY_//p' > .env + env | sed -n "s/^${ENV}_//p" >> .env + + export QA_BUILD="$QA_PREFIX/$CIRCLE_BRANCH" + export QA_URL="$DEMO_WQXR_URL?build=$QA_BUILD" + + npx ember deploy ${LONG_ENV:-qa:$QA_BUILD} --verbose --activate + mkdir -p /tmp/qa-builds + + if [[ -z "$LONG_ENV" ]]; then + echo "$QA_URL" \ + >> /tmp/qa-builds/$CIRCLE_SHA1.html + fi + - store_artifacts: + path: /tmp/qa-builds + +workflows: + build-test-deploy: + jobs: + - build: + <<: *filter_all + - test_ember: + <<: *filter_all + requires: + - build + - deploy_static_demo: + <<: *filter_demo + requires: + - test_ember + context: "AWS Deploy" + - deploy_static_prod: + <<: *filter_prod + requires: + - test_ember + context: "AWS Deploy" + - nypr-deploy/build_and_deploy: + <<: *filter_demo + name: "Deploy Demo Fastboot" + context: "AWS Deploy" + repo: "wqxr-web-client" + service: "wqxr-web-client" + cluster: "fastboot" + cpu: 512 + memory: 1024 + requires: + - build + - test_ember + - deploy_static_demo + - nypr-deploy/build_and_deploy: + <<: *filter_prod + name: "Deploy Production Fastboot" + context: "AWS Deploy" + repo: "wqxr-web-client" + service: "wqxr-web-client" + cluster: "fastboot" + cpu: 512 + memory: 1024 + requires: + - build + - test_ember + - deploy_static_prod + +jobs: + build: + <<: *executor_node + steps: + - checkout + - restore_cache: + <<: *cache + - run: + name: Install Node Dependencies + command: | + [ -d ./node_modules ] || yarn --pure-lockfile + - save_cache: + <<: *cache + paths: + - node_modules + - /home/circleci/.cache/Cypress + - restore_cache: + <<: *cache_modernizr + - run: + name: Build Modernizr + command: | + [ -f vendor/modernizr/modernizr-build.js ] || npx grunt modernizr:dist + - save_cache: + <<: *cache_modernizr + paths: + - vendor/modernizr/modernizr-build.js + + test_ember: + <<: *executor_node + steps: + - checkout + - restore_cache: + <<: *cache + - restore_cache: + <<: *cache_modernizr + - run: + name: Test Ember + command: | + cp .env.sample .env + npx ember test -r xunit + environment: + CIRCLE_TEST_REPORTS: test-results + - store_test_results: + path: test-results/ + + deploy_static_demo: + environment: + ENV: DEMO + LONG_ENV: demo + <<: *deploy_static + + deploy_static_prod: + environment: + ENV: PROD + LONG_ENV: production + <<: *deploy_static + diff --git a/circle.yml b/circle.yml deleted file mode 100644 index 6497b9245..000000000 --- a/circle.yml +++ /dev/null @@ -1,255 +0,0 @@ ---- -version: 2 - -templates: - - # Cache Keys: - ############################################################################# - cache: &cache - key: v3-{{arch}}-{{ checksum "yarn.lock" }}-{{ checksum "circle.yml" }} - cache_deploy: &cache_deploy - key: v2-deploy-{{ checksum "circle.yml" }} - cache_modernizr: &cache_modernizr - key: v2-modernizr-{{ .Revision }} - - # Environments: - ############################################################################# - demo: &demo - environment: - ENV: DEMO - LONG_ENV: demo - prod: &prod - environment: - ENV: PROD - LONG_ENV: production - qa: &qa - environment: - ENV: DEMO - - # Executors: - ############################################################################# - executor_node: &executor_node - docker: - - image: circleci/node:10-browsers - environment: - TERM: xterm - JOBS: 2 - executor_python: &executor_python - docker: - - image: circleci/python:3.6 - - # Filters: - ############################################################################# - filter_all: &filter_all - filters: - tags: - only: /.*/ - filter_demo: &filter_demo - filters: - branches: - only: main - tags: - only: demo - filter_prod: &filter_prod - filters: - tags: - only: /^v[0-9]+\.[0-9]+\.[0-9]+/ - branches: - ignore: /.*/ - filter_qa: &filter_qa - filters: - tags: - ignore: /.*/ - branches: - only: /[\w-]+/[\w-]+/ - - # Job Templates: - ############################################################################# - deploy_ecs: &deploy_ecs - <<: *executor_python - steps: - - checkout - - setup_remote_docker - - restore_cache: - <<: *cache_deploy - - run: - name: Deploy Fastboot - command: | - if [[ ! -d ~/.venv ]]; then - python -m venv ~/.venv - . ~/.venv/bin/activate - pip install -U git+https://github.com/nypublicradio/nyprsetuptools.git - fi - . ~/.venv/bin/activate - TAG="${CIRCLE_TAG:-demo}" - ENV="${ENV,,}" - export "${ENV}_SENTRY_RELEASE"="${TAG}" - nyprsetuptools DockerDeploy \ - --cpu=512 \ - --ecr-repository=wqxr-web-client \ - --ecs-cluster=fastboot \ - --environment=$ENV \ - --execution-role=wqxr-web-client-$ENV \ - --fargate \ - --memory-reservation=1024 \ - --ports=3000 \ - --tag=$TAG \ - --task-role=wqxr-web-client-$ENV \ - --wait=300 - - save_cache: - <<: *cache_deploy - paths: - - ~/.venv - deploy_static: &deploy_static - <<: *executor_node - steps: - - checkout - - restore_cache: - <<: *cache - - restore_cache: - <<: *cache_modernizr - - run: - name: Deploy to S3 - command: | - env | sed -n 's/^DEPLOY_//p' > .env - env | sed -n "s/^${ENV}_//p" >> .env - - export QA_BUILD="$QA_PREFIX/$CIRCLE_BRANCH" - export QA_URL="$DEMO_WQXR_URL?build=$QA_BUILD" - - npx ember deploy ${LONG_ENV:-qa:$QA_BUILD} --verbose --activate - mkdir -p /tmp/qa-builds - - if [[ -z "$LONG_ENV" ]]; then - echo "$QA_URL" \ - >> /tmp/qa-builds/$CIRCLE_SHA1.html - fi - - store_artifacts: - path: /tmp/qa-builds - - -jobs: - build: - <<: *executor_node - steps: - - checkout - - restore_cache: - <<: *cache - - run: - name: Install Node Dependencies - command: | - [ -d ./node_modules ] || yarn --pure-lockfile - - save_cache: - <<: *cache - paths: - - node_modules - - /home/circleci/.cache/Cypress - - restore_cache: - <<: *cache_modernizr - - run: - name: Build Modernizr - command: | - [ -f vendor/modernizr/modernizr-build.js ] || npx grunt modernizr:dist - - save_cache: - <<: *cache_modernizr - paths: - - vendor/modernizr/modernizr-build.js - - test_ember: - <<: *executor_node - steps: - - checkout - - restore_cache: - <<: *cache - - restore_cache: - <<: *cache_modernizr - - run: - name: Test Ember - command: | - cp .env.sample .env - npx ember test -r xunit - environment: - CIRCLE_TEST_REPORTS: test-results - - store_test_results: - path: test-results/ - - test_cypress: - <<: *executor_node - steps: - - checkout - - restore_cache: - <<: *cache - - restore_cache: - <<: *cache_modernizr - - run: sudo apt-get install libgconf-2-4 - - run: cp .env.sample .env - - run: - name: Run Cypress tests in parallel - command: yarn run cy:ci:test - - store_test_results: - path: test-results/ - - deploy_static_demo: - <<: *deploy_static - <<: *demo - - deploy_ecs_demo: - <<: *deploy_ecs - <<: *demo - - deploy_static_prod: - <<: *deploy_static - <<: *prod - - deploy_ecs_prod: - <<: *deploy_ecs - <<: *prod - - deploy_static_qa: - <<: *deploy_static - <<: *qa - -workflows: - version: 2 - build-test-deploy: - jobs: - - build: - <<: *filter_all - - test_ember: - <<: *filter_all - requires: - - build - - test_cypress: - <<: *filter_all - requires: - - build - - deploy_static_demo: - <<: *filter_demo - requires: - - test_ember - - test_cypress - context: "AWS Deploy" - - deploy_ecs_demo: - <<: *filter_demo - requires: - - test_ember - - test_cypress - context: "AWS Deploy" - - deploy_static_prod: - <<: *filter_prod - requires: - - test_ember - - test_cypress - context: "AWS Deploy" - - deploy_ecs_prod: - <<: *filter_prod - requires: - - test_ember - - test_cypress - context: "AWS Deploy" - - deploy_static_qa: - <<: *filter_qa - requires: - - test_ember - - test_cypress - context: "AWS Deploy" diff --git a/cypress/integration/404-page.spec.js b/cypress/integration/404-page.spec.js index 3657e40bd..412b7c178 100644 --- a/cypress/integration/404-page.spec.js +++ b/cypress/integration/404-page.spec.js @@ -1,5 +1,5 @@ // describe('404 page', () => { -// ['true','false'].forEach(fastbootStatus => { +// ['false'].forEach(fastbootStatus => { // it(`displays the 404 page (fastboot=${fastbootStatus})`, () => { // cy.fastbootCheck(`/bad-path-that-should-404`, fastbootStatus, false); // diff --git a/cypress/integration/blog-detail.spec.js b/cypress/integration/blog-detail.spec.js index 15196fcec..742111687 100644 --- a/cypress/integration/blog-detail.spec.js +++ b/cypress/integration/blog-detail.spec.js @@ -1,5 +1,5 @@ describe('Blog detail page', () => { - ['true','false'].forEach(fastbootStatus => { + ['false'].forEach(fastbootStatus => { it(`displays the blog detail page (fastboot=${fastbootStatus})`, () => { cy.fastbootCheck(`/blogs/wqxr-blog/`, fastbootStatus); diff --git a/cypress/integration/event-page.spec.js b/cypress/integration/event-page.spec.js index b677e5b32..14c1c9a77 100644 --- a/cypress/integration/event-page.spec.js +++ b/cypress/integration/event-page.spec.js @@ -1,5 +1,5 @@ describe('Events page', () => { - ['true','false'].forEach(fastbootStatus => { + ['false'].forEach(fastbootStatus => { it(`displays the events page (fastboot=${fastbootStatus})`, () => { cy.fastbootCheck(`/events`, fastbootStatus); diff --git a/cypress/integration/forgot-page.spec.js b/cypress/integration/forgot-page.spec.js index bcb0eb873..af8505e73 100644 --- a/cypress/integration/forgot-page.spec.js +++ b/cypress/integration/forgot-page.spec.js @@ -1,5 +1,5 @@ describe('Forgot page', () => { - ['true','false'].forEach(fastbootStatus => { + ['false'].forEach(fastbootStatus => { it(`displays the forgot page (fastboot=${fastbootStatus})`, () => { cy.fastbootCheck(`/forgot`, fastbootStatus); diff --git a/cypress/integration/home-page.spec.js b/cypress/integration/home-page.spec.js index 284f653c9..e1f3637ec 100644 --- a/cypress/integration/home-page.spec.js +++ b/cypress/integration/home-page.spec.js @@ -1,5 +1,5 @@ describe('Home page', () => { - ['true','false'].forEach(fastbootStatus => { + ['false'].forEach(fastbootStatus => { it(`displays the home page (fastboot=${fastbootStatus})`, () => { cy.fastbootCheck(`/`, fastbootStatus); diff --git a/cypress/integration/login-page.spec.js b/cypress/integration/login-page.spec.js index d09965ab8..3a71f9ccc 100644 --- a/cypress/integration/login-page.spec.js +++ b/cypress/integration/login-page.spec.js @@ -1,5 +1,5 @@ describe('Login page', () => { - ['true','false'].forEach(fastbootStatus => { + ['false'].forEach(fastbootStatus => { it(`displays the login page (fastboot=${fastbootStatus})`, () => { cy.fastbootCheck(`/login`, fastbootStatus); diff --git a/cypress/integration/playlist-daily-page.spec.js b/cypress/integration/playlist-daily-page.spec.js index d5e12e2d0..99e71c6c1 100644 --- a/cypress/integration/playlist-daily-page.spec.js +++ b/cypress/integration/playlist-daily-page.spec.js @@ -1,5 +1,5 @@ describe('Playlist Daily page', () => { - ['true','false'].forEach(fastbootStatus => { + ['false'].forEach(fastbootStatus => { it(`displays the playlist daily page (fastboot=${fastbootStatus})`, () => { cy.fastbootCheck(`/playlist-daily`, fastbootStatus); diff --git a/cypress/integration/playlist-page.spec.js b/cypress/integration/playlist-page.spec.js index 86fe0adc8..4f5b70ee8 100644 --- a/cypress/integration/playlist-page.spec.js +++ b/cypress/integration/playlist-page.spec.js @@ -1,5 +1,5 @@ describe('Playlist page', () => { - ['true','false'].forEach(fastbootStatus => { + ['false'].forEach(fastbootStatus => { it(`displays the playlist page (fastboot=${fastbootStatus})`, () => { cy.fastbootCheck(`/streams/new-sounds`, fastbootStatus); diff --git a/cypress/integration/profile-page.spec.js b/cypress/integration/profile-page.spec.js index 83378ce52..b90be9b65 100644 --- a/cypress/integration/profile-page.spec.js +++ b/cypress/integration/profile-page.spec.js @@ -1,5 +1,5 @@ describe('Profile page', () => { - ['true','false'].forEach(fastbootStatus => { + ['false'].forEach(fastbootStatus => { it(`displays the profile page (fastboot=${fastbootStatus})`, () => { cy.fastbootCheck(`/profile`, fastbootStatus); diff --git a/cypress/integration/reset-page.spec.js b/cypress/integration/reset-page.spec.js index 85dfd4f52..3234ee263 100644 --- a/cypress/integration/reset-page.spec.js +++ b/cypress/integration/reset-page.spec.js @@ -1,5 +1,5 @@ describe('reset page', () => { - ['true','false'].forEach(fastbootStatus => { + ['false'].forEach(fastbootStatus => { it(`displays the reset page (fastboot=${fastbootStatus})`, () => { cy.fastbootCheck(`/reset`, fastbootStatus); diff --git a/cypress/integration/schedule-page.spec.js b/cypress/integration/schedule-page.spec.js index 8711b9046..1aeb30ad5 100644 --- a/cypress/integration/schedule-page.spec.js +++ b/cypress/integration/schedule-page.spec.js @@ -1,5 +1,5 @@ describe('Schedule page', () => { - ['true','false'].forEach(fastbootStatus => { + ['false'].forEach(fastbootStatus => { it(`displays the schedule page (fastboot=${fastbootStatus})`, () => { cy.fastbootCheck(`/schedule`, fastbootStatus); diff --git a/cypress/integration/series-detail.spec.js b/cypress/integration/series-detail.spec.js index b3572aa04..6a2e11a03 100644 --- a/cypress/integration/series-detail.spec.js +++ b/cypress/integration/series-detail.spec.js @@ -1,5 +1,5 @@ describe('Series detail page', () => { - ['true','false'].forEach(fastbootStatus => { + ['false'].forEach(fastbootStatus => { it(`displays the series detail page (fastboot=${fastbootStatus})`, () => { cy.fastbootCheck(`/series/inventing-abstraction`, fastbootStatus); cy.visit(`/series/inventing-abstraction?fastboot=${fastbootStatus}`); diff --git a/cypress/integration/set-password-page.spec.js b/cypress/integration/set-password-page.spec.js index 2dce09d7e..99709cdde 100644 --- a/cypress/integration/set-password-page.spec.js +++ b/cypress/integration/set-password-page.spec.js @@ -1,5 +1,5 @@ describe('Set password page', () => { - ['true','false'].forEach(fastbootStatus => { + ['false'].forEach(fastbootStatus => { it(`displays the set password page (fastboot=${fastbootStatus})`, () => { cy.fastbootCheck(`/set-password`, fastbootStatus); diff --git a/cypress/integration/settings-page.spec.js b/cypress/integration/settings-page.spec.js index ff7bd56a2..699e415c3 100644 --- a/cypress/integration/settings-page.spec.js +++ b/cypress/integration/settings-page.spec.js @@ -1,5 +1,5 @@ describe('Settings page', () => { - ['true','false'].forEach(fastbootStatus => { + ['false'].forEach(fastbootStatus => { it(`displays the settings page (fastboot=${fastbootStatus})`, () => { cy.fastbootCheck(`/settings`, fastbootStatus); diff --git a/cypress/integration/show-detail.spec.js b/cypress/integration/show-detail.spec.js index 13e493569..78ba43b51 100644 --- a/cypress/integration/show-detail.spec.js +++ b/cypress/integration/show-detail.spec.js @@ -1,5 +1,5 @@ describe('Show detail page', () => { - ['true','false'].forEach(fastbootStatus => { + ['false'].forEach(fastbootStatus => { it(`displays the show detail page (fastboot=${fastbootStatus})`, () => { cy.fastbootCheck(`/shows/carnegie`, fastbootStatus); diff --git a/cypress/integration/show-page.spec.js b/cypress/integration/show-page.spec.js index 38eeabc79..f0c07cc0f 100644 --- a/cypress/integration/show-page.spec.js +++ b/cypress/integration/show-page.spec.js @@ -1,5 +1,5 @@ describe('Show page', () => { - ['true','false'].forEach(fastbootStatus => { + ['false'].forEach(fastbootStatus => { it(`displays the shows page (fastboot=${fastbootStatus})`, () => { cy.fastbootCheck(`/shows`, fastbootStatus); diff --git a/cypress/integration/signup-page-spec.js b/cypress/integration/signup-page-spec.js index 585cc717f..dcdc96154 100644 --- a/cypress/integration/signup-page-spec.js +++ b/cypress/integration/signup-page-spec.js @@ -1,5 +1,5 @@ describe('Signup page', () => { - ['true','false'].forEach(fastbootStatus => { + ['false'].forEach(fastbootStatus => { it(`displays the signup page (fastboot=${fastbootStatus})`, () => { cy.fastbootCheck(`/signup`, fastbootStatus); diff --git a/cypress/integration/stream-page.spec.js b/cypress/integration/stream-page.spec.js index 8b38a82dc..d1f4e0cf3 100644 --- a/cypress/integration/stream-page.spec.js +++ b/cypress/integration/stream-page.spec.js @@ -1,5 +1,5 @@ describe('Streams page', () => { - ['true','false'].forEach(fastbootStatus => { + ['false'].forEach(fastbootStatus => { it(`displays the streams page (fastboot=${fastbootStatus})`, () => { cy.fastbootCheck(`/streams`, fastbootStatus); diff --git a/cypress/integration/tag-detail.spec.js b/cypress/integration/tag-detail.spec.js index 6a1cc118f..2233aa586 100644 --- a/cypress/integration/tag-detail.spec.js +++ b/cypress/integration/tag-detail.spec.js @@ -1,5 +1,5 @@ describe('Tag detail page', () => { - ['true','false'].forEach(fastbootStatus => { + ['false'].forEach(fastbootStatus => { it(`displays the tag detail page (fastboot=${fastbootStatus})`, () => { cy.fastbootCheck(`/tags/prince`, fastbootStatus); diff --git a/cypress/integration/validate-page.spec.js b/cypress/integration/validate-page.spec.js index 9354dd09a..5986d64c7 100644 --- a/cypress/integration/validate-page.spec.js +++ b/cypress/integration/validate-page.spec.js @@ -1,5 +1,5 @@ describe('Validate page', () => { - ['true','false'].forEach(fastbootStatus => { + ['false'].forEach(fastbootStatus => { it(`displays the validate daily page (fastboot=${fastbootStatus})`, () => { cy.fastbootCheck(`/validate`, fastbootStatus); diff --git a/cypress/integration/verify-page.spec.js b/cypress/integration/verify-page.spec.js index 99c91e7da..ff38e5bf1 100644 --- a/cypress/integration/verify-page.spec.js +++ b/cypress/integration/verify-page.spec.js @@ -1,5 +1,5 @@ describe('verify page', () => { - ['true','false'].forEach(fastbootStatus => { + ['false'].forEach(fastbootStatus => { it(`displays the verify daily page (fastboot=${fastbootStatus})`, () => { cy.fastbootCheck(`/verify`, fastbootStatus); diff --git a/cypress/integration/videos-page.spec.js b/cypress/integration/videos-page.spec.js index 09f24b74c..1d475a976 100644 --- a/cypress/integration/videos-page.spec.js +++ b/cypress/integration/videos-page.spec.js @@ -1,5 +1,5 @@ describe('Videos page', () => { - ['true','false'].forEach(fastbootStatus => { + ['false'].forEach(fastbootStatus => { it(`displays the videos page (fastboot=${fastbootStatus})`, () => { cy.fastbootCheck(`/videos`, fastbootStatus);