Skip to content

Commit 41a632b

Browse files
zakiskchmouel
authored andcommitted
chore: divide Gitea tests in equall number in 3 jobs
Before this update, Gitea tests were partitioned into three jobs based on the first letter following the "Gitea" keyword. This alphabetic approach resulted in an uneven distribution, causing some jobs to handle a significantly higher workload than others. After this update, the tests are divided equally by count, ensuring a balanced load across jobs and improved CI scalability. Signed-off-by: Zaki Shaikh <zashaikh@redhat.com>
1 parent eb39d14 commit 41a632b

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

hack/gh-workflow-ci.sh

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,23 @@ get_tests() {
7777
mapfile -t testfiles < <(find test/ -maxdepth 1 -name '*.go')
7878
all_tests=$(grep -hioP '^func[[:space:]]+Test[[:alnum:]_]+' "${testfiles[@]}" | sed -E 's/^func[[:space:]]+//')
7979

80+
local -a gitea_tests
81+
local chunk_size remainder
82+
if [[ "${target}" == *"gitea"* ]]; then
83+
# Filter Gitea tests, excluding Concurrency tests
84+
mapfile -t gitea_tests < <(echo "${all_tests}" | grep -iP '^TestGitea' 2>/dev/null | grep -ivP 'Concurrency' 2>/dev/null | sort 2>/dev/null)
85+
# Remove any non-Gitea entries that might have been captured
86+
local -a filtered_tests
87+
for test in "${gitea_tests[@]}"; do
88+
if [[ "${test}" =~ ^TestGitea ]] && [[ ! "${test}" =~ Concurrency ]]; then
89+
filtered_tests+=("${test}")
90+
fi
91+
done
92+
gitea_tests=("${filtered_tests[@]}")
93+
chunk_size=$((${#gitea_tests[@]} / 3))
94+
remainder=$((${#gitea_tests[@]} % 3))
95+
fi
96+
8097
case "${target}" in
8198
concurrency)
8299
printf '%s\n' "${all_tests}" | grep -iP 'Concurrency'
@@ -91,13 +108,20 @@ get_tests() {
91108
printf '%s\n' "${all_tests}" | grep -iP 'Gitlab|Bitbucket' | grep -ivP 'Concurrency'
92109
;;
93110
gitea_1)
94-
printf '%s\n' "${all_tests}" | grep -iP 'Gitea[A-G]' | grep -ivP 'Concurrency'
111+
if [[ ${#gitea_tests[@]} -gt 0 ]]; then
112+
printf '%s\n' "${gitea_tests[@]:0:${chunk_size}}"
113+
fi
95114
;;
96115
gitea_2)
97-
printf '%s\n' "${all_tests}" | grep -iP 'Gitea[H-P]' | grep -ivP 'Concurrency'
116+
if [[ ${#gitea_tests[@]} -gt 0 ]]; then
117+
printf '%s\n' "${gitea_tests[@]:${chunk_size}:${chunk_size}}"
118+
fi
98119
;;
99120
gitea_3)
100-
printf '%s\n' "${all_tests}" | grep -iP 'Gitea[Q-Z]' | grep -ivP 'Concurrency'
121+
if [[ ${#gitea_tests[@]} -gt 0 ]]; then
122+
local start_idx=$((chunk_size * 2))
123+
printf '%s\n' "${gitea_tests[@]:${start_idx}:$((chunk_size + remainder))}"
124+
fi
101125
;;
102126
gitea_others)
103127
# Deprecated: Use gitea_1, gitea_2, gitea_3 instead

pkg/provider/github/github.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ func (v *Provider) SetClient(ctx context.Context, run *params.Run, event *info.E
324324
return nil
325325
}
326326

327-
// GetTektonDir Get all yaml files in tekton directory return as a single concated file.
327+
// GetTektonDir retrieves all YAML files from the .tekton directory and returns them as a single concatenated multi-document YAML file.
328328
func (v *Provider) GetTektonDir(ctx context.Context, runevent *info.Event, path, provenance string) (string, error) {
329329
tektonDirSha := ""
330330

0 commit comments

Comments
 (0)