Skip to content

Commit 1264bfa

Browse files
authored
ci: enhance CI workflow with Go 1.24 and test reporting (#100)
Add Go 1.24 to the matrix to keep the CI up to date with the latest Go version. Introduce a separate Lint job that runs gofmt and go vet to improve code quality checks independently. Replace previous gofmt and go vet steps in the main job with a dedicated lint job. Modify the test job to install go-junit-report and generate JUnit XML test reports from Go test JSON output. Upload these test results to Codecov alongside coverage reports to improve test result visibility and integration with CI tools. These changes enhance CI robustness, code quality enforcement, and test reporting.
1 parent 136d86a commit 1264bfa

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

.github/workflows/code.yaml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@ concurrency:
1818
permissions: read-all
1919

2020
jobs:
21+
Lint:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4.2.2 # immutable action, safe to use the versions
25+
- uses: actions/setup-go@v5.4.0 # immutable action, safe to use the versions
26+
with:
27+
go-version-file: go.mod
28+
- name: gofmt
29+
run: diff -u <(echo -n) <(gofmt -l . )
30+
- name: show diff
31+
if: ${{ failure() }}
32+
run: git diff
33+
- run: go vet ./...
34+
2135
UnitTestJob:
2236
runs-on: ubuntu-latest
2337
strategy:
@@ -26,26 +40,28 @@ jobs:
2640
- "1.21"
2741
- "1.22"
2842
- "1.23"
43+
- "1.24"
2944
steps:
3045
- name: Checkout repository
3146
uses: actions/checkout@v4.2.2 # immutable action, safe to use the versions
3247
- name: Install Go
3348
uses: actions/setup-go@v5.4.0 # immutable action, safe to use the versions
3449
with:
3550
go-version: ${{ matrix.go }}
36-
- name: gofmt
37-
run: diff -u <(echo -n) <(gofmt -l . )
38-
- name: show diff
39-
if: ${{ failure() }}
40-
run: git diff
41-
- name: go vet
42-
run: go vet ./...
43-
- name: Run Unit Tests
44-
run: go test -race -cover -coverprofile=coverage.out -covermode=atomic ./...
45-
- name: Codecov
51+
- run: go install github.com/jstemmer/go-junit-report/v2@latest
52+
- run: go test -race -cover -coverprofile=coverage.out -covermode=atomic ./...
53+
- run: go test -json 2>&1 | go-junit-report -parser gojson > junit.xml
54+
if: always()
55+
- name: Upload coverage reports to Codecov
56+
if: ${{ !cancelled() }}
4657
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2
4758
env:
4859
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
60+
- name: Upload test results to Codecov
61+
if: ${{ !cancelled() }}
62+
uses: codecov/test-results-action@f2dba722c67b86c6caa034178c6e4d35335f6706 # v1.1.0
63+
env:
64+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
4965

5066
UnitTests:
5167
if: ${{ always() }}

0 commit comments

Comments
 (0)