# Copyright 2019 PrivateStorage.io, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

version: 2

jobs:
  documentation:
    docker:
      - image: "circleci/python:3.7"
    steps:
      - "checkout"

      - run:
          name: "Sphinx Documentation Build"
          command: |
            virtualenv venv
            . venv/bin/activate
            pip install --upgrade pip
            pip install -r docs/requirements.txt
            sphinx-build docs/source docs/build

      - store_artifacts:
          path: "docs/build"
          destination: "docs"

  tests:
    docker:
      - image: "circleci/python:3.7"
    steps:
      - "checkout"

      - run:
          name: "Run Test Suite"
          command: |
            virtualenv venv
            . venv/bin/activate
            pip install --upgrade pip
            pip install -r requirements.txt requirements-tests.txt
            coverage run -m twisted.trial _secureaccesstokenauthorizer

      - run:
          name: "Report Coverage"
          command: |
            . venv/bin/activate
            CODECOV_TOKEN="cc6e4697-4337-4506-88af-92b8f8ca6b22" codecov


workflows:
  version: 2
  everything:
    jobs:
      - "documentation"
      - "tests"
