What is the simplest setup for meteor+chimp on circle-ci?

Hi @warehouseman: Thanks for the hint.

:slight_smile:

Yeah I finally have a test passing. This stuff took me ages to setup to get hereā€¦

I have spend 2 hours trying @samā€™s solution, but I ran into compile-errors being thrown by gulp (I am using Blaze and not React), and this whole gulp stuff got me overwhelmed. So I decided to dump it and go back to the basic setup I had before and tweak it a bit more.

My learnings for future CircleCi Newbies:

  • when using CIRCLE_ARTIFACTS you can actually access those resulting files in the ā€œartifactsā€-tab
  • there are log-files shown in the GUI for each command. So you can do stuff like - pwd and check out where you are

This is my hacky circle.yml, which is starting to give me resultsā€¦ I am sure it is not the final version and needs more iterations :smile:

machine:
  node:
    version: 6.5.0
  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: test  # for setting stuff in our .js files depending on environment

dependencies:
  cache_directories:
    - ~/project/src/.meteor
    - ~/project/src/node_modules

  pre:
    - pwd
    - cd src; mkdir -p .meteor
    - if [ ! -e src/.meteor/meteor ]; then cd src; curl https://install.meteor.com | /bin/sh 2>&1 | cat; ls -al; fi
    - pwd; cd src; pwd; meteor npm install;  # install npm-packages from ./src/packages.json
    # WORKAROUND for lookback_emails: right now "lookback_emails" is crashing with underscore problem 
    #  (see https://github.com/lookback/meteor-emails/issues/80),
    #  but it works if we fetch it to local disk
    - cd src/packages; git clone https://github.com/lookback/meteor-emails.git; ls -al;
    - cd src; meteor --version;
    # - cd src; meteor --get-ready;  # currently FAILS, probably NOT enough memory
    - cd src; npm install -g chimp 
    - cd src; chimp --path=noexist # Cache chimp deps by running it without any tests

  # Run METEOR IN PARALLEL
  post:
    - pwd
    - date > ${CIRCLE_ARTIFACTS}/meteor.log
    - cd src; meteor test --full-app --driver-package tmeasday:acceptance-test-driver --port 3000 >> ${CIRCLE_ARTIFACTS}/meteor.log 2>&1 & :
        background: true
    - sleep 3m

test:
  post:
    - pwd
    - ls -al
    - cd src; ls -al; node --version; npm --version; java -version; meteor --version;
    - sleep 3m
    - cd src; chimp ./tests/_circle-ci-chimp-config.js --ddp=http://localhost:3000 --path=tests --mocha;

Why not post a link to your Circle CI page? Then we can look at it
together.

Sorry, this is not a public project, so I canā€™t do this.

I got some results now: A lot of the existing tests actually do pass on the slow(?) CircleCi machine. I have some timeout issues, where I guess Iā€™ll just have to double the values.

Right now I am trying to get the reporting setup correctly by setting mochaReporter: 'mocha-junit-reporter', so that CircleCi can give better feedback using https://github.com/michaelleeallen/mocha-junit-reporter.

Iā€™ll keep you guys up to date. Thanks a lot for your help so far! :slight_smile:

Hi guys,

I had it running, but on CircleCi Chimp is NOT able to connect to meteor anymore.
I checked my code, but have NOT found any breaking changes yet. Plus meteor-logs say that meteor is running fine on localhost:3000.

Maybe this is related to the chimp/webdriver-combination?

VERSIONS (CircleCi vs Local-Setup)
CircleCi setup (ERROR)
Chimp 0.46.0
Node v6.5.0
Java 3.10.3

Local setup (WORKS)
Chimp 0.45.0
Node 4.6.2
Java build 1.8.0_65

CIRCLE.YML OVERVIEW

Meteor is started via meteor test --full-app --driver-package tmeasday:acceptance-test-driver --port 3000. The logs say that meteor is really running (=> App running at: http://localhost:3000/).

Chimp is started via chimp ./tests/_circle-ci-chimp-config.js --ddp=http://localhost:3000 --path=tests --mocha;.

The problem is that Chimp is NOT able to connect to localhost:3000.
For example: when doing a simple check for Blaze being rendered, like browser.waitForExist('div#__blaze-root'), I will get an Error like: Error: element (div#__blaze-root) still not existing after 10000ms.

Any ideas how to get this working?

This is my circle.yml

# References
#  * https://forums.meteor.com/t/what-is-the-simplest-setup-for-meteor-chimp-on-circle-ci/31627
machine:
  node:
    version: 6.5.0
  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
    MOCHA_FILE: $CIRCLE_TEST_REPORTS/junit/test-results.xml  # setup reporting for circle (see https://circleci.com/docs/test-metadata/#metadata-collection-in-custom-test-steps)

dependencies:
  pre:
    # START of chimp pre-heat (including chrome-driver).
    # 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 chimp pre-heat (including chrome-driver). Copied from https://github.com/xolvio/chimp/blob/master/circle.yml
    - 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
    - cd src; npm install -g chimp  # not working with low node-version
    - cd src; chimp --path=noexist # Cache chimp deps by running it without any tests

  # 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:
    - cd src; ls -al; chimp -version; node --version; npm --version; java -version; meteor --version; google-chrome --version;
    - sleep 5m  # give meteor-background some time to wake up.
    - date  # log time so we can check, if chimp was started BEFORE meteor has finished loading
    - cd src; chimp ./tests/_circle-ci-chimp-config.js --ddp=http://localhost:3000 --path=tests --mocha;

Update: it works when explicitly changing versions, like so:

machine:
  node:
    version: 4.6.2  # note: 6.5.0 did NOT work (chimp installs, but meteor is NOT available)

dependencies:
  pre:
    - 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.


will be nice to see v2 example, currently trying to figure it out

I have it working in my Meteor Vue Enterprise Starter.

Here is the circle config and Iā€™m using this script (called from package.json) to run Meteor and e2e tests simultaneously

version: 2
jobs:
  build:
    working_directory: ~/app
    docker:
      - image: circleci/openjdk:8-jdk-browsers
        environment:
          # lang settings required for Meteor's Mongo
          LANG: C.UTF-8
          LANGUAGE: C.UTF-8
          LC_ALL: C.UTF-8
          LC_NUMERIC: en_US.UTF-8
          METEOR_BIN_TMP_DIR: /home/circleci/build-temp/
          METEOR_BIN_TMP_FILE: meteor-bin-temp
    steps:
      - checkout
      - restore_cache:
          key: build-temp-{{ checksum ".meteor/release" }}-{{ checksum ".circleci/config.yml" }}
      - restore_cache:
          key: meteor-release-{{ checksum ".meteor/release" }}-{{ checksum ".circleci/config.yml" }}
      - restore_cache:
          key: meteor-packages-{{ checksum ".meteor/versions" }}-{{ checksum ".circleci/config.yml" }}
      - restore_cache:
          key: npm-packages-{{ checksum "package.json" }}-{{ checksum ".circleci/config.yml" }}
      - run:
          name: install build essentials
          command: sudo apt-get install -y build-essential
      - run:
          name: restore cached meteor bin
          command: |
            if [ -e ~/build-temp/meteor-bin ]
            then
                echo "Cached Meteor bin found, restoring it."
                sudo cp ~/build-temp/meteor-bin /usr/local/bin/meteor
            else
                echo "No cached Meteor bin found."
            fi
      - run:
          name: install Meteor
          command: |
            # only install meteor if bin isn't found
            command -v meteor >/dev/null 2>&1 || curl https://install.meteor.com | /bin/sh
      - run:
          name: check versions
          command: |
            echo "Meteor version:"
            # this forces Meteor to download whatever release your project is using
            meteor --version
            which meteor
            echo "Meteor node version:"
            meteor node -v
            echo "Meteor npm version:"
            meteor npm -v
            echo "Java version:"
            java -version
      - run: 
          name: install npm packages
          command: meteor npm i
      - run:
          name: code linting
          command: |
            echo "Installing semistandard deps manually (hacky fix)"
            cd node_modules/semistandard
            meteor npm i
            cd ../../
            meteor npm run lint
      - run:
          name: unit tests
          command: meteor npm run test:unit
      - run:
          name: start app and run e2e tests
          command: meteor npm run test:e2e-standalone
          no_output_timeout: 5m
      - run:
          name: copy meteor bin to build cache
          command: |
            mkdir -p ~/build-temp
            cp /usr/local/bin/meteor ~/build-temp/meteor-bin
      - save_cache:
          key: build-temp-{{ checksum ".meteor/release" }}-{{ checksum ".circleci/config.yml" }}
          paths:
            - ~/build-temp
      - save_cache:
          key: meteor-release-{{ checksum ".meteor/release" }}-{{ checksum ".circleci/config.yml" }}
          paths:
            - ~/.meteor
      - save_cache:
          key: meteor-packages-{{ checksum ".meteor/versions" }}-{{ checksum ".circleci/config.yml" }}
          paths:
            - .meteor/
      - save_cache:
          key: npm-packages-{{ checksum "package.json" }}-{{ checksum ".circleci/config.yml" }}
          paths:
            - ./node_modules/
            - ~/.npm/
      - store_test_results:
          path: ./tests/coverage/unit-tests/
      - store_artifacts:
          path: ./tests/coverage/unit-tests/
          destination: unit-tests
1 Like

Oo nice, couple of things in there I didnā€™t think about. Would you mind
sharing your package.json? Curious to see how you setup
test:e2e-standalone

I just linked to it :slight_smile: hereā€™s the link again package.json

1 Like

CircleCI image in circle.yml is - image: circleci/node:8.9.3-browsers

Pretty simple partial yml for circleCI.

`steps:
      - checkout
      - run: ls
      - run: pwd
      - run: export TOOL_NODE_FLAGS="--max_old_space_size=4096"
      - restore_cache:
          name: Restore Meteor Cache
          key: v2-meteor-cache-{{ checksum "myapp/.meteor/release" }}
      - restore_cache:
          name : Restore NPM Cache
          key: v2-npm-cache-{{ checksum "myapp/package.json" }}
      - restore_cache:
          name: Restore Meteor Package Cache
          key: v2-packages-cache-{{ checksum "myapp/.meteor/versions" }}
      - run:
          shell: /bin/bash
          command: if [[ \"${CIRCLE_BRANCH}\" == \"develop\"]]; then sh ./CI-scripts/buildStaging.sh; fi
      - run:
          shell: /bin/bash
          command: if [[ \"${CIRCLE_BRANCH}\" == \"master\" ]]; then sh ./CI-scripts/buildMaster.sh; fi
      - save_cache:
                name: Save Meteor Cache
                key: v2-meteor-cache-{{ checksum "myapp/.meteor/release" }}
                paths:
                  - 'myapp/.meteor'
      - save_cache:
                name: Save NPM Cache
                key: v2-npm-cache-{{ checksum "myapp/package.json" }}
                paths:
                  - 'myapp/node_modules'
      - save_cache:
                key: v2-packages-cache-{{ checksum "myapp/.meteor/versions" }}
                paths:
                  - 'myapp/.meteor/local/build'
                  - 'myapp/.meteor/local/bundler-cache'
                  - 'myapp/.meteor/local/isopacks'
                  - 'myapp/.meteor/local/plugin-cache'
      - add_ssh_keys`

Perfect @efrancis. Forked your project ( https://github.com/jirikrepl/Meteor-Vue-Enterprise-Starter ) and Circle Ci build successfully: https://circleci.com/gh/jirikrepl/Meteor-Vue-Enterprise-Starter/1#usage-queue/containers/0

1 Like