Skip to content

Commit

Permalink
chore: Add sonarqube configuration for CI (argoproj#3392)
Browse files Browse the repository at this point in the history
  • Loading branch information
jannfis authored Apr 10, 2020
1 parent e1142f9 commit 092072a
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 2 deletions.
61 changes: 60 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ commands:
echo "export GOCACHE=/tmp/go-build-cache" | tee -a $BASH_ENV
echo "export ARGOCD_TEST_VERBOSE=true" | tee -a $BASH_ENV
echo "export ARGOCD_TEST_PARALLELISM=8" | tee -a $BASH_ENV
echo "export ARGOCD_SONAR_VERSION=4.2.0.1873" | tee -a $BASH_ENV
configure_git:
steps:
- run:
Expand Down Expand Up @@ -37,6 +38,12 @@ commands:
root: .
paths:
- vendor
save_coverage_info:
steps:
- persist_to_workspace:
root: .
paths:
- coverage.out
attach_vendor:
steps:
- attach_workspace:
Expand Down Expand Up @@ -142,11 +149,55 @@ jobs:
command: |
ls -l test-results || true
cat test-results/junit.xml || true
- save_coverage_info
- store_test_results:
path: test-results
- store_artifacts:
path: test-results
destination: .

sonarcloud:
working_directory: /go/src/github.com/argoproj/argo-cd
docker:
- image: argoproj/argocd-test-tools:v0.2.0
environment:
NODE_MODULES: /go/src/github.com/argoproj/argo-cd/ui/node_modules
steps:
- prepare_environment
- checkout
- attach_workspace:
at: .
- run:
command: mkdir -p /tmp/cache/scanner
name: Create cache directory if it doesn't exist
- restore_cache:
keys:
- v1-sonarcloud-scanner-4.2.0.1873
- run:
command: |
set -e
VERSION=4.2.0.1873
SONAR_TOKEN=$SONAR_TOKEN
SCANNER_DIRECTORY=/tmp/cache/scanner
export SONAR_USER_HOME=$SCANNER_DIRECTORY/.sonar
OS="linux"
echo $SONAR_USER_HOME
if [[ ! -x "$SCANNER_DIRECTORY/sonar-scanner-$VERSION-$OS/bin/sonar-scanner" ]]; then
curl -Ol https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$VERSION-$OS.zip
unzip -qq -o sonar-scanner-cli-$VERSION-$OS.zip -d $SCANNER_DIRECTORY
fi
chmod +x $SCANNER_DIRECTORY/sonar-scanner-$VERSION-$OS/bin/sonar-scanner
chmod +x $SCANNER_DIRECTORY/sonar-scanner-$VERSION-$OS/jre/bin/java
$SCANNER_DIRECTORY/sonar-scanner-$VERSION-$OS/bin/sonar-scanner
name: SonarCloud
- save_cache:
key: v1-sonarcloud-scanner-4.2.0.1873
paths:
- /tmp/cache/scanner

e2e:
working_directory: /home/circleci/.go_workspace/src/github.com/argoproj/argo-cd
machine:
Expand Down Expand Up @@ -240,6 +291,10 @@ jobs:
- run: ./node_modules/.bin/codecov -p ..
- run: NODE_ENV='production' yarn build
- run: yarn lint

orbs:
sonarcloud: sonarsource/sonarcloud@1.0.1

workflows:
version: 2
workflow:
Expand All @@ -253,7 +308,11 @@ workflows:
- build
- ui:
requires:
- codegen
- build
- sonarcloud:
context: SonarCloud
requires:
- test
- e2e:
requires:
- build
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ site/
cmd/**/debug
debug.test
coverage.out
test-results
test-results
.scannerwork
.scratch
23 changes: 23 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
sonar.projectKey=argoproj_argo-cd
sonar.organization=argoproj

# This is the name and version displayed in the SonarCloud UI.
sonar.projectName=argo-cd
sonar.projectVersion=1.0

# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
sonar.sources=.

# Encoding of the source code. Default is default system encoding
sonar.sourceEncoding=UTF-8

sonar.host.url=https://sonarcloud.io

# Exclude following set of patterns from coverage analysis
sonar.coverage.exclusions=**/*.pb.go,**/*.pb.gw.go,**/mocks/**,**/*.ts*,**/vendor/**,**/openapi_generated.go,**/*_test.go,**/*_generated*,test/**,pkg/client/**,pkg/apiclient/**

# Exlcude following set of patterns from code analysis
sonar.go.exclusions=**/vendor/**,*/*.pb.go,**/*_test.go,**/*.pb.gw.go,**/mocks/**,**/openapi_generated.go,**/*_generated*.go

# Exclude following set of patterns from duplication detection
sonar.cpd.exclusions=**/*.pg.go,**/*.g.cs,**/*.gw.go,**/mocks/*

0 comments on commit 092072a

Please sign in to comment.