# CircleCI 2.0 configuration file. See <https://circleci.com/docs/2.0/language-python/>.
version: 2
jobs:
  build:
    docker:
      - image: circleci/node:6-jessie-browsers
    steps:
      - run:
          name: Install calibre
          command: sudo apt-get update && sudo apt-get install calibre
      - checkout
      - restore_cache:
          key: dependency-cache-{{ checksum "package.json" }}
      - run:
          name: Install app dependencies
          command: npm install
      - save_cache:
          key: dependency-cache-{{ checksum "package.json" }}
          paths:
            - node_modules
      - run:
          name: Run tests
          command: npm test
  deploy:
    docker:
      - image: circleci/node:6-jessie-browsers
    steps:
      - run:
          name: Install calibre
          command: sudo apt-get update && sudo apt-get install calibre
      - checkout
      - restore_cache:
          key: dependency-cache-{{ checksum "package.json" }}
      - run:
          name: Build app
          command: npm run build
      - run:
          name: Publish openfisca.org/doc
          command: ./publish.sh
workflows:
  version: 2
  build:
    jobs:
      - build
      - deploy:
          requires:
            - build
          filters:
            branches:
              only: master

# CircleCI 2.0 configuration file. See <https://circleci.com/docs/2.0/language-python/>.
version: 2
jobs:
  build:
    docker:
      - image: circleci/node:6-jessie-browsers
    steps:
      - run:
          name: Install calibre
          command: sudo apt-get update && sudo apt-get install calibre
      - checkout
      - restore_cache:
          key: dependency-cache-{{ checksum "package.json" }}
      - run:
          name: Install app dependencies
          command: npm install
      - save_cache:
          key: dependency-cache-{{ checksum "package.json" }}
          paths:
            - node_modules
      - run:
          name: Build app
          command: npm run build > build-log.txt
      - run:
          name: Check there was no warning during build
          command: "! (cat build-log.txt | grep 'warn:' | grep -v openfisca-doc.pdf)"
  deploy:
    docker:
      - image: circleci/node:6-jessie-browsers
    steps:
      - run:
          name: Install calibre
          command: sudo apt-get update && sudo apt-get install calibre
      - checkout
      - restore_cache:
          key: dependency-cache-{{ checksum "package.json" }}
      - run:
          name: Build app
          command: npm run build
      - run:
          name: Publish openfisca.org/doc
          command: ./publish.sh
workflows:
  version: 2
  build:
    jobs:
      - build
      - deploy:
          requires:
            - build
          filters:
            branches:
              only: master

Check npm run build return code
Check npm run build return code
