config.yml 6.57 KB
Newer Older
1
version: 2.1
2
setup: true
3
orbs:
4
    continuation: circleci/continuation@0.1.0
5

6
7
8
9
parameters:
    nightly:
        type: boolean
        default: false
10

Julien Chaumond's avatar
Julien Chaumond committed
11
jobs:
Sylvain Gugger's avatar
Sylvain Gugger committed
12
13
    # Fetch the tests to run
    fetch_tests:
14
        working_directory: ~/transformers
15
        docker:
16
            - image: cimg/python:3.7.12
17
18
19
        parallelism: 1
        steps:
            - checkout
20
            - run: pip install --upgrade pip
Sylvain Gugger's avatar
Sylvain Gugger committed
21
22
23
24
            - run: pip install GitPython
            - run: pip install .
            - run: mkdir -p test_preparation
            - run: python utils/tests_fetcher.py | tee tests_fetched_summary.txt
25
            - store_artifacts:
26
                  path: ~/transformers/tests_fetched_summary.txt
27
            - run: |
Sylvain Gugger's avatar
Sylvain Gugger committed
28
                if [ -f test_list.txt ]; then
29
                    cp test_list.txt test_preparation/test_list.txt
Sylvain Gugger's avatar
Sylvain Gugger committed
30
31
32
                else
                    touch test_preparation/test_list.txt
                fi
Sylvain Gugger's avatar
Sylvain Gugger committed
33
34
35
36
37
38
39
            - run: |
                if [ -f test_repo_utils.txt ]; then
                    mv test_repo_utils.txt test_preparation/test_repo_utils.txt
                else
                    touch test_preparation/test_repo_utils.txt
                fi
            - run: python utils/tests_fetcher.py --filter_tests
40
41
42
43
44
45
            - run: |
                if [ -f test_list.txt ]; then
                    mv test_list.txt test_preparation/filtered_test_list.txt
                else
                    touch test_preparation/filtered_test_list.txt
                fi
46
47
48
49
50
51
52
53
54
            - run: python utils/tests_fetcher.py --filters tests examples | tee examples_tests_fetched_summary.txt
            - run: |
                  if [ -f test_list.txt ]; then
                      mv test_list.txt test_preparation/examples_test_list.txt
                  else
                      touch test_preparation/examples_test_list.txt
                  fi
            - store_artifacts:
                  path: test_preparation/test_list.txt
55
56
            - store_artifacts:
                  path: ~/transformers/test_preparation/filtered_test_list.txt
57
            - store_artifacts:
58
59
                  path: test_preparation/examples_test_list.txt
            - run: python .circleci/create_circleci_config.py --fetcher_folder test_preparation
60
            - run: |
61
62
63
64
65
66
67
68
69
                  if [ ! -s test_preparation/generated_config.yml ]; then
                      echo "No tests to run, exiting early!"
                      circleci-agent step halt
                  fi
            - run: cp test_preparation/generated_config.yml test_preparation/generated_config.txt
            - store_artifacts:
                  path: test_preparation/generated_config.txt
            - continuation/continue:
                  configuration_path: test_preparation/generated_config.yml
70

Sylvain Gugger's avatar
Sylvain Gugger committed
71
72
73
74
75
76
77
    # To run all tests for the nightly build
    fetch_all_tests:
        working_directory: ~/transformers
        docker:
            - image: cimg/python:3.7.12
        parallelism: 1
        steps:
78
79
            - run: pip install --upgrade pip
            - run: pip install .
Sylvain Gugger's avatar
Sylvain Gugger committed
80
81
82
            - run: |
                  mkdir test_preparation
                  echo "tests" > test_preparation/test_list.txt
83
                  echo "tests" > test_preparation/examples_test_list.txt
Sylvain Gugger's avatar
Sylvain Gugger committed
84
            - run: python utils/tests_fetcher.py --filter_tests
85
            - run: mv test_list.txt test_preparation/filtered_test_list.txt
Sylvain Gugger's avatar
Sylvain Gugger committed
86
            - run: mv test_repo_utils.txt test_preparation/test_repo_utils.txt
87
88
            - run: python .circleci/create_circleci_config.py --fetcher_folder test_preparation
            - run: cp test_preparation/generated_config.yml test_preparation/generated_config.txt
89
            - store_artifacts:
90
91
92
                  path: test_preparation/generated_config.txt
            - continuation/continue:
                  configuration_path: test_preparation/generated_config.yml
93

Aymeric Augustin's avatar
Aymeric Augustin committed
94
95
96
    check_code_quality:
        working_directory: ~/transformers
        docker:
97
            - image: cimg/python:3.7.12
Lysandre's avatar
Lysandre committed
98
        resource_class: large
99
100
        environment:
            TRANSFORMERS_IS_CI: yes
101
            PYTEST_TIMEOUT: 120
Aymeric Augustin's avatar
Aymeric Augustin committed
102
103
104
        parallelism: 1
        steps:
            - checkout
105
106
            - restore_cache:
                  keys:
Yih-Dar's avatar
Yih-Dar committed
107
                      - v0.5-code_quality-{{ checksum "setup.py" }}
108
                      - v0.5-code-quality
109
            - run: pip install --upgrade pip
110
            - run: pip install .[all,quality]
111
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
112
                  key: v0.5-code_quality-{{ checksum "setup.py" }}
113
114
                  paths:
                      - '~/.cache/pip'
Sylvain Gugger's avatar
Sylvain Gugger committed
115
            - run: black --check --preview examples tests src utils
116
            - run: isort --check-only examples tests src utils
Sylvain Gugger's avatar
Sylvain Gugger committed
117
            - run: python utils/custom_init_isort.py --check_only
118
            - run: python utils/sort_auto_mappings.py --check_only
119
            - run: flake8 examples tests src utils
120
            - run: doc-builder style src/transformers docs/source --max_len 119 --check_only --path_to_docs docs/source
Sylvain Gugger's avatar
Sylvain Gugger committed
121
            - run: python utils/check_doc_toc.py
122

123
    check_repository_consistency:
R茅mi Louf's avatar
R茅mi Louf committed
124
125
        working_directory: ~/transformers
        docker:
126
            - image: cimg/python:3.7.12
Sylvain Gugger's avatar
Sylvain Gugger committed
127
128
129
        resource_class: large
        environment:
            TRANSFORMERS_IS_CI: yes
130
            PYTEST_TIMEOUT: 120
R茅mi Louf's avatar
R茅mi Louf committed
131
132
133
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
134
135
            - restore_cache:
                  keys:
Yih-Dar's avatar
Yih-Dar committed
136
                      - v0.5-repository_consistency-{{ checksum "setup.py" }}
137
                      - v0.5-repository_consistency
Sylvain Gugger's avatar
Sylvain Gugger committed
138
139
140
            - run: pip install --upgrade pip
            - run: pip install .[all,quality]
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
141
                  key: v0.5-repository_consistency-{{ checksum "setup.py" }}
Sylvain Gugger's avatar
Sylvain Gugger committed
142
143
144
145
146
147
148
                  paths:
                      - '~/.cache/pip'
            - run: python utils/check_copies.py
            - run: python utils/check_table.py
            - run: python utils/check_dummies.py
            - run: python utils/check_repo.py
            - run: python utils/check_inits.py
149
            - run: python utils/check_config_docstrings.py
Sylvain Gugger's avatar
Sylvain Gugger committed
150
151
            - run: make deps_table_check_updated
            - run: python utils/tests_fetcher.py --sanity_check
152
            - run: python utils/update_metadata.py --check-only
153

154
workflows:
LysandreJik's avatar
LysandreJik committed
155
    version: 2
156
157
158
    setup_and_quality:
        when:
            not: <<pipeline.parameters.nightly>>
LysandreJik's avatar
LysandreJik committed
159
        jobs:
Aymeric Augustin's avatar
Aymeric Augustin committed
160
            - check_code_quality
161
            - check_repository_consistency
Sylvain Gugger's avatar
Sylvain Gugger committed
162
            - fetch_tests
163

164
    nightly:
165
        when: <<pipeline.parameters.nightly>>
166
        jobs:
167
168
169
            - check_code_quality
            - check_repository_consistency
            - fetch_all_tests