Skip to content

Commit d6ae166

Browse files
author
Gonzalo Diaz
committed
[CONFIG] [REFACTOR] [Github Actions] codecov and sonarcloud now runs in parallel. Coverage file moved.
1 parent fc6f43c commit d6ae166

File tree

5 files changed

+51
-9
lines changed

5 files changed

+51
-9
lines changed

.codecov.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
3+
fixes:
4+
- "gon.cl/algorithms/::"
5+
- "/home/runner/work/algorithm-exercises-go/algorithm-exercises-go/::"

.github/workflows/go-coverage.yml

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ env:
1515

1616
jobs:
1717

18-
coverage:
18+
build-and-test:
1919
name: "Go CI Tests Coverage"
2020
strategy:
2121
fail-fast: false
@@ -41,21 +41,56 @@ jobs:
4141
run: >
4242
go test -v
4343
-covermode=atomic
44-
-coverprofile="coverage.out"
44+
-coverprofile="coverage/coverage.out"
4545
./exercises/...
4646
4747
- name: Coverage
48-
run: go tool cover -func="coverage.out"
48+
run: go tool cover -func="coverage/coverage.out"
49+
50+
- name: Upload coverage artifact
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: coverage-report
54+
path: coverage
55+
56+
codecov:
57+
name: Upload to Codecov
58+
runs-on: ubuntu-24.04
59+
needs: build-and-test
60+
61+
steps:
62+
- name: Download coverage artifact
63+
uses: actions/download-artifact@v5
64+
with:
65+
name: coverage-report
66+
path: coverage
4967

5068
- name: Upload coverage reports to Codecov with GitHub Action
5169
uses: codecov/codecov-action@v5
5270
with:
71+
files: coverage/coverage.out
5372
token: ${{ secrets.CODECOV_TOKEN }} # required
5473
verbose: true # optional (default = false)
5574

56-
- name: Analyze with SonarCloud
75+
sonarqube:
76+
name: Analyze with SonarQube
77+
runs-on: ubuntu-24.04
78+
needs: build-and-test
79+
80+
steps:
81+
- name: Checkout repository
82+
uses: actions/checkout@v5
83+
with:
84+
fetch-depth: 0
85+
86+
- name: Download coverage artifact
87+
uses: actions/download-artifact@v5
88+
with:
89+
name: coverage-report
90+
path: coverage
91+
92+
- name: SonarQube Scan
5793
uses: SonarSource/sonarqube-scan-action@master
5894
env:
5995
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
60-
# Needed to get PR information, if any
6196
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ COPY ./go.mod ${WORKDIR}/
8181
COPY ./go.sum ${WORKDIR}/
8282
COPY ./Makefile ${WORKDIR}/
8383

84+
RUN mkdir ${WORKDIR}/coverage
85+
8486
# CMD []
8587
###############################################################################
8688
FROM development AS builder

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,15 @@ format:
8888
$(GO) run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix ./...
8989

9090
coverage.out: env dependencies
91-
$(GOTEST) -v -covermode=atomic -coverprofile="coverage.out" ./exercises/...
91+
$(GOTEST) -v -covermode=atomic -coverprofile="coverage/coverage.out" ./exercises/...
9292

9393
test: env dependencies coverage.out
94-
$(GOCOVER) -func=coverage.out
94+
$(GOCOVER) -func=coverage/coverage.out
9595

9696
coverage: test
9797

9898
coverage/html: coverage.out
99-
$(GOCOVER) -html=coverage.out -o ./coverage/coverage.html
99+
$(GOCOVER) -html=coverage/coverage.out -o ./coverage/coverage.html
100100
open ./coverage/coverage.html
101101

102102
outdated:

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ sonar.exclusions=
1212
sonar.tests=exercises
1313
sonar.test.inclusions=**/*_test.go
1414

15-
sonar.go.coverage.reportPaths=coverage.out
15+
sonar.go.coverage.reportPaths=coverage/coverage.out
1616

1717
# Encoding of the source code. Default is default system encoding
1818
sonar.sourceEncoding=UTF-8

0 commit comments

Comments
 (0)