From d63ae3db031130f6c6b4d9a6694368a5e15acbfe Mon Sep 17 00:00:00 2001 From: Pavan <25031267+Pavan-SAP@users.noreply.github.com> Date: Wed, 6 Sep 2023 18:06:08 +0200 Subject: [PATCH] [Misc] Operator: sonar workflow added Sonar workflow added --- .github/workflows/build.yml | 67 +++++++++++++++++++++++++++++++++++++ .github/workflows/go.yml | 32 ------------------ 2 files changed, 67 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/go.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..c583eb4 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,67 @@ +name: CAP Operator Manager (Build & Unit test) + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: + +env: + CGO_ENABLED: 0 + +permissions: + contents: read + pull-requests: read # allows SonarCloud to decorate PRs with analysis results + +jobs: + build: + name: Build and Test + runs-on: ubuntu-22.04 + steps: + + - name: Check out code into the Go module directory + uses: actions/checkout@v4 + + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version-file: 'go.mod' + cache: true + + - name: Download module and all dependencies + run: go mod download + + - name: Build all relevant packages + run: go build -v . + + - name: Test relevant packages + run: go test -v -cover -coverprofile=coverage.out ./... + + - name: Upload Test results + uses: actions/upload-artifact@v3 + with: + name: test-coverage + path: coverage.out + + analysis: + name: Analyze with Sonar Cloud + needs: build + runs-on: ubuntu-22.04 + steps: + + - name: Check out code for Sonar Analysis + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Download Test results + uses: actions/download-artifact@v3 + with: + name: test-coverage + + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml deleted file mode 100644 index f26b6be..0000000 --- a/.github/workflows/go.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: CAP Operator Manager - Go (Build & Unit test) - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - - build: - name: Build - runs-on: ubuntu-22.04 - steps: - - - name: Check out code into the Go module directory - uses: actions/checkout@v3 - - - name: Setup Go - uses: actions/setup-go@v4 - with: - go-version: ^1.21 - cache: true - - - name: Get dependencies - run: go get -v -t -d ./... - - - name: Build all relevant packages - run: CGO_ENABLED=0 go build -v ./main.go - - - name: Test relevant packages - run: CGO_ENABLED=0 go test -v ./... \ No newline at end of file