From 3643041b2b833e14dd3593b33935ec2d2bb7135b Mon Sep 17 00:00:00 2001 From: petruki <31597636+petruki@users.noreply.github.com> Date: Sun, 10 Mar 2024 17:52:51 -0700 Subject: [PATCH] Added Sonar analysis to CI --- .github/workflows/master.yml | 11 ++++++++--- .gitignore | 1 + sonar-project.properties | 13 +++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 sonar-project.properties diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index adb27ea..c2119bb 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -7,7 +7,6 @@ on: branches: [ "master" ] jobs: - build-test: name: Build & Test runs-on: ubuntu-latest @@ -32,8 +31,14 @@ jobs: run: go build -v ./... - name: Test - run: go test -v ./... + run: go test -v ./... -coverprofile="coverage.out" env: GO_ENV: test MONGODB_URI: mongodb://127.0.0.1:27017 - MONGO_DB: switcher-gitops-test \ No newline at end of file + MONGO_DB: switcher-gitops-test + + - name: SonarCloud Scan + uses: sonarsource/sonarcloud-github-action@v2.0.2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index dd769f0..21c3030 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +coverage.out .idea .bin .data diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..81b7a6c --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,13 @@ +sonar.projectKey=switcherapi_switcher-gitops +sonar.projectName=switcher-gitops +sonar.organization=switcherapi +sonar.projectVersion=1.0.0 +sonar.links.homepage=https://github.com/switcherapi/switcher-gitops + +sonar.sources=src +sonar.exclusions=**/*_test.go +sonar.tests=src +sonar.test.inclusions=**/*_test.go + +sonar.language=go +sonar.go.coverage.reportPaths=coverage.out \ No newline at end of file