aboutsummaryrefslogtreecommitdiff
path: root/ci-report
blob: fe6deda534cff43cd241f1cfc5538ddb976a7fe1 (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
#!/bin/bash

# Give the opportunity the caller of the script to specify the directory
# where the repository is located, otherwise default to the current
# directory
REPOPATH=${1:-$PWD}

# Move into the repo
cd $REPOPATH

# kernelci is using abbrev=12 inherited from Jenkins
ABBREV=12

# Get the git description conforming to kernelci
GIT_DESCR=$(git describe --abbrev=$ABBREV)
# Build the url
DEFAULT_KERNEL_CI_BASE_URL=https://storage.kernelci.org/pmwg/integ
KERNELCI_URL=${KERNEL_CI_BASE_URL:-$DEFAULT_KERNEL_CI_BASE_URL}/$GIT_DESCR/build-logs-summary.txt

BLAME_SCRIPT=ci-blame

ci_report() {

    URL=$KERNELCI_URL

    git tag | grep -q report-$GIT_DESCR && return 1

    ERRORS="$(curl -s -f $URL)"
    if [ $? -ne 0 ]; then
	return 1
    fi

    RET=0
    echo "$ERRORS" | while read -r ERROR; do

	# ignore commented lines
	echo $ERROR | egrep -q '(^#|^\s*$|^\s*\t*#)' && continue

	FILE=$(echo $ERROR | awk '{ print $2 }' | awk -F ':' '{print $1}')
	LINE=$(echo $ERROR | awk '{ print $2 }' | awk -F ':' '{print $2}')

	# Do not display anything, so if there is no warning/error belonging
	# to one of *our* branch, then we end up with nothing on the input, so
	# nothing on the email report => everything ok.
	$BLAME_SCRIPT $FILE $LINE "$ERROR"
	RET=$(( RET + $? ))
    done

    # Add a tag to the tree, so we know that the branch can't be tested
    if [ $RET -ne 0]; then
	git tag blame-$GIT_DESCR
    fi

    # Add a tag to the tree, so we know the report was already done.
    git tag report-$GIT_DESCR

    return $RET
}

ci_report