diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bfe8dd2..b9e02d2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,4 +1,4 @@ -name: Quality Gate +name: Quality Gate and SonarCloud analysis env: COVERAGE_THRESH_PCT: 81 @@ -22,6 +22,11 @@ jobs: run: go install github.com/klmitch/overcover@v1.2.1 - name: Run unit test with coverage run: go test --coverprofile cover.out ./pdp ./attributes ./protoconv + - name: SonarCloud scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - name: Check coverage meets threshold run: overcover --coverprofile cover.out ./pdp ./attributes --threshold ${{ env.COVERAGE_THRESH_PCT }} - uses: actions/setup-python@v4 diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..1c1812b --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,15 @@ +# must be unique in a given SonarQube instance +sonar.projectKey=virtru_access-pdp +sonar.organization=virtru + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +# This property is optional if sonar.modules is set. +sonar.sources=attributes,pdp,protoconv +sonar.exclusions=**/*_test.go,**/mock_*.go + +sonar.test.inclusions=**/*_test.go + +sonar.go.coverage.reportPaths=cover.out + +# Encoding of the source code. Default is default system encoding +sonar.sourceEncoding=UTF-8