diff options
author | Laurent Alfonsi <laurent.alfonsi@linaro.org> | 2022-08-18 10:48:05 +0200 |
---|---|---|
committer | Laurent Alfonsi <laurent.alfonsi@linaro.org> | 2022-08-25 12:43:20 +0200 |
commit | 2104b9f5211abda5945306ed63fbc1943b3202e3 (patch) | |
tree | 6386c9a73570c4312cbfc21cab80a5edab2457cf /tcwg-report-stale-rr-jobs.sh | |
parent | 25d12c548c2113c67af338aace9f19e8c559c525 (diff) |
tcwg-report-stale-rr-jobs.sh: use manifest to detect unupdated branches
Change-Id: I86f1e5fae54106a0113b6714300ccbba98947bfe
Diffstat (limited to 'tcwg-report-stale-rr-jobs.sh')
-rwxr-xr-x | tcwg-report-stale-rr-jobs.sh | 150 |
1 files changed, 106 insertions, 44 deletions
diff --git a/tcwg-report-stale-rr-jobs.sh b/tcwg-report-stale-rr-jobs.sh index 06ce4536..1dd7560b 100755 --- a/tcwg-report-stale-rr-jobs.sh +++ b/tcwg-report-stale-rr-jobs.sh @@ -19,22 +19,38 @@ only="${only-false}" keep_tmp="${keep_tmp-false}" tmpdir="${tmpdir-""}" -if [ x"${repos[*]}" = x"default" ]; then - repos=(base-artifacts binutils-gdb gcc glibc linux llvm-project newlib qemu) -fi +process_manifest () +{ + components=$* + iterate_again=false + + declare -A rr + manifest=base-artifacts/manifest.sh + [ -f base-artifacts/jenkins/manifest.sh ] && manifest=base-artifacts/jenkins/manifest.sh + # shellcheck disable=SC1090 + source $manifest + + for c in $components; do + if [ ! -v rr[debug_${c}_date] ]; then + iterate_again=true + else + commit_stamps[$c]=$(eval echo "\${rr[debug_${c}_date]}") + fi + done + unset rr +} + -process_git_url () +process_all_artifacts () { ( set -euf -o pipefail - local refs_url="$1" + local baseartifacts_url="$refs_url_prefix/base-artifacts" local days_for_master days_for_release days_limit # Initialize base-artifacts repo (by cloning its "empty" branch). - refs_repo=$(basename "$refs_url" .git) - clone_or_update_repo_no_checkout "$refs_repo" "$refs_url" auto empty origin \ - >/dev/null 2>&1 - git -C "$refs_repo" reset --hard >/dev/null 2>&1 + clone_or_update_repo "base-artifacts" empty "$baseartifacts_url.git" >/dev/null 2>&1 + git -C "base-artifacts" reset --hard >/dev/null 2>&1 days_for_master="$days" days_for_release="$((days+days))" @@ -42,23 +58,58 @@ process_git_url () # Walk through all commits of all tcwg_bmk* branches and mark results # referenced in those results with "used_by" file. while IFS= read -r ref; do + + if [ $only != false ] && [[ ! $ref =~ $only ]]; then + continue + fi + dst_ref="refs/remotes/origin/${ref#refs/heads/}" - git -C "$refs_repo" fetch -q origin "+$ref:$dst_ref" >/dev/null 2>&1 - commit_stamp=$(git -C "$refs_repo" show --no-patch --pretty=%ct "$dst_ref") - days_ago=$((($(date +%s) - $commit_stamp) / (24 * 3600))) - if [[ $ref =~ -release- ]]; then - days_limit=$days_for_release - else - days_limit=$days_for_master - fi - if [ "$days_ago" -gt "$days_limit" ]; then - if $human; then - echo "$refs_repo: ${ref#$refs_prefix}: last updated $days_ago days ago" - else - echo "$refs_repo:$ref" - fi + git -C "base-artifacts" fetch -q origin "+$ref:$dst_ref" >/dev/null 2>&1 + git -C "base-artifacts" checkout FETCH_HEAD >/dev/null 2>&1 + + # -- get components for this project + components="" + if [ ! -d "base-artifacts"/git ]; then + # For old style artifacts, we consider, they have not been updated since + # git directory has been created in base-artifacts. i.e. + # 100fd17 round-robin.sh: Fix "git rev-parse" of short histories + commit_stamp=1660557250 + days_ago=$((($(date +%s) - $commit_stamp) / (24 * 3600))) + echo "all: ${ref#$refs_prefix}: No successful run since $days_ago days" + continue; fi - done < <(git ls-remote "$refs_url" "${refs_prefix}*" | awk '{ print $2 }') + while read -e c; do + c=${c#base-artifacts/git/} + c=${c%_rev} + components="$components $c" + done < <(find base-artifacts/git -name '*_rev') + + # -- get all component commit stamps + declare -A commit_stamps + iterate_again=true + while $iterate_again ; do + process_manifest $components + if $iterate_again; then + ( git -C "base-artifacts" checkout HEAD~1 >/dev/null 2>&1 ) || iterate_again=false + fi + done + + # -- dump the messages + days_limit=$days_for_master + [[ $ref =~ -release- ]] && days_limit=$days_for_release + + for c in $components; do + if [[ -v commit_stamps[$c] ]]; then + days_ago=$((($(date +%s) - ${commit_stamps[$c]}) / (24 * 3600))) + if [ "$days_ago" -gt "$days_limit" ]; then + echo "$c: ${ref#$refs_prefix}: last updated $days_ago days ago" + fi + else + echo "$c: ${ref#$refs_prefix}: no date for this component" + fi + done + + done < <(git ls-remote "$baseartifacts_url" "${refs_prefix}*" | awk '{ print $2 }') ) } @@ -84,8 +135,8 @@ classify_get_project() ['run_nb']="" ['run_date']="" ['run_status']="" ['run_title']="" ['run_check_regression']="" # ['last_run']="" ['diag']="" ) - - test['last_updated']=$(echo $1 | sed -e 's|.*: last updated ||') + + test['last_updated']=$(echo $1 | sed -e 's|.*: last updated ||' -e 's|.*: No successful run since ||') test['gitproject']=$(echo $1 |cut -d: -f 1) test['branch']=$(echo $1 |cut -d: -f 2) test['branch']=${test['branch']:1} @@ -167,7 +218,7 @@ classify () local expression="$3" local diag_error="$4" - # Only if not already classified + # Only if not already classified if [ ! -z "${test['diag']}" ]; then return; fi download_project_file "$filename" @@ -229,7 +280,7 @@ get_artifact_dir () get_run_title_and_status () { run=$1 - + verbose " - get_run_title_and_status() : $run" # Last run download_project_file $run/__toppage__ @@ -256,7 +307,8 @@ get_last_interesting_run () export r # to avoid shellcheck unused warning for r in {1..8}; do get_run_title_and_status ${test['run_nb']} - if [[ "${test['run_title']}" =~ $gitprojectshort ]]; then + if [[ "${test['run_title']}" =~ $gitprojectshort ]] || + [ $gitprojectshort == "all" ]; then test['last_run']=${test['run_nb']} verbose " > ${test['run_nb']}" return @@ -268,7 +320,6 @@ get_last_interesting_run () ################## CLASSIFY FUNCTIONS - classify_polling_error () { if [ ! -z "${test['diag']}" ]; then return; fi @@ -315,23 +366,41 @@ classify_analyse_result_file () while read line do # stage line - pat='^# .*(reset_artifacts|build_abe|build_llvm|benchmark)' + pat='^# .*(reset_artifacts|build_abe|build_llvm|benchmark|linux_n_obj)' if [[ $line =~ $pat ]]; then stage="$(echo $line|sed -e 's|# ||' -e 's| --.*||' -e 's|:.*||')" #echo " $line => $stage" fi - # Error line + # Clear error line pat='^# Benchmarking infra is offline' if [[ $line =~ $pat ]]; then set_diag "ERROR (infra offline)" fi - - # Error line pat='# .* error: patch failed' if [[ $line =~ $pat ]]; then set_diag "ERROR (git patch failed)" fi + pat='# First few build errors in logs' + if [[ $line =~ $pat ]]; then + set_diag "ERROR ($stage build errors)" + fi + pat='^# .*grew in size.*' + if [[ $line =~ $pat ]]; then + set_diag "ERROR (grew in size)" + fi + pat='^# .*slowed down.*' + if [[ $line =~ $pat ]]; then + set_diag "ERROR (slowed down)" + fi + + # single message before reset-artifact + pat='^# FAILED' + if [[ $line =~ $pat ]] && [ ! -v stage ]; then + set_diag "ERROR (FAILED in reset_artifacts)" + fi + + [ ! -z "${test['diag']}" ] && break done < "${test['run_nb']}/artifact/artifacts/results" @@ -396,12 +465,12 @@ print_suggestions () echo " --delete refs/heads/linaro-local/ci/$br \\" done echo "" - done + done echo "rm -rf $tmpdir" fi } -################## MAIN CLASSIFY FUNCTIONS +################## MAIN CLASSIFY FUNCTIONS classify_failures () { local stale_jobs_file @@ -420,8 +489,6 @@ classify_failures () while read -r line; do - # For now, we classify only base-artifacts stale jobs - #[[ "$line" =~ ^base-artifacts: ]] || continue classify_get_project "$line" @@ -474,10 +541,5 @@ if [ $classify != false ]; then exit 0; fi +process_all_artifacts -# Otherwise process the git to find not updated results -for repo in "${repos[@]}"; do - process_git_url "$refs_url_prefix/$repo" & -done | sort - -wait |