From 64187a9142c7df3a6edcc2b840b7e96a7c703d17 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Thu, 16 Apr 2020 23:48:05 -0400 Subject: [PATCH 01/15] update to config.yml --- .circleci/config.ch9.yml | 85 ------------- .circleci/config.master.yml | 200 ++++++++++++++++++++++++++++++ .circleci/config.yml | 236 +++++++++++------------------------- 3 files changed, 268 insertions(+), 253 deletions(-) delete mode 100644 .circleci/config.ch9.yml create mode 100644 .circleci/config.master.yml diff --git a/.circleci/config.ch9.yml b/.circleci/config.ch9.yml deleted file mode 100644 index 7c84332e..00000000 --- a/.circleci/config.ch9.yml +++ /dev/null @@ -1,85 +0,0 @@ -version: 2.1 -orbs: - coveralls: coveralls/coveralls@1.0.4 -jobs: - build: - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - checkout - - restore_cache: - keys: - - v1-dependencies-{{ checksum "package-lock.json" }} - # fallback to using the latest cache if no exact match is found - - v1-dependencies- - - - run: npm ci - - # force update the webdriver, so it runs with latest version of Chrome - - run: cd ./node_modules/protractor && npm i webdriver-manager@latest - - # because we use "npm ci" to install NPM dependencies - # we cache "~/.npm" folder - - save_cache: - paths: - - ~/.npm - key: v1-dependencies-{{ checksum "package-lock.json" }} - - - run: npm run style - - run: npm run lint - - - run: npm run build:prod - - run: npm run test:coverage -- --watch=false - - run: npm run e2e - - - store_test_results: - path: ./test_results - - store_artifacts: - path: ./coverage - - # upload coverage report to coveralls for readme badge support - # requires config.yml version 2.1 and orbs: coveralls: coveralls/coveralls@1.0.4 - # requires coveralls account and token named COVERALLS_REPO_TOKEN specific to repo to be stored in CircleCI - - coveralls/upload - - - run: - name: Tar & Gzip compiled app - command: tar zcf dist.tar.gz dist/local-weather-app - - store_artifacts: - path: dist.tar.gz - - - run: - name: Move compiled app to workspace - command: | - set -exu - mkdir -p /tmp/workspace/dist - mv dist/local-weather-app /tmp/workspace/dist/ - - persist_to_workspace: - root: /tmp/workspace - paths: - - dist/local-weather-app - deploy: - docker: - - image: circleci/node:lts - working_directory: ~/repo - steps: - - attach_workspace: - at: /tmp/workspace - - run: npx now --token $NOW_TOKEN --platform-version 2 --prod /tmp/workspace/dist/local-weather-app --confirm - -workflows: - version: 2 - build-test-and-approval-deploy: - jobs: - - build - - hold: - type: approval - requires: - - build - filters: - branches: - only: master - - deploy: - requires: - - hold diff --git a/.circleci/config.master.yml b/.circleci/config.master.yml new file mode 100644 index 00000000..57e3a377 --- /dev/null +++ b/.circleci/config.master.yml @@ -0,0 +1,200 @@ +version: 2.1 +orbs: + coveralls: coveralls/coveralls@1.0.4 +commands: + install: + description: 'Install project dependencies' + parameters: + warm-cache: + type: boolean + default: false + steps: + - checkout + - restore_cache: + keys: + - node_modules-{{ checksum "package-lock.json" }} + - when: + condition: << parameters.warm-cache >> + steps: + - run: npm install + # Pre-build Angular modules + - run: npx ngcc --properties es2015 --async false # async false is temp CI build fix + # force update the webdriver, so it runs with latest version of Chrome + - run: cd ./node_modules/protractor && npm i webdriver-manager@latest + - save_cache: + key: node_modules-{{ checksum "package-lock.json" }} + paths: + - node_modules + lint: + description: 'Check for code style and linting errors' + steps: + - run: npm run style + - run: npm run lint + build_and_test: + description: 'Build command that accepts Angular project name as parameter' + parameters: + project: + type: string + default: 'local-weather-app' + run-tests: + type: boolean + default: true + steps: + - run: npx ng build --prod --project << parameters.project >> + - when: + condition: << parameters.run-tests >> + steps: + - run: npx ng test --code-coverage --watch=false --project << parameters.project >> + - run: npx ng e2e << parameters.project >> + store: + description: 'Stores build_and_test artifacts' + parameters: + project: + type: string + default: 'local-weather-app' + steps: + - store_test_results: + path: ./test_results + - store_artifacts: + path: ./coverage + + # upload coverage report to coveralls for readme badge support + # requires config.yml version 2.1 and orbs: coveralls: coveralls/coveralls@1.0.4 + # requires coveralls account and token named COVERALLS_REPO_TOKEN specific to repo to be stored in CircleCI + - coveralls/upload + + - run: + name: Tar & Gzip compiled app + command: tar zcf dist.tar.gz dist/<< parameters.project >> + - store_artifacts: + path: dist.tar.gz + + - run: + name: Move compiled app to workspace + command: | + set -exu + mkdir -p /tmp/workspace/dist + mv dist/<< parameters.project >> /tmp/workspace/dist/ + - persist_to_workspace: + root: /tmp/workspace + paths: + - dist/<< parameters.project >> + deploy_now: + description: 'Deploys project to Zeit Now --> https://now.sh' + parameters: + project: + type: string + default: 'local-weather-app' + steps: + - attach_workspace: + at: /tmp/workspace + - run: npx now --token $NOW_TOKEN --platform-version 2 --prod /tmp/workspace/dist/<< parameters.project >> --confirm +jobs: + initialize: + docker: + - image: circleci/node:lts-browsers + working_directory: ~/repo + steps: + - install: + warm-cache: true + default: + docker: + - image: circleci/node:lts-browsers + working_directory: ~/repo + steps: + - install + - lint + - build_and_test + - store + deploy: + docker: + - image: circleci/node:lts + working_directory: ~/repo + steps: + - deploy_now + + ch2: # this job is only here to verify sample code from the book, remove it in your own projects + docker: + - image: circleci/node:lts-browsers + working_directory: ~/repo + steps: + - install + - build_and_test: + project: 'ch2' + ch3: # this job is only here to verify sample code from the book, remove it in your own projects + docker: + - image: circleci/node:lts-browsers + working_directory: ~/repo + steps: + - install + - build_and_test: + project: 'ch3' + run-tests: false + ch4: # this job is only here to verify sample code from the book, remove it in your own projects + docker: + - image: circleci/node:lts-browsers + working_directory: ~/repo + steps: + - install + - build_and_test: + project: 'ch4' + ch5: # this job is only here to verify sample code from the book, remove it in your own projects + docker: + - image: circleci/node:lts-browsers + working_directory: ~/repo + steps: + - install + - build_and_test: + project: 'ch5' + ch6: # this job is only here to verify sample code from the book, remove it in your own projects + docker: + - image: circleci/node:lts-browsers + working_directory: ~/repo + steps: + - install + - build_and_test: + project: 'ch6' + ch12: # this job is only here to verify sample code from the book, remove it in your own projects + docker: + - image: circleci/node:lts-browsers + working_directory: ~/repo + steps: + - install + - build_and_test: + project: 'ch12' +workflows: + version: 2 + build-test-and-approval-deploy: + jobs: + - initialize + - default: + requires: + - initialize + - ch2: # this job is only here to verify sample code from the book, remove it in your own projects + requires: + - initialize + - ch3: # this job is only here to verify sample code from the book, remove it in your own projects + requires: + - initialize + - ch4: # this job is only here to verify sample code from the book, remove it in your own projects + requires: + - initialize + - ch5: # this job is only here to verify sample code from the book, remove it in your own projects + requires: + - initialize + - ch6: # this job is only here to verify sample code from the book, remove it in your own projects + requires: + - initialize + # - ch12: # this job is only here to verify sample code from the book, remove it in your own projects + # requires: + # - initialize + - hold: + type: approval + requires: + - default + filters: + branches: + only: master + - deploy: + requires: + - hold diff --git a/.circleci/config.yml b/.circleci/config.yml index 57e3a377..c367197c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,71 +1,44 @@ version: 2.1 orbs: - coveralls: coveralls/coveralls@1.0.4 -commands: - install: - description: 'Install project dependencies' - parameters: - warm-cache: - type: boolean - default: false + gcp-cloud-run: circleci/gcp-cloud-run@1.0.2 +jobs: + build: + docker: + - image: circleci/node:lts-browsers + working_directory: ~/repo steps: - checkout - restore_cache: keys: - - node_modules-{{ checksum "package-lock.json" }} - - when: - condition: << parameters.warm-cache >> - steps: - - run: npm install - # Pre-build Angular modules - - run: npx ngcc --properties es2015 --async false # async false is temp CI build fix - # force update the webdriver, so it runs with latest version of Chrome - - run: cd ./node_modules/protractor && npm i webdriver-manager@latest - - save_cache: - key: node_modules-{{ checksum "package-lock.json" }} - paths: - - node_modules - lint: - description: 'Check for code style and linting errors' - steps: + - v1-dependencies-{{ checksum "package-lock.json" }} + # fallback to using the latest cache if no exact match is found + - v1-dependencies- + + - run: npm ci + + # force update the webdriver, so it runs with latest version of Chrome + - run: cd ./node_modules/protractor && npm i webdriver-manager@latest + + # because we use "npm ci" to install NPM dependencies + # we cache "~/.npm" folder + - save_cache: + paths: + - ~/.npm + key: v1-dependencies-{{ checksum "package-lock.json" }} + - run: npm run style - run: npm run lint - build_and_test: - description: 'Build command that accepts Angular project name as parameter' - parameters: - project: - type: string - default: 'local-weather-app' - run-tests: - type: boolean - default: true - steps: - - run: npx ng build --prod --project << parameters.project >> - - when: - condition: << parameters.run-tests >> - steps: - - run: npx ng test --code-coverage --watch=false --project << parameters.project >> - - run: npx ng e2e << parameters.project >> - store: - description: 'Stores build_and_test artifacts' - parameters: - project: - type: string - default: 'local-weather-app' - steps: + + - run: npm run build:prod + - run: npm run test + - run: npm run e2e + - store_test_results: path: ./test_results - - store_artifacts: - path: ./coverage - - # upload coverage report to coveralls for readme badge support - # requires config.yml version 2.1 and orbs: coveralls: coveralls/coveralls@1.0.4 - # requires coveralls account and token named COVERALLS_REPO_TOKEN specific to repo to be stored in CircleCI - - coveralls/upload - run: name: Tar & Gzip compiled app - command: tar zcf dist.tar.gz dist/<< parameters.project >> + command: tar zcf dist.tar.gz dist/local-weather-app - store_artifacts: path: dist.tar.gz @@ -74,127 +47,54 @@ commands: command: | set -exu mkdir -p /tmp/workspace/dist - mv dist/<< parameters.project >> /tmp/workspace/dist/ + mv dist/local-weather-app /tmp/workspace/dist/ - persist_to_workspace: root: /tmp/workspace paths: - - dist/<< parameters.project >> - deploy_now: - description: 'Deploys project to Zeit Now --> https://now.sh' - parameters: - project: - type: string - default: 'local-weather-app' - steps: - - attach_workspace: - at: /tmp/workspace - - run: npx now --token $NOW_TOKEN --platform-version 2 --prod /tmp/workspace/dist/<< parameters.project >> --confirm -jobs: - initialize: - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - install: - warm-cache: true - default: + - dist/local-weather-app + deploy_cloudrun: docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo + - image: 'cimg/base:stable' steps: - - install - - lint - - build_and_test - - store - deploy: - docker: - - image: circleci/node:lts - working_directory: ~/repo + working_directory: ~/repo steps: - - deploy_now + - attach_workspace: + at: /tmp/workspace + - checkout + - run: + name: Copy built app to dist folder + command: cp -R /tmp/workspace/dist/local-weather-app dist/ + - cloudrun/init + - cloudrun/build: + tag: 'gcr.io/${GOOGLE_PROJECT_ID}/test-${CIRCLE_SHA1}' + - cloudrun/deploy: + image: 'gcr.io/${GOOGLE_PROJECT_ID}/test-${CIRCLE_SHA1}' + platform: managed + region: us-east1 + service-name: localcast-weather + unauthenticated: true + - run: + command: > + # A simple example of how a deployed managed service could be + verified or further tested. - ch2: # this job is only here to verify sample code from the book, remove it in your own projects - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - install - - build_and_test: - project: 'ch2' - ch3: # this job is only here to verify sample code from the book, remove it in your own projects - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - install - - build_and_test: - project: 'ch3' - run-tests: false - ch4: # this job is only here to verify sample code from the book, remove it in your own projects - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - install - - build_and_test: - project: 'ch4' - ch5: # this job is only here to verify sample code from the book, remove it in your own projects - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - install - - build_and_test: - project: 'ch5' - ch6: # this job is only here to verify sample code from the book, remove it in your own projects - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - install - - build_and_test: - project: 'ch6' - ch12: # this job is only here to verify sample code from the book, remove it in your own projects - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - install - - build_and_test: - project: 'ch12' + # This step will send request our "API" and fail if there is + unexpected output. + + GCP_API_RESULTS=$(curl -s "$GCP_DEPLOY_ENDPOINT") + + if [ "$GCP_API_RESULTS" != "Hello World!" ]; then + echo "Result is unexpected" + echo 'Result: ' + curl -s "$GCP_DEPLOY_ENDPOINT" + exit 1; + fi + name: Test managed deployed service. workflows: version: 2 - build-test-and-approval-deploy: + build-test-and-deploy: jobs: - - initialize - - default: - requires: - - initialize - - ch2: # this job is only here to verify sample code from the book, remove it in your own projects - requires: - - initialize - - ch3: # this job is only here to verify sample code from the book, remove it in your own projects - requires: - - initialize - - ch4: # this job is only here to verify sample code from the book, remove it in your own projects - requires: - - initialize - - ch5: # this job is only here to verify sample code from the book, remove it in your own projects - requires: - - initialize - - ch6: # this job is only here to verify sample code from the book, remove it in your own projects - requires: - - initialize - # - ch12: # this job is only here to verify sample code from the book, remove it in your own projects - # requires: - # - initialize - - hold: - type: approval - requires: - - default - filters: - branches: - only: master - - deploy: + - build + - deploy_cloudrun: requires: - - hold + - build From 734642aec59a13e0083a5a7eea347a6c66486a79 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Fri, 17 Apr 2020 00:01:18 -0400 Subject: [PATCH 02/15] update --- .circleci/config.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index c367197c..9dc23d82 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -57,7 +57,6 @@ jobs: - image: 'cimg/base:stable' steps: working_directory: ~/repo - steps: - attach_workspace: at: /tmp/workspace - checkout From e38f1ca6d3d28e7df1f38a4f1da85026dab5723e Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Fri, 17 Apr 2020 00:08:54 -0400 Subject: [PATCH 03/15] fix config --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9dc23d82..8f92e6c1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,6 +1,6 @@ version: 2.1 orbs: - gcp-cloud-run: circleci/gcp-cloud-run@1.0.2 + cloudrun: circleci/gcp-cloud-run@1.0.2 jobs: build: docker: @@ -55,8 +55,8 @@ jobs: deploy_cloudrun: docker: - image: 'cimg/base:stable' + working_directory: ~/repo steps: - working_directory: ~/repo - attach_workspace: at: /tmp/workspace - checkout From c0c72d05e39d22c806d7a7462e12460c429a489c Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Fri, 17 Apr 2020 00:18:47 -0400 Subject: [PATCH 04/15] update to pull ch6 code --- .circleci/config.yml | 14 +++++++------- Dockerfile | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8f92e6c1..0845a58a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -29,16 +29,16 @@ jobs: - run: npm run style - run: npm run lint - - run: npm run build:prod - - run: npm run test - - run: npm run e2e + - run: npx ng build ch6 --prod + - run: npx ng test --weather=false --project ch6 + - run: npx ng e2e --project ch6 - store_test_results: path: ./test_results - run: name: Tar & Gzip compiled app - command: tar zcf dist.tar.gz dist/local-weather-app + command: tar zcf dist.tar.gz dist/ch6 - store_artifacts: path: dist.tar.gz @@ -47,11 +47,11 @@ jobs: command: | set -exu mkdir -p /tmp/workspace/dist - mv dist/local-weather-app /tmp/workspace/dist/ + mv dist/ch6 /tmp/workspace/dist/ - persist_to_workspace: root: /tmp/workspace paths: - - dist/local-weather-app + - dist/ch6 deploy_cloudrun: docker: - image: 'cimg/base:stable' @@ -62,7 +62,7 @@ jobs: - checkout - run: name: Copy built app to dist folder - command: cp -R /tmp/workspace/dist/local-weather-app dist/ + command: cp -R /tmp/workspace/dist/ch6 dist/ - cloudrun/init - cloudrun/build: tag: 'gcr.io/${GOOGLE_PROJECT_ID}/test-${CIRCLE_SHA1}' diff --git a/Dockerfile b/Dockerfile index d81752f4..6a0d9e50 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM duluca/minimal-node-web-server:lts-alpine WORKDIR /usr/src/app -COPY dist/local-weather-app public +COPY dist/ch6 public #Overriding default ENTRYPOINT because gcloud doesn't like dumb-init ENTRYPOINT [ "npm", "start" ] From 943b185ad99012ba31ff8dc0bab9906568780677 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Fri, 17 Apr 2020 00:21:48 -0400 Subject: [PATCH 05/15] weather on my mind, and my mind on weather --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0845a58a..2430355a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -30,7 +30,7 @@ jobs: - run: npm run lint - run: npx ng build ch6 --prod - - run: npx ng test --weather=false --project ch6 + - run: npx ng test --watch=false --project ch6 - run: npx ng e2e --project ch6 - store_test_results: From 509f13b9cb95727dae6df88e3a41d1e24b3b5f5e Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Fri, 17 Apr 2020 01:20:05 -0400 Subject: [PATCH 06/15] update to dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6a0d9e50..233d4d09 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM duluca/minimal-node-web-server:lts-alpine WORKDIR /usr/src/app -COPY dist/ch6 public +COPY dist public #Overriding default ENTRYPOINT because gcloud doesn't like dumb-init ENTRYPOINT [ "npm", "start" ] From 8675cb69bb3c18717244131ef65fbf65520c42cb Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Fri, 17 Apr 2020 01:32:11 -0400 Subject: [PATCH 07/15] fix source --- .circleci/config.ch4.yml | 42 -------- .circleci/config.master.yml | 200 ------------------------------------ .circleci/config.yml | 1 + 3 files changed, 1 insertion(+), 242 deletions(-) delete mode 100644 .circleci/config.ch4.yml delete mode 100644 .circleci/config.master.yml diff --git a/.circleci/config.ch4.yml b/.circleci/config.ch4.yml deleted file mode 100644 index 7de02f84..00000000 --- a/.circleci/config.ch4.yml +++ /dev/null @@ -1,42 +0,0 @@ -version: 2.1 -jobs: - build: - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - checkout - - - restore_cache: - keys: - - v1-dependencies-{{ checksum "package-lock.json" }} - - - run: npm ci - - # force update the webdriver, so it runs with latest version of Chrome - - run: cd ./node_modules/protractor && npm i webdriver-manager@latest - - # because we use "npm ci" to install NPM dependencies - # we cache "~/.npm" folder - - save_cache: - key: v1-dependencies-{{ checksum "package-lock.json" }} - paths: - - ~/.npm - - - run: npm run style - - run: npm run lint - - - run: npm run build:prod - - run: npm run test:coverage -- --watch=false - - run: npm run e2e - - - run: - name: Tar & Gzip compiled app - command: tar zcf dist.tar.gz dist/local-weather-app - - store_artifacts: - path: dist.tar.gz -workflows: - version: 2 - build-and-test: - jobs: - - build diff --git a/.circleci/config.master.yml b/.circleci/config.master.yml deleted file mode 100644 index 57e3a377..00000000 --- a/.circleci/config.master.yml +++ /dev/null @@ -1,200 +0,0 @@ -version: 2.1 -orbs: - coveralls: coveralls/coveralls@1.0.4 -commands: - install: - description: 'Install project dependencies' - parameters: - warm-cache: - type: boolean - default: false - steps: - - checkout - - restore_cache: - keys: - - node_modules-{{ checksum "package-lock.json" }} - - when: - condition: << parameters.warm-cache >> - steps: - - run: npm install - # Pre-build Angular modules - - run: npx ngcc --properties es2015 --async false # async false is temp CI build fix - # force update the webdriver, so it runs with latest version of Chrome - - run: cd ./node_modules/protractor && npm i webdriver-manager@latest - - save_cache: - key: node_modules-{{ checksum "package-lock.json" }} - paths: - - node_modules - lint: - description: 'Check for code style and linting errors' - steps: - - run: npm run style - - run: npm run lint - build_and_test: - description: 'Build command that accepts Angular project name as parameter' - parameters: - project: - type: string - default: 'local-weather-app' - run-tests: - type: boolean - default: true - steps: - - run: npx ng build --prod --project << parameters.project >> - - when: - condition: << parameters.run-tests >> - steps: - - run: npx ng test --code-coverage --watch=false --project << parameters.project >> - - run: npx ng e2e << parameters.project >> - store: - description: 'Stores build_and_test artifacts' - parameters: - project: - type: string - default: 'local-weather-app' - steps: - - store_test_results: - path: ./test_results - - store_artifacts: - path: ./coverage - - # upload coverage report to coveralls for readme badge support - # requires config.yml version 2.1 and orbs: coveralls: coveralls/coveralls@1.0.4 - # requires coveralls account and token named COVERALLS_REPO_TOKEN specific to repo to be stored in CircleCI - - coveralls/upload - - - run: - name: Tar & Gzip compiled app - command: tar zcf dist.tar.gz dist/<< parameters.project >> - - store_artifacts: - path: dist.tar.gz - - - run: - name: Move compiled app to workspace - command: | - set -exu - mkdir -p /tmp/workspace/dist - mv dist/<< parameters.project >> /tmp/workspace/dist/ - - persist_to_workspace: - root: /tmp/workspace - paths: - - dist/<< parameters.project >> - deploy_now: - description: 'Deploys project to Zeit Now --> https://now.sh' - parameters: - project: - type: string - default: 'local-weather-app' - steps: - - attach_workspace: - at: /tmp/workspace - - run: npx now --token $NOW_TOKEN --platform-version 2 --prod /tmp/workspace/dist/<< parameters.project >> --confirm -jobs: - initialize: - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - install: - warm-cache: true - default: - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - install - - lint - - build_and_test - - store - deploy: - docker: - - image: circleci/node:lts - working_directory: ~/repo - steps: - - deploy_now - - ch2: # this job is only here to verify sample code from the book, remove it in your own projects - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - install - - build_and_test: - project: 'ch2' - ch3: # this job is only here to verify sample code from the book, remove it in your own projects - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - install - - build_and_test: - project: 'ch3' - run-tests: false - ch4: # this job is only here to verify sample code from the book, remove it in your own projects - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - install - - build_and_test: - project: 'ch4' - ch5: # this job is only here to verify sample code from the book, remove it in your own projects - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - install - - build_and_test: - project: 'ch5' - ch6: # this job is only here to verify sample code from the book, remove it in your own projects - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - install - - build_and_test: - project: 'ch6' - ch12: # this job is only here to verify sample code from the book, remove it in your own projects - docker: - - image: circleci/node:lts-browsers - working_directory: ~/repo - steps: - - install - - build_and_test: - project: 'ch12' -workflows: - version: 2 - build-test-and-approval-deploy: - jobs: - - initialize - - default: - requires: - - initialize - - ch2: # this job is only here to verify sample code from the book, remove it in your own projects - requires: - - initialize - - ch3: # this job is only here to verify sample code from the book, remove it in your own projects - requires: - - initialize - - ch4: # this job is only here to verify sample code from the book, remove it in your own projects - requires: - - initialize - - ch5: # this job is only here to verify sample code from the book, remove it in your own projects - requires: - - initialize - - ch6: # this job is only here to verify sample code from the book, remove it in your own projects - requires: - - initialize - # - ch12: # this job is only here to verify sample code from the book, remove it in your own projects - # requires: - # - initialize - - hold: - type: approval - requires: - - default - filters: - branches: - only: master - - deploy: - requires: - - hold diff --git a/.circleci/config.yml b/.circleci/config.yml index 2430355a..20c46d78 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -66,6 +66,7 @@ jobs: - cloudrun/init - cloudrun/build: tag: 'gcr.io/${GOOGLE_PROJECT_ID}/test-${CIRCLE_SHA1}' + source: ~/repo - cloudrun/deploy: image: 'gcr.io/${GOOGLE_PROJECT_ID}/test-${CIRCLE_SHA1}' platform: managed From da41d552c12af4532c2b715ad9171530b70f8d74 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Fri, 17 Apr 2020 02:00:38 -0400 Subject: [PATCH 08/15] fix test code --- .circleci/config.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 20c46d78..016a5f6b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -75,15 +75,9 @@ jobs: unauthenticated: true - run: command: > - # A simple example of how a deployed managed service could be - verified or further tested. - - # This step will send request our "API" and fail if there is - unexpected output. - GCP_API_RESULTS=$(curl -s "$GCP_DEPLOY_ENDPOINT") - if [ "$GCP_API_RESULTS" != "Hello World!" ]; then + if echo "$GCP_API_RESULTS" | grep -q "LocalCast Weather"; then echo "Result is unexpected" echo 'Result: ' curl -s "$GCP_DEPLOY_ENDPOINT" From 82f839966ae63a33e02d1d97d88377a3195d8cb4 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Fri, 17 Apr 2020 02:20:47 -0400 Subject: [PATCH 09/15] fix fix test script --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 016a5f6b..550c372d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -77,7 +77,7 @@ jobs: command: > GCP_API_RESULTS=$(curl -s "$GCP_DEPLOY_ENDPOINT") - if echo "$GCP_API_RESULTS" | grep -q "LocalCast Weather"; then + if echo "$GCP_API_RESULTS" | grep -nwo "LocalCast Weather"; then echo "Result is unexpected" echo 'Result: ' curl -s "$GCP_DEPLOY_ENDPOINT" From ef83bc68d7a192246fda2729b1e81f69813c2f60 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Fri, 17 Apr 2020 02:45:16 -0400 Subject: [PATCH 10/15] bash for life --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 550c372d..66d27700 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -77,7 +77,7 @@ jobs: command: > GCP_API_RESULTS=$(curl -s "$GCP_DEPLOY_ENDPOINT") - if echo "$GCP_API_RESULTS" | grep -nwo "LocalCast Weather"; then + if ! echo "$GCP_API_RESULTS" | grep -nwo "LocalCast Weather"; then echo "Result is unexpected" echo 'Result: ' curl -s "$GCP_DEPLOY_ENDPOINT" From a9d654dc1f30666a094d1da25037d3678de6427a Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Sun, 19 Apr 2020 14:21:26 -0400 Subject: [PATCH 11/15] clarify ch6 project --- .circleci/config.yml | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 66d27700..42b1d530 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -62,7 +62,7 @@ jobs: - checkout - run: name: Copy built app to dist folder - command: cp -R /tmp/workspace/dist/ch6 dist/ + command: cp -R /tmp/workspace/dist/ch6 dist/ch6/ - cloudrun/init - cloudrun/build: tag: 'gcr.io/${GOOGLE_PROJECT_ID}/test-${CIRCLE_SHA1}' diff --git a/Dockerfile b/Dockerfile index 233d4d09..6a0d9e50 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM duluca/minimal-node-web-server:lts-alpine WORKDIR /usr/src/app -COPY dist public +COPY dist/ch6 public #Overriding default ENTRYPOINT because gcloud doesn't like dumb-init ENTRYPOINT [ "npm", "start" ] From 3d151c646397482bd31e592a61b0c46b58327f34 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Sun, 19 Apr 2020 14:42:12 -0400 Subject: [PATCH 12/15] mkdir --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 42b1d530..cde71be6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -62,7 +62,7 @@ jobs: - checkout - run: name: Copy built app to dist folder - command: cp -R /tmp/workspace/dist/ch6 dist/ch6/ + command: mkdir dist/ch6 && cp -R /tmp/workspace/dist/ch6 dist/ch6/ - cloudrun/init - cloudrun/build: tag: 'gcr.io/${GOOGLE_PROJECT_ID}/test-${CIRCLE_SHA1}' From eb3ade431c6d7f901657a237295d9372707f6822 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Sun, 19 Apr 2020 14:59:25 -0400 Subject: [PATCH 13/15] fix cp command --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index cde71be6..66d27700 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -62,7 +62,7 @@ jobs: - checkout - run: name: Copy built app to dist folder - command: mkdir dist/ch6 && cp -R /tmp/workspace/dist/ch6 dist/ch6/ + command: cp -R /tmp/workspace/dist/ch6 dist/ - cloudrun/init - cloudrun/build: tag: 'gcr.io/${GOOGLE_PROJECT_ID}/test-${CIRCLE_SHA1}' From 3ad0f92b15125e9bfa248a5ffdd0ae4cb94421cd Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Sun, 19 Apr 2020 15:24:08 -0400 Subject: [PATCH 14/15] show me your work --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 66d27700..9f79f77f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -62,7 +62,7 @@ jobs: - checkout - run: name: Copy built app to dist folder - command: cp -R /tmp/workspace/dist/ch6 dist/ + command: cp -avR /tmp/workspace/dist/ch6 dist/ - cloudrun/init - cloudrun/build: tag: 'gcr.io/${GOOGLE_PROJECT_ID}/test-${CIRCLE_SHA1}' From 5947c26c065cbecd0d2914a47a6d6054841cc5d8 Mon Sep 17 00:00:00 2001 From: Doguhan Uluca Date: Sun, 19 Apr 2020 15:33:49 -0400 Subject: [PATCH 15/15] another go --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9f79f77f..ce02efbb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -62,7 +62,7 @@ jobs: - checkout - run: name: Copy built app to dist folder - command: cp -avR /tmp/workspace/dist/ch6 dist/ + command: cp -avR /tmp/workspace/dist/ . - cloudrun/init - cloudrun/build: tag: 'gcr.io/${GOOGLE_PROJECT_ID}/test-${CIRCLE_SHA1}'