From 7de25c8e41e5462d78d372ea2bca1ed3dadfd0db Mon Sep 17 00:00:00 2001 From: Pete Bacon Darwin Date: Sun, 24 May 2020 09:31:20 +0100 Subject: [PATCH] chore(ci): ensure that deployment files are ready for deployment --- .circleci/config.yml | 40 +++++++++++++------ Gruntfile.js | 15 +------ .../functions/index.js | 2 +- .../readme.firebase.docs.md | 6 ++- 4 files changed, 35 insertions(+), 28 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index dffc29df48e9..1d45b1140c92 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -291,6 +291,19 @@ jobs: - run_e2e_tests_jquery: specs: build/docs/ptore2e/!(example-ng*)/**/jquery_test.js + prepare-deployment: + executor: + name: default-executor + steps: + - custom_attach_workspace + - init_environment + - run: yarn grunt prepareDeploy + # Write the deployment files to the workspace to be used by deploy-docs and deploy-code + - persist_to_workspace: + root: *workspace_location + paths: + - ./ng/deploy + deploy-docs: executor: name: default-executor @@ -300,7 +313,7 @@ jobs: - run: yarn grunt prepareDeploy # Install dependencies for Firebase functions to prevent parsing errors during deployment # See https://github.com/angular/angular.js/pull/16453 - - run: yarn -cwd $PROJECT_ROOT/scripts/docs.angularjs.org-firebase/functions + - run: yarn -cwd ~/ng/scripts/docs.angularjs.org-firebase/functions - run: yarn firebase deploy --token "$FIREBASE_TOKEN" --only hosting deploy-code: @@ -308,7 +321,7 @@ jobs: name: cloud-sdk steps: - custom_attach_workspace - - init_environment + - run: ls ~/ng/deploy/code - run: name: Authenticate and configure Docker command: | @@ -317,7 +330,7 @@ jobs: - run: name: Sync files to code.angularjs.org command: | - gsutil -m rsync -r ${PROJECT_ROOT}/deploy/code gs://code-angularjs-org-338b8.appspot.com + gsutil -m rsync -r ~/ng/deploy/code gs://code-angularjs-org-338b8.appspot.com workflows: version: 2 @@ -351,12 +364,14 @@ workflows: - e2e-test-jquery-2b: requires: - setup - - deploy-docs: + - prepare-deployment: filters: branches: only: + - master - latest requires: + - setup - unit-test - unit-test-jquery - e2e-test-1 @@ -365,6 +380,14 @@ workflows: - e2e-test-jquery-1 - e2e-test-jquery-2a - e2e-test-jquery-2b + + - deploy-docs: + filters: + branches: + only: + - latest + requires: + - prepare-deployment - deploy-code: filters: branches: @@ -372,11 +395,4 @@ workflows: - master - latest requires: - - unit-test - - unit-test-jquery - - e2e-test-1 - - e2e-test-2a - - e2e-test-2b - - e2e-test-jquery-1 - - e2e-test-jquery-2a - - e2e-test-jquery-2b + - prepare-deployment diff --git a/Gruntfile.js b/Gruntfile.js index 9ef0add83c94..fd52c82ce11a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -369,10 +369,9 @@ module.exports = function(grunt) { }, deployFirebaseCode: { files: [ - // copy files that are not handled by compress { cwd: 'build', - src: '**/*.{zip,jpg,jpeg,png}', + src: '**', dest: 'deploy/code/' + deployVersion + '/', expand: true } @@ -420,16 +419,6 @@ module.exports = function(grunt) { expand: true, dot: true, dest: dist + '/' - }, - deployFirebaseCode: { - options: { - mode: 'gzip' - }, - // Already compressed files should not be compressed again - src: ['**', '!**/*.{zip,png,jpeg,jpg}'], - cwd: 'build', - expand: true, - dest: 'deploy/code/' + deployVersion + '/' } }, @@ -527,8 +516,6 @@ module.exports = function(grunt) { 'eslint' ]); grunt.registerTask('prepareDeploy', [ - 'package', - 'compress:deployFirebaseCode', 'copy:deployFirebaseCode', 'firebaseDocsJsonForCI', 'copy:deployFirebaseDocs' diff --git a/scripts/code.angularjs.org-firebase/functions/index.js b/scripts/code.angularjs.org-firebase/functions/index.js index 83d209d479a5..733c6947977f 100644 --- a/scripts/code.angularjs.org-firebase/functions/index.js +++ b/scripts/code.angularjs.org-firebase/functions/index.js @@ -200,7 +200,7 @@ const snapshotRegex = /^snapshot(-stable)?\//; * When a new zip file is uploaded into snapshot or snapshot-stable, * delete the previous zip file. */ -function deleteOldSnapshotZip(object, context) { +function deleteOldSnapshotZip(object) { const bucketId = object.bucket; const filePath = object.name; const contentType = object.contentType; diff --git a/scripts/docs.angularjs.org-firebase/readme.firebase.docs.md b/scripts/docs.angularjs.org-firebase/readme.firebase.docs.md index 2c49bb9b0cdd..09e99d728915 100644 --- a/scripts/docs.angularjs.org-firebase/readme.firebase.docs.md +++ b/scripts/docs.angularjs.org-firebase/readme.firebase.docs.md @@ -13,9 +13,13 @@ See .circleci/config.yml for the complete deployment config and build steps. # Serving locally: -- Run `grunt:prepareDeploy`. +- Run `yarn grunt package`. + This builds the files that will be deployed. + +- Run `yarn grunt prepareDeploy`. This copies docs content files into deploy/docs and the partials for Search Engine AJAX Crawling into ./functions/content. + It also moves the firebase.json file to the root folder, where the firebase-cli expects it - Run `firebase serve --only functions,hosting` Creates a server at localhost:5000 that serves from deploy/docs and uses the local function