18F/cg-dashboard

View on GitHub
.circleci/config.yml

Summary

Maintainability
Test Coverage
# This configuration was automatically generated from a CircleCI 1.0 config.
# And then modified to complete a build-and-test cycle.

# The build uses the docker image, circleci/build-image:ubuntu-14.04-XXL-upstart-1189-5614f37
# that has all the tools from the v1.0 CircleCI world. That image is 22.9 Gb, and
# takes about 8 minutes to set up if it's not already cached on the CircleCI machine
# that your job lands on.

# TODO:
#   - enable cachine for node_modules, to save abou 2m on builds
#   - enable master builds to deploy to fr-stage - DONE Managed in circle_deploy.sh
#   - enable new tags to deploy to fr - DONE Managed in circle_deploy.sh
#   - enable Slack notifications

version: 2
jobs:
  build:
    # branches: TODO filter build by branches for release to fr-stage?
    working_directory: ~/18F/cg-dashboard
    parallelism: 1
    shell: /bin/bash --login
    # CircleCI 2.0 does not support environment variables that refer to each other the same way as 1.0 did.
    # If any of these refer to each other, rewrite them so that they don't or see https://circleci.com/docs/2.0/env-vars/#interpolating-environment-variables-to-set-other-environment-variables .
    environment:
      CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
      CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
      GODIST: go1.9.linux-amd64.tar.gz
      WS: /home/ubuntu/.go_workspace/src/github.com/18F/cg-dashboard
      CF_ORGANIZATION: cloud-gov
    # In CircleCI 1.0 we used a pre-configured image with a large number of languages and other packages.
    # In CircleCI 2.0 you can now specify your own image, or use one of our pre-configured images.
    # The following image, at 22.9 Gb, is the old pre-configured image:
    docker:
    - image: circleci/build-image:ubuntu-14.04-XXL-upstart-1189-5614f37
    steps:
    - checkout
    # Compatibility step
    - run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
    # This is based on your 1.0 configuration file or project settings
    # - run:
    #    working_directory: ~/18F/cg-dashboard
    #   command: 'sudo docker info >/dev/null 2>&1 || sudo service docker start; '
    # The following run steps are pulled from old circle.yml
    # Machine:
    - run:
        working_directory: ~/18F/cg-dashboard
        command: nvm install && nvm use && nvm alias default $(cat .nvmrc)
    - run:
        working_directory: ~/18F/cg-dashboard
        command: mkdir -p download
    - run:
        working_directory: ~/18F/cg-dashboard
        command: test -e download/$GODIST || curl -o download/$GODIST https://storage.googleapis.com/golang/$GODIST
    - run:
        working_directory: ~/18F/cg-dashboard
        command: sudo rm -rf /usr/local/go
    - run:
        working_directory: ~/18F/cg-dashboard
        command: sudo tar -C /usr/local -xzf download/$GODIST
    # Dependencies:
    - run: sudo apt-get update; sudo apt-get install libicu52
    - run: go version
    - run: go get -u github.com/golang/dep/cmd/dep
    - run: rm -rf $WS
    - run: mkdir -p $(dirname $WS) && ln -s $(pwd) $WS
    - run: cd $WS && dep ensure
    - run: npm install
    # - run: npm run test-selenium-install
    - run: cd $WS && go build
    - run: npm run build
    # - run: wget https://chromedriver.storage.googleapis.com/2.33/chromedriver_linux64.zip
    # - run: unzip chromedriver_linux64.zip
    # - run: sudo cp chromedriver /usr/local/bin/chromedriver
    # Test:
    # - run: if ! go get github.com/golang/tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi
    # - run: export DISPLAY=:99.0
    # - run: sh -e /etc/init.d/xvfb start || echo \"Unable to start virtual display.\"
    # - run: sleep 5 # give xvfb spin pu time
    # - run: cd $WS && npm test
    - run: NODE_ENV=prod npm run build
    - run: sleep 5
    # - run: cd $WS && npm run test-performance || true
    # - run: cd $WS && SKIP_DOCKER=1 ./codecheck.sh  # TODO: SKIP_DOCKER may not be needed anymore
    # Deploy:
    - run: NODE_ENV=prod npm run build-prod
    - run: pip install --upgrade pip
    - run: pip install --user ruamel.yaml
    - run: export BUILD_INFO=build::$CIRCLE_BRANCH::$(date -u "+%Y-%m-%d-%H-%M-%S")::$CIRCLE_BUILD_NUM::$(deploy/npm-version.sh) && python deploy/vars-to-manifest.py
    - run: cd $WS && ./deploy/circle_deploy.sh


workflows:
  version: 2
  build-deploy:
    jobs:
      - build