From bb65567407c142f9efd74152df4966fd22d9c5c8 Mon Sep 17 00:00:00 2001 From: bagel897 Date: Wed, 29 Jan 2025 15:53:30 -0800 Subject: [PATCH 1/3] Update ats script --- .circleci/ats.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/.circleci/ats.sh b/.circleci/ats.sh index 0177e8494..bc4d7d574 100755 --- a/.circleci/ats.sh +++ b/.circleci/ats.sh @@ -15,7 +15,29 @@ uv run --frozen codecovcli static-analysis --token ${CODECOV_STATIC_TOKEN} --fol ATS_COLLECT_ARGS="${ATS_COLLECT_ARGS}${DEFAULT_TESTS}," echo "Label analysis with base sha: ${BASE_SHA} and default tests: ${ATS_COLLECT_ARGS}" runner_param="collect_tests_options=${ATS_COLLECT_ARGS}" -response=$(uv run --frozen codecovcli label-analysis --token ${CODECOV_STATIC_TOKEN} --base-sha=$BASE_SHA --dry-run --dry-run-format="json" --runner-param "$runner_param") + +# Always get last 10 commits as fallback options, starting with BASE_SHA if provided +base_commit_candidates=($(git log --format=%H | sed -n "1,10p")) +if [[ -n ${BASE_SHA} ]]; then + # Prepend BASE_SHA to the candidates list if it's provided + base_commit_candidates=("${BASE_SHA}" "${base_commit_candidates[@]}") +fi + +for base_commit in ${base_commit_candidates[@]} +do + echo "Attempting label analysis with base commit: $base_commit" + response=$(uv run --frozen codecovcli label-analysis --token ${CODECOV_STATIC_TOKEN} --base-sha=$base_commit --dry-run --dry-run-format="json" --runner-param "$runner_param" --wait-time=2 || true) + if [[ -n $response ]]; then + break + else + echo "-> Attempt failed" + fi +done + +if [[ -z $response ]]; then + echo "Failed to run label analysis with any base commit." +fi + mkdir codecov_ats jq <<< "$response" '.runner_options + .ats_tests_to_run | .[1:] | map(gsub("\""; "")) | join(" ")' --raw-output > codecov_ats/tests_to_run.txt jq <<< "$response" '.runner_options + .ats_tests_to_skip | .[1:] | map(gsub("\""; "")) | join(" ")' --raw-output > codecov_ats/tests_to_skip.txt From 00851ad147e8b1f7a406327df11a38cb0cf1ce80 Mon Sep 17 00:00:00 2001 From: bagel897 Date: Wed, 29 Jan 2025 15:57:09 -0800 Subject: [PATCH 2/3] Fix arg --- .circleci/ats.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/ats.sh b/.circleci/ats.sh index bc4d7d574..be375a4c7 100755 --- a/.circleci/ats.sh +++ b/.circleci/ats.sh @@ -26,7 +26,7 @@ fi for base_commit in ${base_commit_candidates[@]} do echo "Attempting label analysis with base commit: $base_commit" - response=$(uv run --frozen codecovcli label-analysis --token ${CODECOV_STATIC_TOKEN} --base-sha=$base_commit --dry-run --dry-run-format="json" --runner-param "$runner_param" --wait-time=2 || true) + response=$(uv run --frozen codecovcli label-analysis --token ${CODECOV_STATIC_TOKEN} --base-sha=$base_commit --dry-run --dry-run-format="json" --runner-param "$runner_param" --max-wait-time=2 || true) if [[ -n $response ]]; then break else From 00c917fe6f0a42afb9b80f7bea2f67a5e3aff332 Mon Sep 17 00:00:00 2001 From: bagel897 Date: Wed, 29 Jan 2025 16:01:38 -0800 Subject: [PATCH 3/3] Wait up to 30s --- .circleci/ats.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/ats.sh b/.circleci/ats.sh index be375a4c7..261e849d2 100755 --- a/.circleci/ats.sh +++ b/.circleci/ats.sh @@ -26,7 +26,7 @@ fi for base_commit in ${base_commit_candidates[@]} do echo "Attempting label analysis with base commit: $base_commit" - response=$(uv run --frozen codecovcli label-analysis --token ${CODECOV_STATIC_TOKEN} --base-sha=$base_commit --dry-run --dry-run-format="json" --runner-param "$runner_param" --max-wait-time=2 || true) + response=$(uv run --frozen codecovcli label-analysis --token ${CODECOV_STATIC_TOKEN} --base-sha=$base_commit --dry-run --dry-run-format="json" --runner-param "$runner_param" --max-wait-time=30 || true) if [[ -n $response ]]; then break else