Skip to content

Commit 363e804

Browse files
authored
Update ats script (#200)
# Motivation <!-- Why is this change necessary? --> # Content <!-- Please include a summary of the change --> # Testing <!-- How was the change tested? --> # Please check the following before marking your PR as ready for review - [ ] I have added tests for my changes - [ ] I have updated the documentation or added new documentation as needed - [ ] I have read and agree to the [Contributor License Agreement](../CLA.md)
1 parent e2b8af9 commit 363e804

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

.circleci/ats.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,29 @@ uv run --frozen codecovcli static-analysis --token ${CODECOV_STATIC_TOKEN} --fol
1515
ATS_COLLECT_ARGS="${ATS_COLLECT_ARGS}${DEFAULT_TESTS},"
1616
echo "Label analysis with base sha: ${BASE_SHA} and default tests: ${ATS_COLLECT_ARGS}"
1717
runner_param="collect_tests_options=${ATS_COLLECT_ARGS}"
18-
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")
18+
19+
# Always get last 10 commits as fallback options, starting with BASE_SHA if provided
20+
base_commit_candidates=($(git log --format=%H | sed -n "1,10p"))
21+
if [[ -n ${BASE_SHA} ]]; then
22+
# Prepend BASE_SHA to the candidates list if it's provided
23+
base_commit_candidates=("${BASE_SHA}" "${base_commit_candidates[@]}")
24+
fi
25+
26+
for base_commit in ${base_commit_candidates[@]}
27+
do
28+
echo "Attempting label analysis with base commit: $base_commit"
29+
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)
30+
if [[ -n $response ]]; then
31+
break
32+
else
33+
echo "-> Attempt failed"
34+
fi
35+
done
36+
37+
if [[ -z $response ]]; then
38+
echo "Failed to run label analysis with any base commit."
39+
fi
40+
1941
mkdir codecov_ats
2042
jq <<< "$response" '.runner_options + .ats_tests_to_run | .[1:] | map(gsub("\""; "")) | join(" ")' --raw-output > codecov_ats/tests_to_run.txt
2143
jq <<< "$response" '.runner_options + .ats_tests_to_skip | .[1:] | map(gsub("\""; "")) | join(" ")' --raw-output > codecov_ats/tests_to_skip.txt

0 commit comments

Comments
 (0)