config.yml 7.94 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:
12
13
14
15
16
17
18
19
20
21
22
23
24
    # Ensure running with CircleCI/huggingface
    check_circleci_user:
        docker:
            - image: cimg/python:3.7.12
        parallelism: 1
        steps:
            - run: echo $CIRCLE_PROJECT_USERNAME
            - run: |
                if [ "$CIRCLE_PROJECT_USERNAME" = "huggingface" ]; then
                    exit 0
                else
                    echo "The CI is running under $CIRCLE_PROJECT_USERNAME personal account. Please follow https://support.circleci.com/hc/en-us/articles/360008097173-Troubleshooting-why-pull-requests-are-not-triggering-jobs-on-my-organization- to fix it."; exit -1
                fi
Sylvain Gugger's avatar
Sylvain Gugger committed
25
26
    # Fetch the tests to run
    fetch_tests:
27
        working_directory: ~/transformers
28
        docker:
29
            - image: cimg/python:3.7.12
30
31
32
        parallelism: 1
        steps:
            - checkout
33
            - run: pip install --upgrade pip
Sylvain Gugger's avatar
Sylvain Gugger committed
34
35
36
37
            - run: pip install GitPython
            - run: pip install .
            - run: mkdir -p test_preparation
            - run: python utils/tests_fetcher.py | tee tests_fetched_summary.txt
38
            - store_artifacts:
39
                  path: ~/transformers/tests_fetched_summary.txt
40
            - run: |
Sylvain Gugger's avatar
Sylvain Gugger committed
41
                if [ -f test_list.txt ]; then
42
                    cp test_list.txt test_preparation/test_list.txt
Sylvain Gugger's avatar
Sylvain Gugger committed
43
44
45
                else
                    touch test_preparation/test_list.txt
                fi
Sylvain Gugger's avatar
Sylvain Gugger committed
46
47
48
49
50
51
52
            - 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
53
54
55
56
57
58
            - 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
59
60
61
62
63
64
65
66
67
            - 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
68
69
            - store_artifacts:
                  path: ~/transformers/test_preparation/filtered_test_list.txt
70
            - store_artifacts:
71
72
                  path: test_preparation/examples_test_list.txt
            - run: python .circleci/create_circleci_config.py --fetcher_folder test_preparation
73
            - run: |
74
75
76
77
78
79
80
81
82
                  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
83

Sylvain Gugger's avatar
Sylvain Gugger committed
84
85
86
87
88
89
90
    # To run all tests for the nightly build
    fetch_all_tests:
        working_directory: ~/transformers
        docker:
            - image: cimg/python:3.7.12
        parallelism: 1
        steps:
91
            - checkout
92
            - run: pip install --upgrade pip
ydshieh's avatar
ydshieh committed
93
            - run: pip install GitPython
94
            - run: pip install .
Sylvain Gugger's avatar
Sylvain Gugger committed
95
96
            - run: |
                  mkdir test_preparation
Yih-Dar's avatar
Yih-Dar committed
97
98
99
100
101
102
103
                  echo -n "tests" > test_preparation/test_list.txt
                  echo -n "tests" > test_preparation/examples_test_list.txt
                  echo -n "tests/repo_utils" > test_preparation/test_repo_utils.txt
            - run: |
                  echo -n "tests" > test_list.txt
                  python utils/tests_fetcher.py --filter_tests
                  mv test_list.txt test_preparation/filtered_test_list.txt
104
105
            - run: python .circleci/create_circleci_config.py --fetcher_folder test_preparation
            - run: cp test_preparation/generated_config.yml test_preparation/generated_config.txt
106
            - store_artifacts:
107
108
109
                  path: test_preparation/generated_config.txt
            - continuation/continue:
                  configuration_path: test_preparation/generated_config.yml
110

Aymeric Augustin's avatar
Aymeric Augustin committed
111
112
113
    check_code_quality:
        working_directory: ~/transformers
        docker:
114
            - image: cimg/python:3.7.12
Lysandre's avatar
Lysandre committed
115
        resource_class: large
116
117
        environment:
            TRANSFORMERS_IS_CI: yes
118
            PYTEST_TIMEOUT: 120
Aymeric Augustin's avatar
Aymeric Augustin committed
119
120
121
        parallelism: 1
        steps:
            - checkout
122
123
            - restore_cache:
                  keys:
Yih-Dar's avatar
Yih-Dar committed
124
                      - v0.5-code_quality-{{ checksum "setup.py" }}
125
                      - v0.5-code-quality
126
            - run: pip install --upgrade pip
127
            - run: pip install .[all,quality]
128
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
129
                  key: v0.5-code_quality-{{ checksum "setup.py" }}
130
131
                  paths:
                      - '~/.cache/pip'
132
133
134
135
136
            - run:
                name: Show installed libraries and their versions
                command: pip freeze | tee installed.txt
            - store_artifacts:
                  path: ~/transformers/installed.txt
Sylvain Gugger's avatar
Sylvain Gugger committed
137
            - run: black --check --preview examples tests src utils
138
            - run: isort --check-only examples tests src utils
Sylvain Gugger's avatar
Sylvain Gugger committed
139
            - run: python utils/custom_init_isort.py --check_only
140
            - run: python utils/sort_auto_mappings.py --check_only
141
            - run: flake8 examples tests src utils
142
            - 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
143
            - run: python utils/check_doc_toc.py
144

145
    check_repository_consistency:
R茅mi Louf's avatar
R茅mi Louf committed
146
147
        working_directory: ~/transformers
        docker:
148
            - image: cimg/python:3.7.12
Sylvain Gugger's avatar
Sylvain Gugger committed
149
150
151
        resource_class: large
        environment:
            TRANSFORMERS_IS_CI: yes
152
            PYTEST_TIMEOUT: 120
R茅mi Louf's avatar
R茅mi Louf committed
153
154
155
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
156
157
            - restore_cache:
                  keys:
Yih-Dar's avatar
Yih-Dar committed
158
                      - v0.5-repository_consistency-{{ checksum "setup.py" }}
159
                      - v0.5-repository_consistency
Sylvain Gugger's avatar
Sylvain Gugger committed
160
161
162
            - run: pip install --upgrade pip
            - run: pip install .[all,quality]
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
163
                  key: v0.5-repository_consistency-{{ checksum "setup.py" }}
Sylvain Gugger's avatar
Sylvain Gugger committed
164
165
                  paths:
                      - '~/.cache/pip'
166
167
168
169
170
            - run:
                name: Show installed libraries and their versions
                command: pip freeze | tee installed.txt
            - store_artifacts:
                  path: ~/transformers/installed.txt
Sylvain Gugger's avatar
Sylvain Gugger committed
171
172
173
174
175
            - 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
176
            - run: python utils/check_config_docstrings.py
177
            - run: python utils/check_doctest_list.py
Sylvain Gugger's avatar
Sylvain Gugger committed
178
179
            - run: make deps_table_check_updated
            - run: python utils/tests_fetcher.py --sanity_check
180
            - run: python utils/update_metadata.py --check-only
181
            - run: python utils/check_task_guides.py
182

183
workflows:
LysandreJik's avatar
LysandreJik committed
184
    version: 2
185
186
187
    setup_and_quality:
        when:
            not: <<pipeline.parameters.nightly>>
LysandreJik's avatar
LysandreJik committed
188
        jobs:
189
            - check_circleci_user
Aymeric Augustin's avatar
Aymeric Augustin committed
190
            - check_code_quality
191
            - check_repository_consistency
Sylvain Gugger's avatar
Sylvain Gugger committed
192
            - fetch_tests
193

194
    nightly:
195
        when: <<pipeline.parameters.nightly>>
196
        jobs:
197
            - check_circleci_user
198
199
200
            - check_code_quality
            - check_repository_consistency
            - fetch_all_tests