~rcr/rirc

ref: d30a3f0cce8366dcacad8e8924d9ad5f1007a2af rirc/scripts/sa_sonarcloud_run.sh -rwxr-xr-x 1.4 KiB
d30a3f0c — Richard Robbins Merge branch 'dev' into static_analysis 11 months ago
                                                                                
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
#!/bin/bash

set -e

fail() { >&2 printf "%s\n" "$*"; exit 1; }

if [[ -z $1 ]]; then
	fail "Usage: '$0 dir'"
fi

DIR="$1"

SONAR_VERSION="4.5.0.2216"
SONAR_CONFIG="$DIR/sonar-project.properties"

SONAR_SCANNER_BIN="$DIR/sonar-scanner-$SONAR_VERSION-linux/bin/sonar-scanner"
BUILD_WRAPPER_BIN="$DIR/build-wrapper-linux-x86/build-wrapper-linux-x86-64"
BUILD_WRAPPER_OUT="$DIR/bw-out"

if [[ ! -f "$BUILD_WRAPPER_BIN" ]]; then
	fail "missing build-wrapper binary"
fi

if [[ ! -f "$SONAR_SCANNER_BIN" ]]; then
	fail "missing sonar-scanner binary"
fi

cat << EOF >> "$SONAR_CONFIG"
# Server
sonar.host.url = https://sonarcloud.io

# Project
sonar.organization   = rirc
sonar.projectKey     = rirc
sonar.projectName    = rirc
sonar.projectVersion = $(git rev-parse --short HEAD)
sonar.branch.name    = $(git name-rev --name-only HEAD)
sonar.links.homepage = https://rcr.io/rirc/
sonar.links.scm      = https://git.sr.ht/~rcr/rirc/
sonar.links.ci       = https://builds.sr.ht/~rcr/rirc/

# C, Sources
sonar.cfamily.build-wrapper-output = $BUILD_WRAPPER_OUT
sonar.cfamily.cache.enabled        = false
sonar.cfamily.threads              = $(nproc)
sonar.sources                      = src,test

# Output
sonar.working.directory = $DIR/scannerwork
EOF

make clean
make libs

eval "$BUILD_WRAPPER_BIN --out-dir $BUILD_WRAPPER_OUT make all check"
eval "$SONAR_SCANNER_BIN --define project.settings=$SONAR_CONFIG"