Browse Source

Add Sonar analysis to CI and push coverage to it

Serdar Kalaycı 4 years ago
parent
commit
dff4d27469
2 changed files with 29 additions and 5 deletions
  1. 5 5
      .github/workflows/ci.yml
  2. 24 0
      sonar-project.properties

+ 5 - 5
.github/workflows/ci.yml

@@ -175,11 +175,11 @@ jobs:
           export KUBEBUILDER_ATTACH_CONTROL_PLANE_OUTPUT=true
           make test
 
-      - name: Publish Unit Test Coverage
-        uses: codecov/codecov-action@v2.0.3
-        with:
-          flags: unittests
-          file: ./cover.out
+      - name: SonarCloud Scan
+        uses: SonarSource/sonarcloud-github-action@master
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
+          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
 
 
   publish-artifacts:

+ 24 - 0
sonar-project.properties

@@ -0,0 +1,24 @@
+sonar.projectKey=external-secrets_external-secrets
+sonar.organization=external-secrets
+
+# This is the name and version displayed in the SonarCloud UI.
+#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.sources=./apis
+sonar.exclusions=**/*_test.go,**/vendor/**
+ 
+sonar.tests=./apis
+sonar.test.inclusions=**/*_test.go
+sonar.test.exclusions=**/vendor/**
+sonar.go.coverage.reportPaths=./cover.out
+# =====================================================
+#   Meta-data for the project
+# =====================================================
+
+sonar.links.homepage=https://github.com/external-secrets/external-secrets/