66jobs :
77 lint :
88 name : Lint
9+ # description: |
10+ # Lint uses golangci-lint github action and lints only changes from master.
11+ #
12+ # It will run on the latest go version.
13+ #
14+ # We rely on golangci-lint to automatically disable linters that do not apply to the minimum required go version
15+ # currently defined in go.mod.
16+ #
17+ # At this moment, .golangci.yml configuration files are not shared: each repository must have its configuration.
918 runs-on : ubuntu-latest
1019 steps :
1120 - uses : actions/checkout@v5
@@ -19,11 +28,31 @@ jobs:
1928 with :
2029 version : latest
2130 only-new-issues : true
22- skip-cache : true
31+ skip-cache : false
32+ - name : Linting complete # <- report summary when we have good news to report
33+ run : |
34+ echo "### Your changes to the go code look good. 👍" >> $GITHUB_STEP_SUMMARY
35+ echo "" >> $GITHUB_STEP_SUMMARY
36+ echo "> ℹ️ INFO: we use [golangci-lint action](https://github.com/golangci/golangci-lint-action)" >> $GITHUB_STEP_SUMMARY
37+ echo "> to lint any change to go code from master" >> $GITHUB_STEP_SUMMARY
2338
2439 unit_tests :
2540 name : Unit tests
41+ # description: |
42+ # Run go unit tests run x6: linux, mac & windows on the 2 latest go versions.
43+ #
44+ # Run tests with the -race flag.
45+ #
46+ # Captures test coverage and uploads it to codecov.com.
2647 runs-on : ${{ matrix.os }}
48+ outputs :
49+ # NOTE(fredbi): as of Aug. 2025, there is no way to have github actions declare outputs dynamically
50+ test_result_oldstable_ubuntu_latest : " ${{ steps.goreport.outputs.test_result_oldstable_ubuntu_latest }}"
51+ test_result_oldstable_macos_latest : " ${{ steps.goreport.outputs.test_result_oldstable_macos_latest }}"
52+ test_result_oldstable_windows_latest : " ${{ steps.goreport.outputs.test_result_oldstable_windows_latest }}"
53+ test_result_stable_ubuntu_latest : " ${{ steps.goreport.outputs.test_result_stable_ubuntu_latest }}"
54+ test_result_stable_macos_latest : " ${{ steps.goreport.outputs.test_result_stable_macos_latest }}"
55+ test_result_stable_windows_latest : " ${{ steps.goreport.outputs.test_result_stable_windows_latest }}"
2756
2857 strategy :
2958 matrix :
@@ -35,26 +64,85 @@ jobs:
3564 with :
3665 go-version : ' ${{ matrix.go_version }}'
3766 check-latest : true
38- cache : true
67+ cache : true # <- cache key is go.sum
3968
4069 - uses : actions/checkout@v5
70+
4171 - name : Run unit tests
72+ # description: |
73+ # runs unit tests with test coverage assuming that this repository contains only one module,
74+ # with a go.mod located at the root.
75+ id : gotest
76+ shell : bash
77+ run : |
78+ go test -v \
79+ -race \
80+ -coverprofile="coverage-${{ matrix.os }}.${{ matrix.go_version }}.out" \
81+ -covermode=atomic \
82+ -coverpkg=$(go list ./... |paste -sd ",") \
83+ ./...
84+
85+ - name : Report test
86+ if : ${{ success() || failure() }}
87+ id : goreport
4288 shell : bash
43- run : go test -v -race -coverprofile="coverage-${{ matrix.os }}.${{ matrix.go_version }}.out" -covermode=atomic -coverpkg=$(go list)/... ./...
89+ run : |
90+ icon="✅"
91+ if [[ "${{ steps.gotest.outcome }}" != "success" ]] ; then
92+ icon="🚫"
93+ fi
94+ echo "test_result_${{ matrix.go_version }}_$(echo "${{ matrix.os }}"|tr '-' '_')='| ${{ matrix.go_version }} | ${{ matrix.os }} | ${icon} ${{ steps.gotest.outcome }} |'" >> "$GITHUB_OUTPUT"
4495
4596 - name : Upload coverage to codecov
4697 uses : codecov/codecov-action@v5
4798 with :
4899 files : ' ./coverage-${{ matrix.os }}.${{ matrix.go_version }}.out'
49100 flags : ' ${{ matrix.go_version }}-${{ matrix.os }}'
50101 fail_ci_if_error : false
51- verbose : true
102+ verbose : false
52103
53104 all_tests :
54- needs : [ unit_tests ]
55105 name : All tests
106+ # description: |
107+ # This job regroups all tests launched as a matrix, so we may define a branch protection rule
108+ # just on that job rather than each matrix job independently.
109+ needs : [ unit_tests ] # <- requires all unit_tests jobs to be successful.
110+ env :
111+ test_result : ' ${{ join(needs.unit_tests.outputs.*) }}' # <- this is a comma-separated list of quoted strings
56112 runs-on : ubuntu-latest
57113 steps :
58114 - name : Tests complete
59115 run : |
60- echo "All tests completed"
116+ echo "### All tests completed. 👍" >> $GITHUB_STEP_SUMMARY
117+ echo "" >> $GITHUB_STEP_SUMMARY
118+ echo "> ℹ️ INFO: we run unit tests in 6 different configurations of OS and go version." >> $GITHUB_STEP_SUMMARY
119+ echo "> At this moment, we don't run architecture-specific test runs" >> $GITHUB_STEP_SUMMARY
120+ echo "" >> $GITHUB_STEP_SUMMARY
121+ echo "| go version | OS | Result |" >> $GITHUB_STEP_SUMMARY
122+ echo "|------------|----|--------|" >> $GITHUB_STEP_SUMMARY
123+ declare -a lines
124+ eval "lines=($(echo $test_result|tr ',' ' '))"
125+ for line in "${lines[@]}";do echo "${line}" ; done >> $GITHUB_STEP_SUMMARY
126+
127+ some_failed_tests :
128+ name : Some tests have failed
129+ # description: |
130+ # This job is only here to report a summary of failed tests in the github actions UI.
131+ needs : [ unit_tests ] # <- requires all unit_tests jobs to be completed, but not all where successfull.
132+ if : ${{ failure() }}
133+ env :
134+ test_result : ' ${{ join(needs.unit_tests.outputs.*) }}'
135+ runs-on : ubuntu-latest
136+ steps :
137+ - name : Tests failed
138+ run : |
139+ echo "### Some tests have failed. 🚫" >> $GITHUB_STEP_SUMMARY
140+ echo "" >> $GITHUB_STEP_SUMMARY
141+ echo "> ℹ️ INFO: testing halted on first encountered failure." >> $GITHUB_STEP_SUMMARY
142+ echo "> Some configurations may not have been tested yet." >> $GITHUB_STEP_SUMMARY
143+ echo "" >> $GITHUB_STEP_SUMMARY
144+ echo "| go version | OS | Result |" >> $GITHUB_STEP_SUMMARY
145+ echo "|------------|----|--------|" >> $GITHUB_STEP_SUMMARY
146+ declare -a lines
147+ eval "lines=($(echo $test_result|tr ',' ' '))"
148+ for line in "${lines[@]}";do echo "${line}" ; done >> $GITHUB_STEP_SUMMARY
0 commit comments