2020-08-07 15:17:07 +00:00
version : 2.1
2022-10-11 20:31:24 +00:00
setup : true
2020-08-07 15:17:07 +00:00
orbs :
2022-10-11 20:31:24 +00:00
continuation : circleci/continuation@0.1.0
2020-08-07 15:17:07 +00:00
2022-10-11 20:31:24 +00:00
parameters :
nightly :
type : boolean
default : false
2020-08-07 15:17:07 +00:00
2018-12-20 21:33:39 +00:00
jobs :
2023-01-03 15:19:38 +00:00
# Ensure running with CircleCI/huggingface
check_circleci_user :
docker :
2024-05-06 08:10:32 +00:00
- image : python:3.10-slim
2025-01-16 20:31:18 +00:00
resource_class : small
2023-01-03 15:19:38 +00:00
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
2022-09-16 13:19:51 +00:00
# Fetch the tests to run
fetch_tests :
2019-09-26 08:15:53 +00:00
working_directory : ~/transformers
2019-09-24 11:25:50 +00:00
docker :
2024-05-06 08:10:32 +00:00
- image : huggingface/transformers-quality
2019-09-24 11:25:50 +00:00
parallelism : 1
steps :
- checkout
2024-05-06 08:10:32 +00:00
- run : uv pip install -U -e .
2024-05-22 08:52:59 +00:00
- run : echo 'export "GIT_COMMIT_MESSAGE=$(git show -s --format=%s)"' >> "$BASH_ENV" && source "$BASH_ENV"
2022-09-16 13:19:51 +00:00
- run : mkdir -p test_preparation
2023-08-11 19:07:08 +00:00
- run : python utils/tests_fetcher.py | tee tests_fetched_summary.txt
2022-10-18 17:47:36 +00:00
- run : python utils/tests_fetcher.py --filter_tests
2024-05-22 08:52:59 +00:00
- run : export "GIT_COMMIT_MESSAGE=$(git show -s --format=%s)" && echo $GIT_COMMIT_MESSAGE && python .circleci/create_circleci_config.py --fetcher_folder test_preparation
2022-09-29 13:36:42 +00:00
- run : |
2024-08-30 16:17:25 +00:00
if [ ! -s test_preparation/generated_config.yml ]; then
echo "No tests to run, exiting early!"
circleci-agent step halt
fi
2022-10-11 20:31:24 +00:00
- store_artifacts :
2024-08-30 16:17:25 +00:00
path : test_preparation
- run :
name : "Retrieve Artifact Paths"
2024-09-20 09:00:34 +00:00
# [reference] https://circleci.com/docs/api/v2/index.html#operation/getJobArtifacts
# `CIRCLE_TOKEN` is defined as an environment variables set within a context, see `https://circleci.com/docs/contexts/`
2024-08-30 16:17:25 +00:00
command : |
project_slug="gh/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}"
job_number=${CIRCLE_BUILD_NUM}
url="https://circleci.com/api/v2/project/${project_slug}/${job_number}/artifacts"
2024-09-20 09:00:34 +00:00
curl -o test_preparation/artifacts.json ${url} --header "Circle-Token: $CIRCLE_TOKEN"
2024-08-30 16:17:25 +00:00
- run :
2024-09-03 14:53:21 +00:00
name : "Prepare pipeline parameters"
2024-08-30 16:17:25 +00:00
command : |
2024-09-03 14:53:21 +00:00
python utils/process_test_artifacts.py
2024-12-16 10:06:17 +00:00
2024-08-30 16:17:25 +00:00
# To avoid too long generated_config.yaml on the continuation orb, we pass the links to the artifacts as parameters.
# Otherwise the list of tests was just too big. Explicit is good but for that it was a limitation.
# We used:
# https://circleci.com/docs/api/v2/index.html#operation/getJobArtifacts : to get the job artifacts
# We could not pass a nested dict, which is why we create the test_file_... parameters for every single job
2024-12-16 10:06:17 +00:00
2023-04-28 20:25:34 +00:00
- store_artifacts :
2024-08-30 16:17:25 +00:00
path : test_preparation/transformed_artifacts.json
2024-09-03 14:53:21 +00:00
- store_artifacts :
path : test_preparation/artifacts.json
2022-10-11 20:31:24 +00:00
- continuation/continue :
2024-08-30 16:17:25 +00:00
parameters : test_preparation/transformed_artifacts.json
2024-05-06 08:10:32 +00:00
configuration_path : test_preparation/generated_config.yml
2022-01-10 12:53:20 +00:00
2022-09-16 13:19:51 +00:00
# To run all tests for the nightly build
fetch_all_tests :
working_directory : ~/transformers
docker :
2024-05-29 13:42:39 +00:00
- image : huggingface/transformers-quality
2022-09-16 13:19:51 +00:00
parallelism : 1
steps :
2022-10-21 14:26:30 +00:00
- checkout
2024-09-20 08:57:21 +00:00
- run : uv pip install -U -e .
- run : echo 'export "GIT_COMMIT_MESSAGE=$(git show -s --format=%s)"' >> "$BASH_ENV" && source "$BASH_ENV"
- run : mkdir -p test_preparation
- run : python utils/tests_fetcher.py --fetch_all | tee tests_fetched_summary.txt
- run : python utils/tests_fetcher.py --filter_tests
- run : export "GIT_COMMIT_MESSAGE=$(git show -s --format=%s)" && echo $GIT_COMMIT_MESSAGE && python .circleci/create_circleci_config.py --fetcher_folder test_preparation
2022-10-24 14:00:02 +00:00
- run : |
2024-09-20 08:57:21 +00:00
if [ ! -s test_preparation/generated_config.yml ]; then
echo "No tests to run, exiting early!"
circleci-agent step halt
fi
2021-08-10 12:54:52 +00:00
- store_artifacts :
2024-09-20 08:57:21 +00:00
path : test_preparation
- run :
name : "Retrieve Artifact Paths"
env :
CIRCLE_TOKEN : ${{ secrets.CI_ARTIFACT_TOKEN }}
command : |
project_slug="gh/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}"
job_number=${CIRCLE_BUILD_NUM}
url="https://circleci.com/api/v2/project/${project_slug}/${job_number}/artifacts"
curl -o test_preparation/artifacts.json ${url}
- run :
name : "Prepare pipeline parameters"
command : |
python utils/process_test_artifacts.py
# To avoid too long generated_config.yaml on the continuation orb, we pass the links to the artifacts as parameters.
# Otherwise the list of tests was just too big. Explicit is good but for that it was a limitation.
# We used:
# https://circleci.com/docs/api/v2/index.html#operation/getJobArtifacts : to get the job artifacts
# We could not pass a nested dict, which is why we create the test_file_... parameters for every single job
- store_artifacts :
path : test_preparation/transformed_artifacts.json
- store_artifacts :
path : test_preparation/artifacts.json
2022-10-11 20:31:24 +00:00
- continuation/continue :
2024-09-20 08:57:21 +00:00
parameters : test_preparation/transformed_artifacts.json
configuration_path : test_preparation/generated_config.yml
2021-08-10 12:54:52 +00:00
2019-12-21 14:49:11 +00:00
check_code_quality :
working_directory : ~/transformers
docker :
2024-05-06 08:10:32 +00:00
- image : huggingface/transformers-quality
2021-07-06 15:46:39 +00:00
resource_class : large
2021-05-04 13:53:44 +00:00
environment :
TRANSFORMERS_IS_CI : yes
2022-07-26 15:57:59 +00:00
PYTEST_TIMEOUT : 120
2019-12-21 14:49:11 +00:00
parallelism : 1
steps :
- checkout
2024-09-24 13:54:07 +00:00
- run : uv pip install -e ".[quality]"
2022-11-02 19:52:39 +00:00
- run :
name : Show installed libraries and their versions
command : pip freeze | tee installed.txt
- store_artifacts :
path : ~/transformers/installed.txt
2024-03-22 09:11:59 +00:00
- run : python -c "from transformers import *" || (echo '🚨 import failed, this means you introduced unprotected imports! 🚨'; exit 1)
2023-11-16 16:43:19 +00:00
- run : ruff check examples tests src utils
- run : ruff format tests src utils --check
2021-03-19 20:17:13 +00:00
- run : python utils/custom_init_isort.py --check_only
2022-05-16 17:24:20 +00:00
- run : python utils/sort_auto_mappings.py --check_only
2022-07-07 12:17:58 +00:00
- run : python utils/check_doc_toc.py
2024-07-30 17:56:10 +00:00
- run : python utils/check_docstrings.py --check_all
2020-11-03 21:57:12 +00:00
2019-12-20 19:56:59 +00:00
check_repository_consistency :
2019-12-05 20:24:57 +00:00
working_directory : ~/transformers
docker :
2024-05-06 08:10:32 +00:00
- image : huggingface/transformers-consistency
2021-11-03 21:43:19 +00:00
resource_class : large
environment :
TRANSFORMERS_IS_CI : yes
2022-07-26 15:57:59 +00:00
PYTEST_TIMEOUT : 120
2019-12-05 20:24:57 +00:00
parallelism : 1
steps :
- checkout
2024-09-24 13:54:07 +00:00
- run : uv pip install -e ".[quality]"
2022-11-02 19:52:39 +00:00
- run :
name : Show installed libraries and their versions
command : pip freeze | tee installed.txt
- store_artifacts :
path : ~/transformers/installed.txt
2021-11-03 21:43:19 +00:00
- run : python utils/check_copies.py
2024-09-24 13:54:07 +00:00
- run : python utils/check_modular_conversion.py
2021-11-03 21:43:19 +00:00
- run : python utils/check_table.py
- run : python utils/check_dummies.py
- run : python utils/check_repo.py
- run : python utils/check_inits.py
2022-04-30 08:40:46 +00:00
- run : python utils/check_config_docstrings.py
2023-02-07 16:49:30 +00:00
- run : python utils/check_config_attributes.py
2023-01-26 14:33:47 +00:00
- run : python utils/check_doctest_list.py
2021-11-03 21:43:19 +00:00
- run : make deps_table_check_updated
2022-09-14 18:06:49 +00:00
- run : python utils/update_metadata.py --check-only
2023-10-04 13:13:37 +00:00
- run : python utils/check_docstrings.py
2023-12-22 11:56:11 +00:00
- run : python utils/check_support_list.py
2020-08-07 15:17:07 +00:00
2019-02-05 23:25:12 +00:00
workflows :
2019-08-29 16:14:29 +00:00
version : 2
2022-10-11 20:31:24 +00:00
setup_and_quality :
when :
2024-10-01 15:42:45 +00:00
and :
- equal : [ <<pipeline.project.git_url>>, https://github.com/huggingface/transformers]
- not : <<pipeline.parameters.nightly>>
jobs :
- check_circleci_user
- check_code_quality
- check_repository_consistency
- fetch_tests
setup_and_quality_2 :
when :
not :
equal : [ <<pipeline.project.git_url>>, https://github.com/huggingface/transformers]
2019-08-29 16:14:29 +00:00
jobs :
2023-01-03 15:19:38 +00:00
- check_circleci_user
2019-12-21 14:49:11 +00:00
- check_code_quality
2019-12-20 19:56:59 +00:00
- check_repository_consistency
2024-09-20 09:00:34 +00:00
- fetch_tests :
# [reference] https://circleci.com/docs/contexts/
context :
- TRANSFORMERS_CONTEXT
2022-10-11 20:31:24 +00:00
2021-08-10 12:54:52 +00:00
nightly :
2022-10-11 20:31:24 +00:00
when : <<pipeline.parameters.nightly>>
2021-08-10 12:54:52 +00:00
jobs :
2023-01-03 15:19:38 +00:00
- check_circleci_user
2022-10-11 20:31:24 +00:00
- check_code_quality
- check_repository_consistency
2024-07-30 17:56:10 +00:00
- fetch_all_tests