From 6dc364616d58b9fdc70f88cd2c136e741fc28d26 Mon Sep 17 00:00:00 2001 From: Yih-Dar <2521628+ydshieh@users.noreply.github.com> Date: Fri, 20 Sep 2024 10:57:21 +0200 Subject: [PATCH] Fix CircleCI nightly run (#33558) fix Co-authored-by: ydshieh --- .circleci/config.yml | 53 +++++++++++++++++++++++++++++++----------- utils/tests_fetcher.py | 9 ++++--- 2 files changed, 46 insertions(+), 16 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 483e315e260..0c03538f07d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -82,22 +82,49 @@ jobs: parallelism: 1 steps: - checkout - - run: uv pip install -e . + - 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 - run: | - mkdir test_preparation - echo -n "tests" > test_preparation/test_list.txt - echo -n "all" > 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 - - run: python .circleci/create_circleci_config.py --fetcher_folder test_preparation - - run: cp test_preparation/generated_config.yml test_preparation/generated_config.txt + if [ ! -s test_preparation/generated_config.yml ]; then + echo "No tests to run, exiting early!" + circleci-agent step halt + fi + - store_artifacts: - path: test_preparation/generated_config.txt + 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 - continuation/continue: - configuration_path: test_preparation/generated_config.yml + parameters: test_preparation/transformed_artifacts.json + configuration_path: test_preparation/generated_config.yml check_code_quality: working_directory: ~/transformers diff --git a/utils/tests_fetcher.py b/utils/tests_fetcher.py index 8ccd738c1df..1aa663e967c 100644 --- a/utils/tests_fetcher.py +++ b/utils/tests_fetcher.py @@ -1193,9 +1193,9 @@ if __name__ == "__main__": default=None, ) parser.add_argument( - "--commit_message", - type=str, - help="The commit message (which could contain a command to force all tests or skip the CI).", + "--fetch_all", + action="store_true", + help="Will fetch all tests.", default=None, ) args = parser.parse_args() @@ -1212,6 +1212,9 @@ if __name__ == "__main__": quit() if commit_flags["no_filter"]: print("Running all tests fetched without filtering.") + + if args.fetch_all: + commit_flags["test_all"] = True if commit_flags["test_all"]: print("Force-launching all tests")