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 diff --git a/README.md b/README.md index a32e1dd..8c42cdd 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ # cap-operator-lifecycle +![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/SAP/cap-operator-lifecycle) +[![Go Report Card](https://goreportcard.com/badge/github.com/sap/cap-operator-lifecycle)](https://goreportcard.com/report/github.com/sap/cap-operator-lifecycle) +[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=SAP_cap-operator-lifecycle&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=SAP_cap-operator-lifecycle) +[![CodeQL](https://github.com/SAP/cap-operator-lifecycle/actions/workflows/github-code-scanning/codeql/badge.svg)](https://github.com/SAP/cap-operator-lifecycle/actions/workflows/github-code-scanning/codeql) [![REUSE status](https://api.reuse.software/badge/github.com/SAP/cap-operator-lifecycle)](https://api.reuse.software/info/github.com/SAP/cap-operator-lifecycle) Helm chart and operator based on Kyma lifecycle manager to install the [CAP Operator](https://sap.github.io/cap-operator/) diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..1384ac1 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,18 @@ +sonar.projectKey=SAP_cap-operator-lifecycle +sonar.organization=sap-1 + +# This is the name and version displayed in the SonarCloud UI. +#sonar.projectName=CAP Operator Lifecycle +#sonar.projectVersion=1.0 +# Go! +sonar.language=go +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +sonar.sources=pkg,internal +sonar.exclusions=**/*_test.go +sonar.tests=. +sonar.test.inclusions=**/*_test.go + +sonar.go.coverage.reportPaths=coverage.out + +# Encoding of the source code. Default is default system encoding +#sonar.sourceEncoding=UTF-8