| | #!/usr/bin/env bash |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | |
| |
|
| | |
| | function ci_list_functions() { |
| | declare -F | awk '{print $NF}' | sort | egrep '^ci_' | sed 's/^ci_//' |
| | } |
| |
|
| | |
| | |
| | function ci_print_thread_dumps() { |
| | for java_pid in $(jps -q -J-XX:+PerfDisableSharedMem); do |
| | echo "----------------------- pid $java_pid -----------------------" |
| | cat /proc/$java_pid/cmdline | xargs -0 echo |
| | jcmd $java_pid Thread.print -l |
| | jcmd $java_pid GC.heap_info |
| | done |
| | return 0 |
| | } |
| |
|
| | |
| | |
| | function ci_move_test_reports() { |
| | ( |
| | if [ -n "${GITHUB_WORKSPACE}" ]; then |
| | cd "${GITHUB_WORKSPACE}" |
| | mkdir -p test-reports |
| | mkdir -p surefire-reports |
| | fi |
| | |
| | if [ -d test-reports ]; then |
| | |
| | find . -path '*/target/surefire-reports/junitreports/TEST-*.xml' -print0 | xargs -0 -r -n 1 mv -t test-reports --backup=numbered |
| | |
| | ( |
| | for f in test-reports/*~; do |
| | mv -- "$f" "${f}.xml" |
| | done 2>/dev/null |
| | ) || true |
| | fi |
| | |
| | if [ -d surefire-reports ]; then |
| | ( |
| | find . -type d -path '*/target/surefire-reports' -not -path './surefire-reports/*' | |
| | while IFS=$'\n' read -r directory; do |
| | echo "Copying reports from $directory" |
| | target_dir="surefire-reports/${directory}" |
| | if [ -d "$target_dir" ]; then |
| | |
| | ( command ls -vr1d "${target_dir}~"* 2> /dev/null | awk '{print "mv "$0" "substr($0,0,length-1)substr($0,length,1)+1}' | sh ) || true |
| | |
| | mv "$target_dir" "${target_dir}~1" |
| | fi |
| | |
| | cp -R --parents "$directory" surefire-reports |
| | |
| | rm -rf "$directory" |
| | done |
| | ) |
| | fi |
| | ) |
| | } |
| |
|
| | |
| | function ci_find_fast_ubuntu_mirror() { |
| | local ubuntu_release=${1:-"$(lsb_release -c 2>/dev/null | cut -f2 || echo "jammy")"} |
| | local ubuntu_arch=${2:-"$(dpkg --print-architecture 2>/dev/null || echo "amd64")"} |
| | { |
| | |
| | { |
| | |
| | |
| | curl -s http://mirrors.ubuntu.com/mirrors.txt | grep '^http://' | shuf -n 10 |
| | |
| | echo http://azure.archive.ubuntu.com/ubuntu/ |
| | } | xargs -I {} sh -c "ubuntu_release=$ubuntu_release ubuntu_arch=$ubuntu_arch;"'echo "$(curl -m 5 -sI {}dists/${ubuntu_release}/Contents-${ubuntu_arch}.gz|sed s/\\r\$//|grep Last-Modified|awk -F": " "{ print \$2 }" | LANG=C date -f- -u +%s)" "{}"' | sort -rg | awk '{ if (NR==1) TS=$1; if ($1 == TS) print $2 }' |
| | } | xargs -I {} sh -c 'echo `curl -r 0-102400 -m 5 -s -w %{speed_download} -o /dev/null {}ls-lR.gz` {}' \ |
| | |sort -g -r |head -1| awk '{ print $2 }' |
| | } |
| |
|
| | function ci_pick_ubuntu_mirror() { |
| | echo "Choosing fastest up-to-date ubuntu mirror based on download speed..." |
| | UBUNTU_MIRROR=$(ci_find_fast_ubuntu_mirror) |
| | if [ -z "$UBUNTU_MIRROR" ]; then |
| | |
| | UBUNTU_MIRROR="http://archive.ubuntu.com/ubuntu/" |
| | UBUNTU_SECURITY_MIRROR="http://security.ubuntu.com/ubuntu/" |
| | else |
| | UBUNTU_SECURITY_MIRROR="${UBUNTU_MIRROR}" |
| | fi |
| | echo "Picked '$UBUNTU_MIRROR'." |
| | |
| | |
| | export UBUNTU_MIRROR |
| | export UBUNTU_SECURITY_MIRROR |
| | |
| | if [ -n "$GITHUB_ENV" ]; then |
| | echo "UBUNTU_MIRROR=$UBUNTU_MIRROR" >> $GITHUB_ENV |
| | echo "UBUNTU_SECURITY_MIRROR=$UBUNTU_SECURITY_MIRROR" >> $GITHUB_ENV |
| | fi |
| | } |
| |
|
| | if [ -z "$1" ]; then |
| | echo "usage: $0 [ci_tool_function_name]" |
| | echo "Available ci tool functions:" |
| | ci_list_functions |
| | exit 1 |
| | fi |
| | ci_function_name="ci_$1" |
| | shift |
| |
|
| | if [[ "$(LC_ALL=C type -t $ci_function_name)" == "function" ]]; then |
| | eval "$ci_function_name" "$@" |
| | else |
| | echo "Invalid ci tool function" |
| | echo "Available ci tool functions:" |
| | ci_list_functions |
| | exit 1 |
| | fi |