Selaa lähdekoodia

add code coverage

Signed-off-by: Alex Meijer <ameijer@kubecost.com>
Alex Meijer 2 vuotta sitten
vanhempi
sitoutus
dacb18347e
3 muutettua tiedostoa jossa 12 lisäystä ja 2 poistoa
  1. 8 1
      .github/workflows/pr.yaml
  2. 1 1
      justfile
  3. 3 0
      sonar-project.properties

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

@@ -4,7 +4,9 @@ on:
   pull_request:
     branches:
       - develop
-
+  push:
+    branches:
+      - develop
 jobs:
   backend:
     runs-on: ubuntu-latest
@@ -41,6 +43,11 @@ jobs:
         name: Build
         run: |
           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:
     runs-on: ubuntu-latest

+ 1 - 1
justfile

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

+ 3 - 0
sonar-project.properties

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