Skip to content

Commit

Permalink
DGS-16859: Run SonarQube report in pipeline (#1362)
Browse files Browse the repository at this point in the history
  • Loading branch information
GunalKupta authored Dec 20, 2024
1 parent bb108e5 commit bf51d32
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ tmp-build
.go-version
.vscode/
.trunk/
**/*coverage.txt
19 changes: 19 additions & 0 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ blocks:
- export DYLD_LIBRARY_PATH="$HOME/confluent-kafka-go/tmp-build/lib"
- rm -rf tmp-build
- go install golang.org/x/lint/golint@latest && touch .do_lint
- go get github.com/wadey/gocovmerge && go install github.com/wadey/gocovmerge
jobs:
- name: "Static Build"
env_vars:
Expand Down Expand Up @@ -58,6 +59,7 @@ blocks:
- sudo apt-get install confluent-librdkafka-plugins -y
- rm -rf tmp-build
- go install -v golang.org/x/lint/golint@latest && touch .do_lint
- go get github.com/wadey/gocovmerge && go install github.com/wadey/gocovmerge
jobs:
- name: "Static Build + Integration tests (CGRP classic)"
env_vars:
Expand Down Expand Up @@ -103,6 +105,7 @@ blocks:
#- sudo apt-get install confluent-librdkafka-plugins -y
- rm -rf tmp-build
- go install golang.org/x/lint/golint@latest && touch .do_lint
- go get github.com/wadey/gocovmerge && go install github.com/wadey/gocovmerge
jobs:
- name: "Static Build"
env_vars:
Expand Down Expand Up @@ -138,3 +141,19 @@ blocks:
- name: MSYSTEM
value: UCRT64
commands_file: semaphore_commands.ps1

after_pipeline:
task:
agent:
machine:
type: s1-prod-ubuntu20-04-amd64-1
jobs:
- name: SonarQube
commands:
- checkout
- artifact pull workflow static_coverage.txt
- artifact pull workflow dynamic_coverage.txt
- artifact pull workflow static_integration_coverage.txt
- artifact pull workflow dynamic_integration_coverage.txt
- sem-version java 11
- emit-sonarqube-data --run_only_sonar_scan
8 changes: 6 additions & 2 deletions .semaphore/semaphore_commands.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
set -e
if [ "$EXPECT_LINK_INFO" = "dynamic" ]; then export GO_TAGS="-tags dynamic"; bash mk/bootstrap-librdkafka.sh ${LIBRDKAFKA_VERSION} tmp-build; fi
coverage_profile="static_coverage.txt"
if [ "$EXPECT_LINK_INFO" = "dynamic" ]; then export GO_TAGS="-tags dynamic" && coverage_profile="dynamic_coverage.txt"; bash mk/bootstrap-librdkafka.sh ${LIBRDKAFKA_VERSION} tmp-build; fi
for dir in kafka examples ; do (cd $dir && go install $GO_TAGS ./...) ; done
if [[ -f .do_lint ]]; then golint -set_exit_status ./examples/... ./kafka/... ./kafkatest/... ./soaktest/... ./schemaregistry/...; fi
for dir in kafka schemaregistry ; do (cd $dir && go test -timeout 180s -v $GO_TAGS ./...) ; done
for dir in kafka schemaregistry ; do (cd $dir && go test -coverprofile="$coverage_profile" -timeout 180s -v $GO_TAGS ./...) ; done
go-kafkacat --help
library-version
(library-version | grep "$EXPECT_LINK_INFO") || (echo "Incorrect linkage, expected $EXPECT_LINK_INFO" ; false)

(gocovmerge $(find . -type f -iname "*coverage.txt") > ${coverage_profile}) || (echo "Failed to merge coverage files" && exit 0)
artifact push workflow ${coverage_profile} || true
8 changes: 6 additions & 2 deletions .semaphore/semaphore_integration_commands.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
set -e
if [ "$EXPECT_LINK_INFO" = "dynamic" ]; then export GO_TAGS="-tags dynamic"; bash mk/bootstrap-librdkafka.sh ${LIBRDKAFKA_VERSION} tmp-build; fi
coverage_profile="static_integration_coverage.txt"
if [ "$EXPECT_LINK_INFO" = "dynamic" ]; then export GO_TAGS="-tags dynamic" && coverage_profile="dynamic_integration_coverage.txt"; bash mk/bootstrap-librdkafka.sh ${LIBRDKAFKA_VERSION} tmp-build; fi
for dir in kafka examples ; do (cd $dir && go install $GO_TAGS ./...) ; done
if [[ -f .do_lint ]]; then golint -set_exit_status ./examples/... ./kafka/... ./kafkatest/... ./soaktest/... ./schemaregistry/...; fi
for dir in kafka schemaregistry ; do (cd $dir && go test -timeout 180s -v $GO_TAGS ./...) ; done
for dir in kafka schemaregistry ; do (cd $dir && go test -coverprofile="$coverage_profile" -timeout 180s -v $GO_TAGS ./...) ; done
(cd kafka && go test -v $GO_TAGS -timeout 3600s -run ^TestIntegration$ -docker.needed=true ; cd ..)
go-kafkacat --help
library-version
(library-version | grep "$EXPECT_LINK_INFO") || (echo "Incorrect linkage, expected $EXPECT_LINK_INFO" ; false)

(gocovmerge $(find . -type f -iname "*coverage.txt") > ${coverage_profile}) || (echo "Failed to merge coverage files" && exit 0)
artifact push workflow ${coverage_profile} || true
4 changes: 3 additions & 1 deletion service.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: confluent-kafka-go
lang: go
lang_version: 1.18
lang_version: 1.21
git:
enable: true
github:
Expand All @@ -10,3 +10,5 @@ semaphore:
enable: true
sonarqube:
enable: true
coverage_reports:
- "**/*coverage.txt"
8 changes: 8 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### service-bot sonarqube plugin managed file
sonar.coverage.exclusions=**/test/**/*,**/tests/**/*,**/mock/**/*,**/mocks/**/*,**/*mock*,**/*test*
sonar.cpd.exclusions=**/test/**/*,**/tests/**/*,**/mock/**/*,**/mocks/**/*,**/*mock*,**/*test*
sonar.exclusions=**/*.pb.*,**/mk-include/**/*
sonar.go.coverage.reportPaths=**/*coverage.txt
sonar.language=go
sonar.projectKey=confluent-kafka-go
sonar.sources=.

0 comments on commit bf51d32

Please sign in to comment.