2
0
Эх сурвалжийг харах

add code coverage

Signed-off-by: Alex Meijer <ameijer@kubecost.com>
Alex Meijer 2 жил өмнө
parent
commit
dacb18347e

+ 8 - 1
.github/workflows/pr.yaml

@@ -4,7 +4,9 @@ on:
   pull_request:
   pull_request:
     branches:
     branches:
       - develop
       - develop
-
+  push:
+    branches:
+      - develop
 jobs:
 jobs:
   backend:
   backend:
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest
@@ -41,6 +43,11 @@ jobs:
         name: Build
         name: Build
         run: |
         run: |
           just build-local
           just build-local
+      - name: Submit Code Coverage
+        uses: sonarsource/sonarqube-scan-action@master
+        env:
+          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
+          SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
 
 
   frontend:
   frontend:
     runs-on: ubuntu-latest
     runs-on: ubuntu-latest

+ 1 - 1
justfile

@@ -8,7 +8,7 @@ default:
 
 
 # Run unit tests
 # Run unit tests
 test:
 test:
-    {{commonenv}} go test ./...
+    {{commonenv}} go test ./... -coverprofile=coverage.out
 
 
 # Compile a local binary
 # Compile a local binary
 build-local:
 build-local:

+ 3 - 0
sonar-project.properties

@@ -0,0 +1,3 @@
+sonar.projectKey=opencost
+sonar.sources=pkg,test
+sonar.go.coverage.reportPaths=coverage.out