Skip to content

Instantly share code, notes, and snippets.

@AdamT
Created October 10, 2017 19:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdamT/21d72f5a7daf66655c61475d7bb02a8c to your computer and use it in GitHub Desktop.
Save AdamT/21d72f5a7daf66655c61475d7bb02a8c to your computer and use it in GitHub Desktop.
Circle CI Elm Tests Fix

Problem

When running elm-test on Circle CI, your builds will run indefinitely due to an issue with determining CPU usage. The following might help be of help to you.

Solution

Configure Circle CI (i.e. circle.yml) as follows:

machine:
  environment:
    YARN_VERSION: 0.17.10
    PATH: "${PATH}:${HOME}/.yarn/bin"
  node:
    version: 7.2.1
dependencies:
  pre:
    - |
      if [[ ! -e ~/.yarn/bin/yarn || $(yarn --version) != "${YARN_VERSION}" ]]; then
        curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version $YARN_VERSION
      fi
  override:
    - yarn install
  post:
    # Workaround to Elm CI test suite timeout: https://github.com/elm-lang/elm-compiler/issues/1473.
    - if [ ! -d libsysconfcpus ]; then git clone https://github.com/obmarg/libsysconfcpus.git; fi
    - cd libsysconfcpus && ./configure && make && sudo make install
  cache_directories:
    - libsysconfcpus
    - ~/.yarn
    - ~/.yarn-cache
test:
  override:
    - yarn run ci

In order to get the yarn run ci command, used above, to work properly you'll want to configure your Yarn package.json as follows:

{
  "name": "example",
  "version": "0.1.0",
  "description": "Example",
  "main": "index.js",
  "repository": "https://github.com/example/example",
  "author": "Brooke Kuhlmann",
  "license": "MIT",
  "devDependencies": {
    "elm": "^0.18.0",
    "elm-live": "^2.6.0",
    "elm-test": "^0.18.2"
  },
  "scripts": {
    "test": "elm-test",
    "ci": "sysconfcpus --num 1 elm-test"
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment