config.yml 7.91 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
    # Ensure running with CircleCI/huggingface
    check_circleci_user:
        docker:
15
            - image: python:3.10-slim
16
17
18
19
20
21
22
23
24
        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: huggingface/transformers-quality
30
31
32
        parallelism: 1
        steps:
            - checkout
33
            - run: uv pip install -U -e .
34
            - run: echo 'export "GIT_COMMIT_MESSAGE=$(git show -s --format=%s)"' >> "$BASH_ENV" && source "$BASH_ENV"
Sylvain Gugger's avatar
Sylvain Gugger committed
35
            - run: mkdir -p test_preparation
36
            - run: python utils/tests_fetcher.py | tee tests_fetched_summary.txt
37
            - store_artifacts:
38
                  path: ~/transformers/tests_fetched_summary.txt
39
            - run: |
Sylvain Gugger's avatar
Sylvain Gugger committed
40
                if [ -f test_list.txt ]; then
41
                    cp test_list.txt test_preparation/test_list.txt
Sylvain Gugger's avatar
Sylvain Gugger committed
42
43
44
                else
                    touch test_preparation/test_list.txt
                fi
45
46
47
48
49
50
            - run: |
                  if [ -f examples_test_list.txt ]; then
                      mv examples_test_list.txt test_preparation/examples_test_list.txt
                  else
                      touch test_preparation/examples_test_list.txt
                  fi
51
52
53
54
55
56
            - run: |
                  if [ -f filtered_test_list_cross_tests.txt ]; then
                      mv filtered_test_list_cross_tests.txt test_preparation/filtered_test_list_cross_tests.txt
                  else
                      touch test_preparation/filtered_test_list_cross_tests.txt
                  fi
57
58
59
60
61
62
            - run: |
                if [ -f doctest_list.txt ]; then
                    cp doctest_list.txt test_preparation/doctest_list.txt
                else
                    touch test_preparation/doctest_list.txt
                fi
Sylvain Gugger's avatar
Sylvain Gugger committed
63
64
65
66
67
68
69
            - 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
70
71
72
73
74
75
            - 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
76
77
            - store_artifacts:
                  path: test_preparation/test_list.txt
78
79
            - store_artifacts:
                  path: test_preparation/doctest_list.txt
80
81
            - store_artifacts:
                  path: ~/transformers/test_preparation/filtered_test_list.txt
82
            - store_artifacts:
83
                  path: test_preparation/examples_test_list.txt
84
            - run: export "GIT_COMMIT_MESSAGE=$(git show -s --format=%s)" && echo $GIT_COMMIT_MESSAGE && python .circleci/create_circleci_config.py --fetcher_folder test_preparation
85
            - run: |
86
87
88
89
90
                  if [ ! -s test_preparation/generated_config.yml ]; then
                      echo "No tests to run, exiting early!"
                      circleci-agent step halt
                  fi
            - store_artifacts:
91
                path: test_preparation/generated_config.yml
Yih-Dar's avatar
Yih-Dar committed
92
            - store_artifacts:
93
                path: test_preparation/filtered_test_list_cross_tests.txt
94
            - continuation/continue:
95
                configuration_path: test_preparation/generated_config.yml
96

Sylvain Gugger's avatar
Sylvain Gugger committed
97
98
99
100
    # To run all tests for the nightly build
    fetch_all_tests:
        working_directory: ~/transformers
        docker:
Yih-Dar's avatar
Yih-Dar committed
101
            - image: huggingface/transformers-quality
Sylvain Gugger's avatar
Sylvain Gugger committed
102
103
        parallelism: 1
        steps:
104
            - checkout
105
            - run: uv pip install -e .
Sylvain Gugger's avatar
Sylvain Gugger committed
106
107
            - run: |
                  mkdir test_preparation
Yih-Dar's avatar
Yih-Dar committed
108
                  echo -n "tests" > test_preparation/test_list.txt
109
                  echo -n "all" > test_preparation/examples_test_list.txt
Yih-Dar's avatar
Yih-Dar committed
110
111
112
113
114
                  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
115
116
            - run: python .circleci/create_circleci_config.py --fetcher_folder test_preparation
            - run: cp test_preparation/generated_config.yml test_preparation/generated_config.txt
117
            - store_artifacts:
118
119
120
                  path: test_preparation/generated_config.txt
            - continuation/continue:
                  configuration_path: test_preparation/generated_config.yml
121

Aymeric Augustin's avatar
Aymeric Augustin committed
122
123
124
    check_code_quality:
        working_directory: ~/transformers
        docker:
125
            - image: huggingface/transformers-quality
Lysandre's avatar
Lysandre committed
126
        resource_class: large
127
128
        environment:
            TRANSFORMERS_IS_CI: yes
129
            PYTEST_TIMEOUT: 120
Aymeric Augustin's avatar
Aymeric Augustin committed
130
131
132
        parallelism: 1
        steps:
            - checkout
133
            - run: uv pip install -e .
134
135
136
137
138
            - run:
                name: Show installed libraries and their versions
                command: pip freeze | tee installed.txt
            - store_artifacts:
                  path: ~/transformers/installed.txt
139
            - run: python -c "from transformers import *" || (echo '馃毃 import failed, this means you introduced unprotected imports! 馃毃'; exit 1)
140
141
            - run: ruff check examples tests src utils
            - run: ruff format tests src utils --check
Sylvain Gugger's avatar
Sylvain Gugger committed
142
            - run: python utils/custom_init_isort.py --check_only
143
            - run: python utils/sort_auto_mappings.py --check_only
Sylvain Gugger's avatar
Sylvain Gugger committed
144
            - run: python utils/check_doc_toc.py
145
            - run: python utils/check_docstrings.py --check_all
146

147
    check_repository_consistency:
R茅mi Louf's avatar
R茅mi Louf committed
148
149
        working_directory: ~/transformers
        docker:
150
            - image: huggingface/transformers-consistency
Sylvain Gugger's avatar
Sylvain Gugger committed
151
152
153
        resource_class: large
        environment:
            TRANSFORMERS_IS_CI: yes
154
            PYTEST_TIMEOUT: 120
R茅mi Louf's avatar
R茅mi Louf committed
155
156
157
        parallelism: 1
        steps:
            - checkout
158
            - run: uv pip install -e .
159
160
161
162
163
            - 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
164
165
166
167
168
            - 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
169
            - run: python utils/check_config_docstrings.py
170
            - run: python utils/check_config_attributes.py
171
            - run: python utils/check_doctest_list.py
Sylvain Gugger's avatar
Sylvain Gugger committed
172
            - run: make deps_table_check_updated
173
            - run: python utils/update_metadata.py --check-only
Sylvain Gugger's avatar
Sylvain Gugger committed
174
            - run: python utils/check_docstrings.py
175
            - run: python utils/check_support_list.py
176

177
workflows:
LysandreJik's avatar
LysandreJik committed
178
    version: 2
179
180
181
    setup_and_quality:
        when:
            not: <<pipeline.parameters.nightly>>
LysandreJik's avatar
LysandreJik committed
182
        jobs:
183
            - check_circleci_user
Aymeric Augustin's avatar
Aymeric Augustin committed
184
            - check_code_quality
185
            - check_repository_consistency
Sylvain Gugger's avatar
Sylvain Gugger committed
186
            - fetch_tests
187

188
    nightly:
189
        when: <<pipeline.parameters.nightly>>
190
        jobs:
191
            - check_circleci_user
192
193
            - check_code_quality
            - check_repository_consistency
194
            - fetch_all_tests