Skip to content

Commit c0d661b

Browse files
authoredOct 16, 2024
Check the last 10 commits for upgrade E2E test (#11086)
Signed-off-by: Derek Nola <derek.nola@suse.com>
1 parent 14eee80 commit c0d661b

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed
 

‎tests/e2e/scripts/latest_commit.sh

+15-13
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
#!/bin/bash
2-
# Grabs the last 5 commit SHA's from the given branch, then purges any commits that do not have a passing CI build
2+
3+
branch=$1
4+
output_file=$2
5+
# Grabs the last 10 commit SHA's from the given branch, then purges any commits that do not have a passing CI build
36
iterations=0
4-
curl -s -H 'Accept: application/vnd.github.v3+json' "https://api.github.com/repos/k3s-io/k3s/commits?per_page=5&sha=$1" | jq -r '.[] | .sha' &> $2
5-
# The VMs take time on startup to hit googleapis.com, wait loop until we can
7+
commits_str=$(curl -s -H 'Accept: application/vnd.github.v3+json' "https://api.github.com/repos/k3s-io/k3s/commits?per_page=10&sha=$branch" | jq -j -r '.[] | .sha, " "')
8+
read -a commits <<< "$commits_str"
9+
10+
# The VMs take time on startup to hit aws, wait loop until we can
611
while ! curl -s --fail https://k3s-ci-builds.s3.amazonaws.com > /dev/null; do
712
((iterations++))
813
if [ "$iterations" -ge 30 ]; then
@@ -12,15 +17,12 @@ while ! curl -s --fail https://k3s-ci-builds.s3.amazonaws.com > /dev/null; do
1217
sleep 1
1318
done
1419

15-
iterations=0
16-
curl -s --fail https://k3s-ci-builds.s3.amazonaws.com/k3s-$(head -n 1 $2).sha256sum
17-
while [ $? -ne 0 ]; do
18-
((iterations++))
19-
if [ "$iterations" -ge 6 ]; then
20-
echo "No valid commits found"
21-
exit 1
20+
for commit in "${commits[@]}"; do
21+
if curl -s --fail https://k3s-ci-builds.s3.amazonaws.com/k3s-$commit.sha256sum > /dev/null; then
22+
echo "$commit" > "$output_file"
23+
exit 0
2224
fi
23-
sed -i 1d "$2"
24-
sleep 1
25-
curl -s --fail https://k3s-ci-builds.s3.amazonaws.com/k3s-$(head -n 1 $2).sha256sum
2625
done
26+
27+
echo "Failed to find a valid commit, checked: " "${commits[@]}"
28+
exit 1

0 commit comments

Comments
 (0)