From d6ae166a3387d68ff808e8c03f8b37cec84aec4c Mon Sep 17 00:00:00 2001 From: Gonzalo Diaz Date: Tue, 19 Aug 2025 00:40:42 -0400 Subject: [PATCH] [CONFIG] [REFACTOR] [Github Actions] codecov and sonarcloud now runs in parallel. Coverage file moved. --- .codecov.yml | 5 ++++ .github/workflows/go-coverage.yml | 45 +++++++++++++++++++++++++++---- Dockerfile | 2 ++ Makefile | 6 ++--- sonar-project.properties | 2 +- 5 files changed, 51 insertions(+), 9 deletions(-) create mode 100644 .codecov.yml diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 0000000..0ed64d9 --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,5 @@ +--- + +fixes: + - "gon.cl/algorithms/::" + - "/home/runner/work/algorithm-exercises-go/algorithm-exercises-go/::" diff --git a/.github/workflows/go-coverage.yml b/.github/workflows/go-coverage.yml index 2d86247..858810e 100644 --- a/.github/workflows/go-coverage.yml +++ b/.github/workflows/go-coverage.yml @@ -15,7 +15,7 @@ env: jobs: - coverage: + build-and-test: name: "Go CI Tests Coverage" strategy: fail-fast: false @@ -41,21 +41,56 @@ jobs: run: > go test -v -covermode=atomic - -coverprofile="coverage.out" + -coverprofile="coverage/coverage.out" ./exercises/... - name: Coverage - run: go tool cover -func="coverage.out" + run: go tool cover -func="coverage/coverage.out" + + - name: Upload coverage artifact + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: coverage + + codecov: + name: Upload to Codecov + runs-on: ubuntu-24.04 + needs: build-and-test + + steps: + - name: Download coverage artifact + uses: actions/download-artifact@v5 + with: + name: coverage-report + path: coverage - name: Upload coverage reports to Codecov with GitHub Action uses: codecov/codecov-action@v5 with: + files: coverage/coverage.out token: ${{ secrets.CODECOV_TOKEN }} # required verbose: true # optional (default = false) - - name: Analyze with SonarCloud + sonarqube: + name: Analyze with SonarQube + runs-on: ubuntu-24.04 + needs: build-and-test + + steps: + - name: Checkout repository + uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - name: Download coverage artifact + uses: actions/download-artifact@v5 + with: + name: coverage-report + path: coverage + + - name: SonarQube Scan uses: SonarSource/sonarqube-scan-action@master env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - # Needed to get PR information, if any GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Dockerfile b/Dockerfile index 22dde96..46b69aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -81,6 +81,8 @@ COPY ./go.mod ${WORKDIR}/ COPY ./go.sum ${WORKDIR}/ COPY ./Makefile ${WORKDIR}/ +RUN mkdir ${WORKDIR}/coverage + # CMD [] ############################################################################### FROM development AS builder diff --git a/Makefile b/Makefile index 15441a1..996b4bc 100644 --- a/Makefile +++ b/Makefile @@ -88,15 +88,15 @@ format: $(GO) run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix ./... coverage.out: env dependencies - $(GOTEST) -v -covermode=atomic -coverprofile="coverage.out" ./exercises/... + $(GOTEST) -v -covermode=atomic -coverprofile="coverage/coverage.out" ./exercises/... test: env dependencies coverage.out - $(GOCOVER) -func=coverage.out + $(GOCOVER) -func=coverage/coverage.out coverage: test coverage/html: coverage.out - $(GOCOVER) -html=coverage.out -o ./coverage/coverage.html + $(GOCOVER) -html=coverage/coverage.out -o ./coverage/coverage.html open ./coverage/coverage.html outdated: diff --git a/sonar-project.properties b/sonar-project.properties index 54b0a8f..46565b6 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -12,7 +12,7 @@ sonar.exclusions= sonar.tests=exercises sonar.test.inclusions=**/*_test.go -sonar.go.coverage.reportPaths=coverage.out +sonar.go.coverage.reportPaths=coverage/coverage.out # Encoding of the source code. Default is default system encoding sonar.sourceEncoding=UTF-8