From f3ebac6c516c02c289db16fdedf4e16afb66ccb4 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Thu, 20 Sep 2018 14:18:44 -0400 Subject: [PATCH] ci: add size check of new project production build --- .circleci/config.yml | 3 +++ .github/angular-robot.yml | 5 +++++ tests/legacy-cli/e2e/tests/basic/build.ts | 27 ++++++++++++++++------- tests/legacy-cli/e2e/utils/fs.ts | 4 ++++ 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 886c08b5cb23..21db9df0c512 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -86,6 +86,9 @@ jobs: steps: - attach_workspace: *attach_options - run: xvfb-run -a node ./tests/legacy-cli/run_e2e --nb-shards=${CIRCLE_NODE_TOTAL} --shard=${CIRCLE_NODE_INDEX} + - store_artifacts: + path: ~/tmp-dist + destination: cli/new-production e2e-node-8: <<: *defaults diff --git a/.github/angular-robot.yml b/.github/angular-robot.yml index ca9d26f7dd2d..2ebaf76633ef 100644 --- a/.github/angular-robot.yml +++ b/.github/angular-robot.yml @@ -91,3 +91,8 @@ triage: - - "type: docs" - "comp: *" + +# Size checking +size: + circleCiStatusName: "ci/circleci: e2e-cli" + maxSizeIncrease: 10000 diff --git a/tests/legacy-cli/e2e/tests/basic/build.ts b/tests/legacy-cli/e2e/tests/basic/build.ts index 36ad2f6b68fc..12039616db05 100644 --- a/tests/legacy-cli/e2e/tests/basic/build.ts +++ b/tests/legacy-cli/e2e/tests/basic/build.ts @@ -1,9 +1,20 @@ -import {ng} from '../../utils/process'; -import {expectFileToMatch} from '../../utils/fs'; - -export default function() { - return ng('build') - .then(() => expectFileToMatch('dist/test-project/index.html', 'main.js')) - .then(() => ng('build', '--prod')) - .then(() => expectFileToMatch('dist/test-project/index.html', /main\.[a-zA-Z0-9]{20}\.js/)); +import { expectFileToMatch, moveDirectory } from '../../utils/fs'; +import { ng } from '../../utils/process'; + + +export default async function() { + // Development build + await ng('build'); + await expectFileToMatch('dist/test-project/index.html', 'main.js'); + + + // Production build + await ng('build', '--prod'); + await expectFileToMatch('dist/test-project/index.html', /main\.[a-zA-Z0-9]{20}\.js/); + + // Store the production build for artifact storage on CircleCI + if (process.env['CIRCLECI']) { + await ng('build', '--prod', '--output-hashing=none'); + await moveDirectory('dist', '~/temp-dist'); + } } diff --git a/tests/legacy-cli/e2e/utils/fs.ts b/tests/legacy-cli/e2e/utils/fs.ts index 13d424e81f17..2f2a0cdaae77 100644 --- a/tests/legacy-cli/e2e/utils/fs.ts +++ b/tests/legacy-cli/e2e/utils/fs.ts @@ -107,6 +107,10 @@ export function copyFile(from: string, to: string) { })); } +export function moveDirectory(from: string, to: string) { + return fs.move(from, to, { overwrite: true }); +} + export function writeMultipleFiles(fs: { [path: string]: string }) { return Promise.all(Object.keys(fs).map(fileName => writeFile(fileName, fs[fileName])));