Hi guys,
my unit- and integration-test’s run-time has increased to over 10 minutes (WUUUUHHHHHH). Right now I am running them locally before each commit, but waiting for those tests to pass sucks a lot.
Now I’d love to extend my CircleCli-Setup to also run my unit- and integrational-tests. It would be cool to find a simple solution for this.
@warehouseman: do you have a quick hint where to look on how to do this?
I am following meteor-guides and run my unit-tests via practicalmeteor:mocha
and meteor test --driver-package practicalmeteor:mocha
and I saw that it is possible to run those tests on commandline via spacejam.
This is my current circle.yml
:
# References
# * https://forums.meteor.com/t/what-is-the-simplest-setup-for-meteor-chimp-on-circle-ci/31627
machine:
node:
version: 4.6.2 # note: 6.5.0 did NOT work (chimp installs, but meteor is NOT available)
java:
# This is needed by Chimp to run Selenium so we can start Chrome and Firefox
version: oraclejdk8
environment:
_JAVA_OPTIONS: "-Xms512m -Xmx1024m"
CIRCLE_ENV: circle # for setting stuff in our .js files depending on environment
dependencies:
pre:
- pwd
- cd ~; pwd; # find HOME
# START of chrome-driver-update
# NOTE: without this, we will get a "Chrome version must be >= 54.0.2840.0"-error
# copied from https://github.com/meteor/todos/blob/master/.testing/upgrade_chrome_version.sh
- google-chrome --version
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
- sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
- sudo apt-get update
- sudo apt-get install google-chrome-stable
- google-chrome --version
# END of chrome-driver-update
# START of meteor pre-heat
- cp src/.meteor/versions ${CIRCLE_ARTIFACTS}/versions_pre;
- cd src; mkdir -p .meteor
- if [ ! -e src/.meteor/meteor ]; then cd src; curl https://install.meteor.com | /bin/sh 2>&1 | cat; fi
- pwd; cd src; pwd; meteor npm install; # install npm-packages from ./src/packages.json
- cd src; meteor --version; # trying to cache and pre-heat meteor
# - cd src; meteor --get-ready; # currently FAILS, probably NOT enough memory
# END of meteor pre-heat
- mkdir -p ${CIRCLE_ARTIFACTS}/screenshots
- cd src; npm install -g chimp@0.45.0 # @0.46.0 might NOT work. in general this is NOT working with LOW node-version.
- cd src; chimp --path=noexist # Cache chimp deps by running it without any tests
- npm install -g junit-merge # https://github.com/drazisil/junit-merge
# Run METEOR IN PARALLEL
post:
- pwd
# debug used versions
- cp src/.meteor/versions ${CIRCLE_ARTIFACTS}/versions_post;
- less src/.meteor/versions > ${CIRCLE_ARTIFACTS}/meteor.log;
- date > ${CIRCLE_ARTIFACTS}/meteor.log
- date # for easy access on circleCi's overview
- cd src; meteor test --full-app --driver-package tmeasday:acceptance-test-driver --port 3000 >> ${CIRCLE_ARTIFACTS}/meteor.log 2>&1 & :
background: true
test:
post:
- date # log time so we can check, if chimp was started BEFORE meteor has finished loading
- pwd
- ls -al
- cd src; chimp -version; node --version; npm --version; java -version; meteor --version; google-chrome --version; # log versions for debug
- sleep 5m # give meteor-background some time to wake up. NOTE: 10m will NOT work either with newest chimp-problem. Keep it at 5m.
- date # log time so we can check, if chimp was started BEFORE meteor has finished loading
# SPLIT CHIMP into 2 runs, so that we do NOT timeout on CircleCi (120 minutes-limit).
# We are using "mocha-circleci-reporter", which writes into "test-results.xml" by default,
# so after EACH run we need to copy&rename the file to $CIRCLE_TEST_REPORTS
# and then combine both results into ONE final "$CIRCLE_TEST_REPORTS/test-results.xml"
# REFERENCES
# => Timeout-problem: https://discuss.circleci.com/t/timeout-more-than-120-minutes/640/5
# => CircleCi-reporter https://github.com/sandcastle/mocha-circleci-reporter
# => Merge-tool: https://www.npmjs.com/package/junit-merge
- less $CIRCLE_TEST_REPORTS
- less ${CIRCLE_TEST_REPORTS}
- cd src; chimp ./tests/_circle-ci-chimp-config-run-1.js --ddp=http://localhost:3000 --path=tests --mocha
- cd src; cp test-results.xml ${CIRCLE_TEST_REPORTS}/test-results-1.xml
- cd src; cp test-results.xml ${CIRCLE_ARTIFACTS}/test-results-1.xml
- cd src; chimp ./tests/_circle-ci-chimp-config-run-2.js --ddp=http://localhost:3000 --path=tests --mocha
- cd src; cp test-results.xml ${CIRCLE_TEST_REPORTS}/test-results-2.xml
- cd src; cp test-results.xml ${CIRCLE_ARTIFACTS}/test-results-2.xml
- junit-merge -d ${CIRCLE_TEST_REPORTS} # see https://www.npmjs.com/package/junit-merge
- cd ${CIRCLE_TEST_REPORTS}; ls -al; # lets see why the next line fails
- cp ${CIRCLE_TEST_REPORTS}/test-results.xml ${CIRCLE_ARTIFACTS}/test-results-merged.xml