summaryrefslogtreecommitdiff
path: root/tcwg-update-lnt-results.sh
blob: 5ae80b44531c4e0f7a78c8d3341c6a3aee96ffde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash

set -euf -o pipefail

scripts=$(dirname $0)

# shellcheck source=jenkins-helpers.sh
. $scripts/jenkins-helpers.sh

convert_args_to_variables "$@"
shift "$SHIFT_CONVERTED_ARGS"

obligatory_variables lnt_config ci_project ci_config
declare              lnt_config ci_project ci_config

verbose="${verbose-false}"
if $verbose; then set -x; fi

gitbaseurl="ssh://bkp.tcwglab/home/tcwg-buildslave/base-artifacts/"
lntserver="${lntserver-/home/tcwg-buildslave/$lnt_config/lntserver}"
lntdb="$lntserver/lnt-database"

. $lntserver/sandbox/bin/activate

# cleanup tmp result dir in any cases.
declare -g tmpdirs=()
trap 'rm -rf "${tmpdirs[@]}"' EXIT

update_one_lnt_results_project()
{
    local project=$1
    local config=$2

    # Early exit if unsupported
    case "$project" in
        tcwg_binutils*|tcwg_bootstrap*|tcwg_gcc*|tcwg_gdb*|tcwg_glibc*|tcwg_gnu*|\
        tcwg_bmk*)
            # process the lnt update further
            ;;
        *)
            # Do not update anything else so far
            return
            ;;
    esac

    # Update base-artifacts with project/config
    branch="linaro-local/ci/$project/$config"
    clone_or_update_repo "base-artifacts/$project/$config" "$branch" "$gitbaseurl/$project/$config.git" \
      auto "$branch"

    # push each one on LNT server
    readarray -t lnt_reports < <(get_git_history -0 base-artifacts/$project/$config notify/lnt_report.json)

    # 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]}")

    if [ ${#lnt_reports[@]} -gt 1 ]; then
        echo "Pushing ${lnt_reports[*]:1}"
        lnt import --testsuite "$project" $lntdb "${lnt_reports[@]:1}"
    else
        echo "No lnt_report to push"
    fi
    rm -rf "${lnt_reports[0]}"
}

# Update the results either on $ci_project/$ci_config if defined
# Or iterate over all matching $ci_project/$ci_config
if [ x"$ci_project" != x"*" ] && [ x"$ci_config" != x"*" ]; then

    update_one_lnt_results_project $ci_project $ci_config

else

    while read -r project_config; do

        project=${project_config%/*}
        config=${project_config#*/}

        if [ x"$ci_project" != x"*" ] && [ x"$ci_project" != x"$project" ]; then
            continue
        fi
        if [ x"$ci_config"  != x"*" ] && [ x"$ci_config"  != x"$config"  ]; then
            continue
        fi

        update_one_lnt_results_project $project $config || true

    done < <(ssh bkp.tcwglab 'cd /home/tcwg-buildslave/base-artifacts/; find . -type d -name "*.git"' | sed -e 's/.git$//' | cut -d/ -f2-3)

fi

rm -rf "${tmpdirs[@]}"