# CircleCI 2.0 configuration file. See <https://circleci.com/docs/2.0/language-python/>.
version: 2
jobs:
  build:
    docker:
      - image: python:3.7
    steps:
      - checkout

      - restore_cache:
          key: dependency-cache-{{ checksum "requirements.txt" }}

      - run:
          name: Create a virtualenv
          command: |
            mkdir -p /tmp/venv/openfisca_doc
            python -m venv /tmp/venv/openfisca_doc
            echo "source /tmp/venv/openfisca_doc/bin/activate" >> $BASH_ENV

      - run:
          name: Install doc dependencies
          command: make install

      - save_cache:
          key: dependency-cache-{{ checksum "requirements.txt" }}
          paths:
            - /tmp/venv/openfisca_doc

      - run:
          name: Build doc
          command: make build

      - run:
          name: Serve doc
          command: make prod
          background: true

      - run:
          name: Check for internal dead links
          command: wget --spider --recursive --page-requisites http://localhost:8000

      - persist_to_workspace:
          root: .
          paths:
            - build

  deploy:
    docker:
      - image: python:3.7
    steps:
      - checkout
      - attach_workspace:
          at: .
      - 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: python:3.7
    steps:
      - checkout

      - restore_cache:
          key: dependency-cache-{{ checksum "requirements.txt" }}

      - run:
          name: Create a virtualenv
          command: |
            mkdir -p /tmp/venv/openfisca_doc
            python -m venv /tmp/venv/openfisca_doc
            echo "source /tmp/venv/openfisca_doc/bin/activate" >> $BASH_ENV

      - run:
          name: Install doc dependencies
          command: make install

      - save_cache:
          key: dependency-cache-{{ checksum "requirements.txt" }}
          paths:
            - /tmp/venv/openfisca_doc

      - run:
          name: Test doc
          command: make test

      - run:
          name: Build doc
          command: make build

      - run:
          name: Serve doc
          command: make prod
          background: true

      - run:
          name: Check for internal dead links
          command: wget --spider --recursive --page-requisites http://localhost:8000

      - persist_to_workspace:
          root: .
          paths:
            - build

  deploy:
    docker:
      - image: python:3.7
    steps:
      - checkout
      - attach_workspace:
          at: .
      - run:
          name: Publish openfisca.org/doc
          command: ./publish.sh
workflows:
  version: 2
  build:
    jobs:
      - build
      - deploy:
          requires:
            - build
          filters:
            branches:
              only: master

Add make test to circleci
Add make test to circleci
