summaryrefslogtreecommitdiff
path: root/ci-autotest.sh
blob: 32aa32025f721588dde4420fb293e9b96b60030c (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
#!/bin/bash


# ci_autotest harness to be reworked.
#
#


# Function to check 
ci_autotest_check_guilty_commit()
{
    (
    set -euf -o pipefail

    local current_stage=$1

    # shellcheck disable=SC2154
    if [ x"${rr[ci_autotest]}" != x"$current_stage" ]; then
	return
    fi

    # get guilty commits
    rm -rf guilty_commits
    scp -r -q \
      bkp-01.tcwglab:/home/tcwg-buildslave/ci_autotest/${rr[ci_project]}/${rr[ci_config]}/guilty_commits \
      guilty_commits

    local -A guilty_commits
    for depfile in $(find guilty_commits -name '*_rev'||true); do
        dep=${depfile#guilty_commits/}
        dep=${dep%_rev}
	guilty_commits[$dep]=$(cat $depfile)
    done

    # check if any guilty commits is included
    for dep in "${!guilty_commits[@]}"; do
        if ! [ -f "${rr[top_artifacts]}/git/${dep}_rev" ]; then
	   echo "CI_AUTOTEST : Cannot check if $dep guilty commit is included. $dep not tracked"
	   continue
        fi

	dep_dir=${dep}
        if [ -f "${rr[top_artifacts]}/git/${dep}_dir" ]; then 
	   dep_dir=$(get_current_git ${dep}_dir)
	fi
        if ! [ -d "$dep_dir" ]; then
	   echo "CI_AUTOTEST : Cannot check if $dep guilty commit is included. Cannot find the sources"
	   continue
	fi

        # check if 
	if git -C "$dep_dir" merge-base --is-ancestor ${guilty_commits[$dep]} HEAD >& /dev/null; then
	   echo "CI_AUTOTEST : Found guilty commit included in [$dep] : ${guilty_commits[$dep]}"
	   # found a regression
	   return 1
	fi
    done

    echo "CI_AUTOTEST : Didn't find any of the guilty commits"
    for dep in "${!guilty_commits[@]}"; do
       echo " - [$dep] : ${guilty_commits[$dep]}"
    done
    return 0
    )
}