summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2024-04-15 13:31:34 +0000
committerMaxim Kuvyrkov <maxim.kuvyrkov@linaro.org>2024-04-16 15:11:51 +0000
commit959772c5047d3e1e0dacbac091ed44ce8a8ea443 (patch)
tree4f8854033391b4fc406275263602a9a02c118de5
parent43f41511c1fef74a1a86e0c3bce93d9ea9996d49 (diff)
tcwg-update-lnt-results.sh: Detect inconsistent history and skip update
Change-Id: Ie1aecdb1fdbe7588a2619e301aa97dc25a5040b4
-rw-r--r--jenkins-helpers.sh22
-rwxr-xr-xtcwg-update-lnt-results.sh56
2 files changed, 58 insertions, 20 deletions
diff --git a/jenkins-helpers.sh b/jenkins-helpers.sh
index d9587ec7..3e5ad7cd 100644
--- a/jenkins-helpers.sh
+++ b/jenkins-helpers.sh
@@ -1279,8 +1279,10 @@ breakup_changed_components ()
# As a special case "0" will fetch you all revisions in "positive" order,
# and "-0" will fetch you all revisions in "negative" order.
# $2 -- git repo
-# $3 -- paths in git repo; can be files or directories, only the 1st path existing
-# in a revision is fetched (useful for renamed/moved files)
+# $3+ -- paths in git repo; can be files or directories, only the 1st path
+# existing in a revision is fetched (useful for renamed/moved files).
+# $4+ -- [optional after "--" separator] paths in git repo, which should be
+# fetched in addition to the "main" path specified in "$3".
#
# This function fetches files into a temporary directory (pointed to by the first
# line of output) and prints out paths under that temporary directory for subsequent
@@ -1295,7 +1297,18 @@ get_git_history ()
local n_revs="$1"
local repo="$2"
shift 2
- local -a paths=("$@")
+
+ local -a paths=()
+ while [ $# != 0 ]; do
+ if [ "$1" = "--" ]; then
+ shift
+ break
+ fi
+ paths+=("$1")
+ shift
+ done
+
+ local -a extra_paths=("$@")
local repo_branch
repo_branch=$(echo "$repo" | cut -s -d# -f2)
@@ -1341,7 +1354,8 @@ get_git_history ()
found=false
for path in "${paths[@]}"; do
- "${git_archive[@]}" "$rev" -- "$path" | tar -x -C "$tmp_dir" &
+ "${git_archive[@]}" "$rev" -- "$path" "${extra_paths[@]}" \
+ | tar -x -C "$tmp_dir" &
# "git archive" fails when $path was deleted in $rev.
if wait $!; then
found=true
diff --git a/tcwg-update-lnt-results.sh b/tcwg-update-lnt-results.sh
index 483b0187..6acdb5fb 100755
--- a/tcwg-update-lnt-results.sh
+++ b/tcwg-update-lnt-results.sh
@@ -51,29 +51,53 @@ update_one_lnt_results_project()
# push each one on LNT server
readarray -t lnt_reports < \
<(get_git_history -0 "$gitbaseurl/$project/$config#$branch" \
- notify/lnt_report.json)
+ notify/lnt_report.json -- manifest.sh)
# get_git_history always returns a first line with the created tmpdir, and each
# extracted files. lnt_reports[0] is the tmpdir created, and should be cleaned afterwards.
tmpdirs+=("${lnt_reports[0]}")
- for json in "${lnt_reports[@]:1}"; do
- jq -f $scripts/tcwg-lnt/$lnt_config/$lnt_model.jq $json > $json.tmp
- mv $json.tmp $json
- done
-
- if [ ${#lnt_reports[@]} -gt 1 ]; then
- echo "Deleting previous reports"
- lnt updatedb --testsuite "$project" "$lntdb" --delete-machine "$config"
- echo "Pushing ${lnt_reports[*]:1}"
- # FIXME: ${lnt_reports[@]} can have hundreds of entries, which all
- # will be expanded on the command line. Consider importing data in
- # chunks or by specifying a top-level directory.
- lnt import --testsuite "$project" $lntdb "${lnt_reports[@]:1}"
- echo "Done!"
- else
+ if [ ${#lnt_reports[@]} -le 1 ]; then
echo "No lnt_report to push"
+ return 0
fi
+
+ # Check if history has inconsistent rr[major].rr[minor] versions -- aka
+ # whether we are in the middle of rewriting history. If "yes", then
+ # skip updating the dashboard to avoid inconsistent results.
+ local manifest
+ manifest="$(dirname "$(dirname "${lnt_reports[1]}")")/manifest.sh"
+ local rr_major1 rr_minor1 i=1 rr_major2 rr_minor2
+ rr_major1=$(get_manifest "$manifest" "{rr[major]-0}")
+ rr_minor1=$(get_manifest "$manifest" "{rr[minor]-0}")
+
+ while [ $i != ${#lnt_reports[@]} ]; do
+ json="${lnt_reports[$i]}"
+ manifest="$(dirname "$(dirname "${lnt_reports[$i]}")")/manifest.sh"
+
+ rr_major2=$(get_manifest "$manifest" "{rr[major]-0}")
+ rr_minor2=$(get_manifest "$manifest" "{rr[minor]-0}")
+ if [ "$rr_major1" != "$rr_major2" ] \
+ || [ "$rr_minor1" != "$rr_minor2" ]; then
+ echo "History re-write is in progress, not updating dashboard"
+ return 0
+ fi
+
+ jq -f $scripts/tcwg-lnt/$lnt_config/$lnt_model.jq $json > $json.tmp
+ mv $json.tmp $json
+
+ i=$((i + 1))
+ done
+
+ echo "Deleting previous reports"
+ lnt updatedb --testsuite "$project" "$lntdb" --delete-machine "$config"
+ echo "Pushing ${lnt_reports[*]:1}"
+ # FIXME: ${lnt_reports[@]} can have hundreds of entries, which all
+ # will be expanded on the command line. Consider importing data in
+ # chunks or by specifying a top-level directory.
+ lnt import --testsuite "$project" $lntdb "${lnt_reports[@]:1}"
+ echo "Done!"
+
rm -rf "${lnt_reports[0]}"
}