Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/maven/spring-cloud-kubernetes-dep…
Browse files Browse the repository at this point in the history
…endencies/com.github.tomakehurst-wiremock-jre8-standalone-2.35.1
  • Loading branch information
Ryan Baxter authored Mar 13, 2024
2 parents 55e0043 + 0f02596 commit 5732b0c
Show file tree
Hide file tree
Showing 648 changed files with 15,392 additions and 14,760 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ runs:
steps:
- name: build controllers project
shell: bash
env:
CURRENT_INDEX: ${{ matrix.current_index }}
run: |
cd spring-cloud-kubernetes-controllers
.././mvnw -T 1C -U clean install
.././mvnw -DCURRENT_INSTANCE=${CURRENT_INDEX} -T 1C -U clean install
cd ..
4 changes: 0 additions & 4 deletions .github/workflows/composites/clean-space/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ description: clean space
runs:
using: "composite"
steps:
- name: apt-update
shell: bash
run: |
sudo apt-get update

- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,56 @@ runs:

steps:

- name: restore test times cache
uses: actions/cache/restore@v3
with:
path: /tmp/sorted.txt
key: ${{ runner.os }}-spring-cloud-k8s-existing-test-times-cache-${{ github.run_id }}
restore-keys: ${{ runner.os }}-spring-cloud-k8s-existing-test-times-cache-

- name: show cached test times
shell: bash
run: cat /tmp/sorted.txt

- name: compute matrix steps
shell: bash
run: |
sum_of_all_tests=$(awk -F' ' '{sum+=$2;} END{print sum;}' /tmp/sorted.txt)
PLAIN_TEST_CLASSNAMES=($(cat /tmp/tests.txt | grep -o 'spring.cloud.k8s.test.to.run -> org.*' | awk '{print $3}'))
#######################################################################################################
### split into tests that we know the running times for and in tests that we do not know the times for.
#######################################################################################################
for test in "${PLAIN_TEST_CLASSNAMES[@]}"; do
find_test_in_sorted=$(grep "$test " /tmp/sorted.txt || true)
if [[ -z "$find_test_in_sorted" ]]; then
echo $test >> /tmp/tests-without-times.txt
else
echo $find_test_in_sorted >> /tmp/tests-with-times.txt
fi
done
sort -t' ' -nk2 /tmp/tests-with-times.txt >> /tmp/tests-with-times-sorted.txt
# this is a work-around for the fact that 'actions/download-artifact@v3' does not support
# something like: 'ignore if downloaded file is missing'.
# so unless we create a dummy file for upload, download will fail
if [[ ! -f /tmp/tests-without-times.txt ]]; then touch /tmp/tests-without-times.txt; fi
echo '--------------------------------------------------------------'
cat /tmp/tests-with-times-sorted.txt
echo '--------------------------------------------------------------'
cat /tmp/tests-without-times.txt
echo '--------------------------------------------------------------'
sum_of_all_tests=$(awk -F' ' '{sum+=$2;} END{print sum;}' /tmp/tests-with-times-sorted.txt)
sum_of_all_tests_as_int=$(printf "%.0f\n" "$sum_of_all_tests")
echo "sum of all tests : $sum_of_all_tests_as_int"
max_test_time=$(tail -1 /tmp/sorted.txt | awk '{print $2}')
max_test_time=$(tail -1 /tmp/tests-with-times-sorted.txt | awk '{print $2}')
max_test_time_as_int=$(printf "%.0f\n" "$max_test_time")
echo "max test time : $max_test_time_as_int"
Expand All @@ -38,7 +79,10 @@ runs:
number_of_instances_as_array+=']'
average_time_per_instance=$(( sum_of_all_tests_as_int / $number_of_instances ))
echo "average time per instance $average_time_per_instance"
average_time_per_instance_array=()
average_time_per_instance_array+='['
average_time_per_instance_array+=$average_time_per_instance
average_time_per_instance_array+=']'
matrix_array=()
matrix_array+='['
Expand All @@ -52,8 +96,9 @@ runs:
matrix_array+=']'
echo "********************************************************************************************************"
echo "number of instances : $number_of_instances_as_array"
echo "average time per instance : $average_time_per_instance"
echo "average_time_per_instance_as_array: $average_time_per_instance_as_array"
echo "matrix_array : $matrix_array"
echo "********************************************************************************************************"
Expand All @@ -62,10 +107,23 @@ runs:
matrix_array_json=$(jq -r -c . <<< $matrix_array)
echo "matrix_array_json : $matrix_array_json"
average_time_per_instance_json=$(jq -r -c . <<< $average_time_per_instance_array)
echo "average_time_per_instance_json : $average_time_per_instance_json"
echo "TEST_TIMES_CACHE_PRESENT=true" >> $GITHUB_ENV
echo "NUMBER_OF_MATRIX_INSTANCES=$(echo $number_of_instances_json)" >> $GITHUB_ENV
echo "MATRIX_ARRAY=$(echo $matrix_array_json)" >> $GITHUB_ENV
echo "AVERAGE_TIME_PER_INSTANCE=$(echo $average_time_per_instance)" >> $GITHUB_ENV
echo "AVERAGE_TIME_PER_INSTANCE=$(echo $average_time_per_instance_json)" >> $GITHUB_ENV
- name: upload test with times
uses: actions/upload-artifact@v3
with:
name: tests-with-times-sorted.txt
path: /tmp/tests-with-times-sorted.txt

- name: upload test without times
uses: actions/upload-artifact@v3
with:
name: tests-without-times.txt
path: /tmp/tests-without-times.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ runs:
using: "composite"
steps:

- name: run 'package' on the project
- name: run 'install' on the project
shell: bash
run: |
./mvnw install -B \
-Dskip.build.image=true \
-DskipTests -DskipITs \
-T 1C -q
-T 1C -U -q
- name: find all classpath entries
shell: bash
Expand All @@ -21,7 +21,7 @@ runs:
shell: bash
run: |
cd spring-cloud-kubernetes-test-support
.././mvnw -q exec:java -Dexec.mainClass="org.springframework.cloud.kubernetes.tests.discovery.TestsDiscovery" > /tmp/tests.txt
.././mvnw -q exec:java -Prun-on-github-actions -Dexec.mainClass="org.springframework.cloud.kubernetes.tests.discovery.TestsDiscovery" > /tmp/tests.txt
cd ..
- name: show result
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/composites/pre-test-actions/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ runs:
- name: cache local maven repository
uses: ./.github/workflows/composites/cache

- name: build project
shell: bash
run: |
./mvnw clean install -Dskip.build.image=true -DskipITs -DskipTests -T1C -U -B -q
- name: build controllers project
uses: ./.github/workflows/composites/build-controllers-project

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ runs:
./mvnw -s .settings.xml \
-DtestsToRun=${TEST_ARG[@]} \
-DCURRENT_INSTANCE=${CURRENT_INDEX} \
-e clean install \
-U -P sonar -nsu --batch-mode \
-P sonar -nsu --batch-mode \
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
-Dhttp.keepAlive=false \
-Dmaven.wagon.http.pool=false \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,30 @@ runs:
using: "composite"

steps:
- name: restore test times cache
uses: actions/cache/restore@v3

- name: download tests with times
if: env.BASE_BRANCH != '2.1.x'
uses: actions/download-artifact@v3
with:
path: /tmp/sorted.txt
key: ${{ runner.os }}-spring-cloud-k8s-existing-test-times-cache-${{ github.run_id }}
restore-keys: ${{ runner.os }}-spring-cloud-k8s-existing-test-times-cache-
name: tests-with-times-sorted.txt
path: /tmp/

- name: show cached test times
shell: bash
run: cat /tmp/sorted.txt
- name: download tests without times
if: env.BASE_BRANCH != '2.1.x'
uses: actions/download-artifact@v3
with:
name: tests-without-times.txt
path: /tmp/

- name: split tests into known times and un-known times
shell: bash
run: |
############################################################################################################
############################################################################################################
############################################################################################################
# 1. Get all existing tests and place them in PLAIN_TEST_CLASSNAMES
# 2. Get all test times from the existing cache : /tmp/sorted.txt
# 3. Split tests from PLAIN_TEST_CLASSNAMES into two files depending if we already know their running times
# or not : tests-without-times.txt and tests-with-times.txt
############################################################################################################
############################################################################################################
############################################################################################################
PLAIN_TEST_CLASSNAMES=($(cat /tmp/tests.txt | grep -o 'spring.cloud.k8s.test.to.run -> org.*' | awk '{print $3}'))
echo "${PLAIN_TEST_CLASSNAMES[@]}"
temp_dir=$(mktemp -d)
for test in "${PLAIN_TEST_CLASSNAMES[@]}"; do
find_test_in_sorted=$(grep "$test " /tmp/sorted.txt || true)
if [[ -z "$find_test_in_sorted" ]]; then
echo $test >> $temp_dir/tests-without-times.txt
else
echo $find_test_in_sorted >> $temp_dir/tests-with-times.txt
fi
done

echo "tests with times:"
cat $temp_dir/tests-with-times.txt

sort -t' ' -nk2 $temp_dir/tests-with-times.txt >> $temp_dir/tests-with-times-sorted.txt
echo "------------------------------------------------------------------------------"
cat /tmp/tests-with-times-sorted.txt
echo "------------------------------------------------------------------------------"
if [[ -f /tmp/tests-without-times.txt ]]; then cat /tmp/tests-without-times.txt; fi
echo "------------------------------------------------------------------------------"
############################################################################################################
############################################################################################################
Expand All @@ -70,7 +47,7 @@ runs:
# this test needs to be taken in 'tests_to_take_in_current_iteration', thus:
# tests_to_take_in_current_iteration=testC; also next_sum becomes 3sec
# we then drop this line from /tmp/sorted.txt because we have already processed it
# ('sed -i "" "${j}d" $temp_dir/tests-with-times-sorted.txt')
# ('sed -i "" "${j}d" /tmp/tests-with-times-sorted.txt')
# we also decrement j, since we removed one line from the file
# we then take testB, add its time to next_sum, thus next_sum = 5 sec, but now the time is NOT < 3.1 sec
Expand All @@ -81,22 +58,14 @@ runs:
# we repeat the process again and now tests_to_take_in_current_iteration=testB,testA because their cumulative
# sum will be 3 sec and it's < 3.1 sec.

sum_of_all_tests=$(awk -F' ' '{sum+=$2;} END{print sum;}' $temp_dir/tests-with-times-sorted.txt)
sum_of_all_tests_as_int=$(printf "%.0f\n" "$sum_of_all_tests")
echo "sum of all tests : $sum_of_all_tests_as_int"

max_test_time=$(tail -1 $temp_dir/tests-with-times-sorted.txt | awk '{print $2}')
max_test_time_as_int=$(printf "%.0f\n" "$max_test_time")
echo "max test time : $max_test_time_as_int"
number_of_instances=${NUMBER_OF_JOBS}
echo "number of instances $number_of_instances"

average_time_per_instance=$(( sum_of_all_tests_as_int / number_of_instances ))
average_time_per_instance=${AVERAGE_TIME_PER_INSTANCE}
echo "average time per instance $average_time_per_instance"

number_of_lines_in_file=$(grep -c ^ $temp_dir/tests-with-times-sorted.txt)
number_of_lines_in_file=$(grep -c ^ /tmp/tests-with-times-sorted.txt)
echo "number of lines in fine : $number_of_lines_in_file"
tests_to_run_in_current_index=''

Expand All @@ -106,7 +75,7 @@ runs:
tests_to_take_in_current_iteration=''
for ((j=$number_of_lines_in_file; j>0; j--)) ; do

current_line_in_file=$(awk "NR == ${j}" $temp_dir/tests-with-times-sorted.txt)
current_line_in_file=$(awk "NR == ${j}" /tmp/tests-with-times-sorted.txt)
current_test_time=$(echo $current_line_in_file | awk '{print $2}')
current_test_time=$(printf "%.0f\n" "$current_test_time")
current_test_name=$(echo $current_line_in_file | awk '{print $1}')
Expand All @@ -122,7 +91,7 @@ runs:
tests_to_take_in_current_iteration="$tests_to_take_in_current_iteration,$current_test_name"
fi

sed -i "${j}d" $temp_dir/tests-with-times-sorted.txt
sed -i "${j}d" /tmp/tests-with-times-sorted.txt
number_of_lines_in_file=$(( $number_of_lines_in_file-1 ))
continue
fi
Expand Down Expand Up @@ -154,7 +123,7 @@ runs:
if [[ ${CURRENT_INDEX} = ${NUMBER_OF_JOBS} ]]; then
echo "last index spotted"

if [ ! -f $temp_dir/tests-without-times.txt ]; then
if [ ! -f /tmp/tests-without-times.txt ]; then
echo "no tests outside cache found"

if [ -z "$tests_to_run_in_current_index" ]; then
Expand All @@ -163,7 +132,7 @@ runs:
fi

else
TESTS_WITHOUT_TIMES=($(cat $temp_dir/tests-without-times.txt))
TESTS_WITHOUT_TIMES=($(cat /tmp/tests-without-times.txt))

for test in "${TESTS_WITHOUT_TIMES[@]}"; do
if [[ -z "$tests_to_run_in_current_index" ]]; then
Expand All @@ -180,8 +149,10 @@ runs:

./mvnw -s .settings.xml \
-DtestsToRun=${tests_to_run_in_current_index} \
-Dsurefire-reports-directory=surefire-reports/${CURRENT_INDEX} \
-Dfailsafe-reports-directory=failsafe-reports/${CURRENT_INDEX} \
-e clean install \
-U -P sonar -nsu --batch-mode \
-P sonar -nsu --batch-mode \
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
-Dhttp.keepAlive=false \
-Dmaven.wagon.http.pool=false \
Expand All @@ -199,7 +170,7 @@ runs:
for i in "${sliced_array[@]}"; do

# can be present in the last index as 'none,testA,testB'
if [[ "$i" -eq "none" ]]; then
if [[ "$i" == "none" ]]; then
echo "skipping 'none'"
else
filename="${i}.txt"
Expand Down
15 changes: 0 additions & 15 deletions .github/workflows/composites/save-controller-images/action.yaml

This file was deleted.

This file was deleted.

Loading

0 comments on commit 5732b0c

Please sign in to comment.