Faster CI build for PR (#14171)

pull/13992/head^2
Rodrigo Nascimento 6 years ago committed by Diego Sampaio
parent 183652be23
commit f6f507dfbc
  1. 104
      .circleci/config.yml
  2. 1
      packages/rocketchat-livechat/package.js
  3. 19
      packages/rocketchat-livechat/plugin/build-livechat.js
  4. 3
      packages/rocketchat-livechat/plugin/build.sh
  5. 2
      tests/chimp-config.js

@ -33,6 +33,15 @@ test-configure-replicaset: &test-configure-replicaset
mongo --eval 'rs.initiate({_id:"rs0", members: [{"_id":1, "host":"localhost:27017"}]})' mongo --eval 'rs.initiate({_id:"rs0", members: [{"_id":1, "host":"localhost:27017"}]})'
mongo --eval 'rs.status()' mongo --eval 'rs.status()'
test-restore-npm-cache: &test-restore-npm-cache
keys:
- node-modules-cache-{{ checksum ".circleci/config.yml" }}-{{ checksum "package.json" }}
test-save-npm-cache: &test-save-npm-cache
key: node-modules-cache-{{ checksum ".circleci/config.yml" }}-{{ checksum "package.json" }}
paths:
- ./node_modules
test-docker-image: &test-docker-image test-docker-image: &test-docker-image
circleci/node:8.11-stretch-browsers circleci/node:8.11-stretch-browsers
@ -54,8 +63,10 @@ test-with-oplog: &test-with-oplog
- checkout - checkout
- run: *test-install-dependencies - run: *test-install-dependencies
- run: *test-configure-replicaset - run: *test-configure-replicaset
- restore_cache: *test-restore-npm-cache
- run: *test-npm-install - run: *test-npm-install
- run: *test-run - run: *test-run
- save_cache: *test-save-npm-cache
- store_artifacts: *test-store_artifacts - store_artifacts: *test-store_artifacts
test-without-oplog: &test-without-oplog test-without-oplog: &test-without-oplog
@ -64,8 +75,10 @@ test-without-oplog: &test-without-oplog
- attach_workspace: *attach_workspace - attach_workspace: *attach_workspace
- checkout - checkout
- run: *test-install-dependencies - run: *test-install-dependencies
- restore_cache: *test-restore-npm-cache
- run: *test-npm-install - run: *test-npm-install
- run: *test-run - run: *test-run
- save_cache: *test-save-npm-cache
- store_artifacts: *test-store_artifacts - store_artifacts: *test-store_artifacts
@ -79,13 +92,13 @@ jobs:
steps: steps:
- checkout - checkout
# - restore_cache: - restore_cache:
# keys: keys:
# - node-modules-cache-{{ checksum ".circleci/config.yml" }}-{{ checksum "package.json" }} - node-modules-cache-{{ checksum ".circleci/config.yml" }}-{{ checksum "package.json" }}
# - restore_cache: - restore_cache:
# keys: keys:
# - meteor-{{ checksum ".circleci/config.yml" }}-{{ checksum ".meteor/release" }} - meteor-{{ checksum ".circleci/config.yml" }}-{{ checksum ".meteor/release" }}
- run: - run:
name: Install Meteor name: Install Meteor
@ -134,25 +147,34 @@ jobs:
command: | command: |
meteor npm run testunit meteor npm run testunit
# - restore_cache: - restore_cache:
# keys: keys:
# - meteor-cache-{{ checksum ".circleci/config.yml" }}-{{ checksum ".meteor/versions" }} - meteor-cache-{{ checksum ".circleci/config.yml" }}-{{ checksum ".meteor/versions" }}
# - restore_cache: - restore_cache:
# keys: keys:
# - livechat-meteor-cache-{{ checksum ".circleci/config.yml" }}-{{ checksum "packages/rocketchat-livechat/app/.meteor/versions" }} - livechat-meteor-cache-{{ checksum ".circleci/config.yml" }}-{{ checksum "packages/rocketchat-livechat/.app/.meteor/versions" }}
# - restore_cache: - restore_cache:
# keys: keys:
# - livechat-node-modules-cache-{{ checksum ".circleci/config.yml" }}-{{ checksum "packages/rocketchat-livechat/app/package.json" }} - livechat-node-modules-cache-{{ checksum ".circleci/config.yml" }}-{{ checksum "packages/rocketchat-livechat/.app/package.json" }}
- run: - run:
name: Build Rocket.Chat name: Build Rocket.Chat
environment: environment:
TOOL_NODE_FLAGS: --max_old_space_size=3072 TOOL_NODE_FLAGS: --max_old_space_size=3072
command: | command: |
if [[ $CIRCLE_TAG ]]; then meteor reset; fi if [[ $CIRCLE_TAG ]] || [[ $CIRCLE_BRANCH == 'develop' ]]; then
meteor build --server-only --directory /tmp/build-test meteor reset;
fi
export CIRCLE_PR_NUMBER="${CIRCLE_PR_NUMBER:-${CIRCLE_PULL_REQUEST##*/}}"
if [[ -z $CIRCLE_PR_NUMBER ]]; then
meteor build --server-only --directory /tmp/build-test
else
export METEOR_PROFILE=1000
meteor build --server-only --directory --debug /tmp/build-test
fi;
- run: - run:
name: Prepare build name: Prepare build
@ -163,30 +185,30 @@ jobs:
cd /tmp/build-test/bundle/programs/server cd /tmp/build-test/bundle/programs/server
npm install npm install
# - save_cache: - save_cache:
# key: node-modules-cache-{{ checksum ".circleci/config.yml" }}-{{ checksum "package.json" }} key: node-modules-cache-{{ checksum ".circleci/config.yml" }}-{{ checksum "package.json" }}
# paths: paths:
# - ./node_modules - ./node_modules
# - save_cache: - save_cache:
# key: meteor-cache-{{ checksum ".circleci/config.yml" }}-{{ checksum ".meteor/versions" }} key: meteor-cache-{{ checksum ".circleci/config.yml" }}-{{ checksum ".meteor/versions" }}
# paths: paths:
# - ./.meteor/local - ./.meteor/local
# - save_cache: - save_cache:
# key: livechat-node-modules-cache-{{ checksum ".circleci/config.yml" }}-{{ checksum "packages/rocketchat-livechat/app/package.json" }} key: livechat-node-modules-cache-{{ checksum ".circleci/config.yml" }}-{{ checksum "packages/rocketchat-livechat/.app/package.json" }}
# paths: paths:
# - ./packages/rocketchat-livechat/app/node_modules - ./packages/rocketchat-livechat/app/node_modules
# - save_cache: - save_cache:
# key: livechat-meteor-cache-{{ checksum ".circleci/config.yml" }}-{{ checksum "packages/rocketchat-livechat/app/.meteor/versions" }} key: livechat-meteor-cache-{{ checksum ".circleci/config.yml" }}-{{ checksum "packages/rocketchat-livechat/.app/.meteor/versions" }}
# paths: paths:
# - ./packages/rocketchat-livechat/app/.meteor/local - ./packages/rocketchat-livechat/app/.meteor/local
# - save_cache: - save_cache:
# key: meteor-{{ checksum ".circleci/config.yml" }}-{{ checksum ".meteor/release" }} key: meteor-{{ checksum ".circleci/config.yml" }}-{{ checksum ".meteor/release" }}
# paths: paths:
# - ~/.meteor - ~/.meteor
- persist_to_workspace: - persist_to_workspace:
root: /tmp/ root: /tmp/

@ -13,7 +13,6 @@ Package.registerBuildPlugin({
'plugin/build-livechat.js', 'plugin/build-livechat.js',
], ],
npmDependencies: { npmDependencies: {
shelljs: '0.8.1',
'uglify-js': '2.8.29', 'uglify-js': '2.8.29',
}, },
}); });

@ -1,17 +1,26 @@
import path from 'path'; import path from 'path';
import shell from 'shelljs'; import { execSync } from 'child_process';
import fs from 'fs'; import fs from 'fs';
import UglifyJS from 'uglify-js'; import UglifyJS from 'uglify-js';
const result = UglifyJS.minify(path.resolve('packages', 'rocketchat-livechat', 'assets', 'rocket-livechat.js')); const livechatSource = path.resolve('packages', 'rocketchat-livechat', 'assets', 'rocket-livechat.js');
const livechatTarget = path.resolve('packages', 'rocketchat-livechat', 'assets', 'rocketchat-livechat.min.js');
fs.writeFileSync(path.resolve('packages', 'rocketchat-livechat', 'assets', 'rocketchat-livechat.min.js'), result.code); if (process.env.CIRCLE_PR_NUMBER) {
fs.writeFileSync(livechatTarget, fs.readFileSync(livechatSource));
} else {
fs.writeFileSync(livechatTarget, UglifyJS.minify(livechatSource).code);
}
const packagePath = path.join(path.resolve('.'), 'packages', 'rocketchat-livechat'); const packagePath = path.join(path.resolve('.'), 'packages', 'rocketchat-livechat');
const pluginPath = path.join(packagePath, 'plugin'); const pluginPath = path.join(packagePath, 'plugin');
const options = {
env: process.env,
};
if (process.platform === 'win32') { if (process.platform === 'win32') {
shell.exec(`${ pluginPath }/build.bat`); execSync(`${ pluginPath }/build.bat`, options);
} else { } else {
shell.exec(`sh ${ pluginPath }/build.sh`); execSync(`sh ${ pluginPath }/build.sh`, options);
} }

@ -7,6 +7,7 @@ export LATEST_LIVECHAT_VERSION="1.0.0"
cd packages/rocketchat-livechat/.app cd packages/rocketchat-livechat/.app
meteor npm install --production meteor npm install --production
meteor build --headless --directory $BUILD_DIR meteor build --headless --directory $BUILD_DIR
rm -rf $LIVECHAT_DIR rm -rf $LIVECHAT_DIR
@ -32,7 +33,7 @@ rm build.tar.gz
# change to lowercase so all injected junk from rocket.chat is not sent: https://github.com/meteorhacks/meteor-inject-initial/blob/master/lib/inject-core.js#L10 # change to lowercase so all injected junk from rocket.chat is not sent: https://github.com/meteorhacks/meteor-inject-initial/blob/master/lib/inject-core.js#L10
# this is not harmful since doctype is case-insesitive: https://www.w3.org/TR/html5/syntax.html#the-doctype # this is not harmful since doctype is case-insesitive: https://www.w3.org/TR/html5/syntax.html#the-doctype
ex -s -c '%s/<!DOCTYPE/<!doctype/g|x' index.html node -e 'fs.writeFileSync("index.html", fs.readFileSync("index.html").toString().replace("<!DOCTYPE", "<!doctype"));'
cd $LIVECHAT_ASSETS_DIR cd $LIVECHAT_ASSETS_DIR
cp ../../public/livechat/$LATEST_LIVECHAT_VERSION/index.html . cp ../../public/livechat/$LATEST_LIVECHAT_VERSION/index.html .

@ -27,7 +27,7 @@ module.exports = {
// chai: false, // chai: false,
screenshotsOnError: true, screenshotsOnError: true,
screenshotsPath: '.screenshots', screenshotsPath: '.screenshots',
captureAllStepScreenshots: true, captureAllStepScreenshots: false,
saveScreenshotsToDisk: true, saveScreenshotsToDisk: true,
// // Note: With a large viewport size and captureAllStepScreenshots enabled, // // Note: With a large viewport size and captureAllStepScreenshots enabled,
// // you may run out of memory. Use browser.setViewportSize to make the // // you may run out of memory. Use browser.setViewportSize to make the

Loading…
Cancel
Save