Skip to content

Commit 787b11d

Browse files
committed
Updated for sonar-scanner and unit testing
1 parent 9da4eab commit 787b11d

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

build-docker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22

3-
docker build -t golang-demo .
3+
docker build -t golang-demo .

start-sonar.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
export PATH="$PATH:/Users/dhamukrish/Documents/digidhamu/k8s.do.digidhamu.com/tools/sonar-scanner-4.2.0.1873-macosx/bin"
4+
5+
sonar-scanner
6+
7+
echo "Checking if analysis is finished.."
8+
9+
SONAR_PROJECT_KEY=golang-daas-demo
10+
SONAR_STATUS_URL=$(cat .scannerwork/report-task.txt | grep ceTaskUrl | sed -e 's/ceTaskUrl=//')
11+
SONAR_STATUS=$(curl -skg "${SONAR_STATUS_URL}" | sed -e 's/.*status":"//' | sed -e 's/",.*//')
12+
13+
while ! [ "${SONAR_STATUS}" = "SUCCESS" ] || [ "${SONAR_STATUS}" = "CANCELED" ] || [ "${SONAR_STATUS}" = "FAILED" ];
14+
do
15+
echo "Sonar analysis is: ${SONAR_STATUS}. Taking a nap while we wait..."
16+
sleep 5
17+
SONAR_STATUS=$(curl -skg ${SONAR_STATUS_URL} | sed -e 's/.*status":"//' | sed -e 's/",.*//')
18+
done
19+
20+
echo "Sonar Task returned: ${SONAR_STATUS}"
21+
22+
if [ "${SONAR_STATUS}" = "FAILED" ]; then
23+
exit -1
24+
fi
25+
26+
exit 0

start-test.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#!/bin/bash
22

3+
export GOPATH=$HOME/Documents/digidhamu/go
4+
35
go test -coverprofile=coverage.out

0 commit comments

Comments
 (0)