version: 2
jobs:
    run_tests_py3_torch_and_tf:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.5
        environment:
            OMP_NUM_THREADS: 1
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
            - run: sudo pip install torch
            - run: sudo pip install tensorflow
            - run: sudo pip install --progress-bar off .
            - run: sudo pip install pytest codecov pytest-cov pytest-xdist
            - run: sudo pip install tensorboardX scikit-learn
            - run: python -m pytest -n 8 --dist=loadfile -s -v ./tests/ --cov
            - run: codecov
    run_tests_py3_torch:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.5
        environment:
            OMP_NUM_THREADS: 1
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
            - run: sudo pip install torch
            - run: sudo pip install --progress-bar off .
            - run: sudo pip install pytest codecov pytest-cov pytest-xdist
            - run: sudo pip install tensorboardX scikit-learn
            - run: python -m pytest -n 8 --dist=loadfile -s -v ./tests/ --cov
            - run: codecov
    run_tests_py3_tf:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.5
        environment:
            OMP_NUM_THREADS: 1
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
            - run: sudo pip install tensorflow
            - run: sudo pip install --progress-bar off .
            - run: sudo pip install pytest codecov pytest-cov pytest-xdist
            - run: sudo pip install tensorboardX scikit-learn
            - run: python -m pytest -n 8 --dist=loadfile -s -v ./tests/ --cov
            - run: codecov
    run_tests_py3_custom_tokenizers:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.5
        steps:
            - checkout
            - run: sudo pip install --progress-bar off .
            - run: sudo pip install pytest pytest-xdist
            - run: sudo pip install mecab-python3
            - run: RUN_CUSTOM_TOKENIZERS=1 python -m pytest -sv ./tests/test_tokenization_bert_japanese.py
    run_examples_py3_torch:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.5
        environment:
            OMP_NUM_THREADS: 1
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
            - run: sudo pip install torch
            - run: sudo pip install --progress-bar off .
            - run: sudo pip install pytest pytest-xdist
            - run: sudo pip install tensorboardX scikit-learn
            - run: python -m pytest -n 8 --dist=loadfile -s -v ./examples/
    deploy_doc:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.5
        steps:
            - add_ssh_keys:
                  fingerprints:
                      - "5b:7a:95:18:07:8c:aa:76:4c:60:35:88:ad:60:56:71"
            - checkout
            - run: sudo pip install --progress-bar off -r docs/requirements.txt
            - run: sudo pip install --progress-bar off -r requirements.txt
            - run: ./.circleci/deploy.sh
    check_code_quality:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.6
        resource_class: medium
        parallelism: 1
        steps:
            - checkout
            - run: sudo pip install --editable .
            - run: sudo pip install torch tensorflow
            - run: sudo pip install black git+git://github.com/timothycrosley/isort.git@e63ae06ec7d70b06df9e528357650281a3d3ec22#egg=isort flake8
            - run: black --check --line-length 119 examples templates tests src utils
            - run: isort --check-only --recursive examples templates tests src utils
            - run: flake8 examples templates tests src utils
    check_repository_consistency:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.5
        resource_class: small
        parallelism: 1
        steps:
            - checkout
            - run: sudo pip install requests
            - run: python ./utils/link_tester.py
workflow_filters: &workflow_filters
    filters:
        branches:
            only:
                - master
workflows:
    version: 2
    build_and_test:
        jobs:
            - check_code_quality
            - check_repository_consistency
            - run_examples_py3_torch
            - run_tests_py3_custom_tokenizers
            - run_tests_py3_torch_and_tf
            - run_tests_py3_torch
            - run_tests_py3_tf
            - deploy_doc: *workflow_filters
