1+ name : CI
2+
3+ on :
4+ workflow_call :
5+ inputs :
6+ go-version :
7+ type : string
8+ required : true
9+
10+ jobs :
11+ preflight :
12+ runs-on : ubuntu-latest
13+ outputs :
14+ gopath : ${{ steps.gopath.outputs.value }}
15+ go-mods-cache-key : ${{ steps.cache-keys.outputs.go-mods-cache-key }}
16+ go-bins-cache-key : ${{ steps.cache-keys.outputs.go-bins-cache-key }}
17+ steps :
18+ - uses : actions/checkout@v4
19+ with :
20+ submodules : " false"
21+
22+ - uses : jdx/mise-action@v3
23+ with :
24+ cache : true
25+ reshim : true
26+ tool_versions : |
27+ go ${{ inputs.go-version }}
28+ github_token : ${{ secrets.GITHUB_TOKEN }}
29+
30+ - name : Get Go path
31+ id : gopath
32+ run : echo "value=$(go env GOPATH)" >> $GITHUB_OUTPUT
33+
34+ - name : Cache keys
35+ id : cache-keys
36+ run : |
37+ echo "go-mods-cache-key=go-mods-${{ runner.os }}-${{ hashFiles('**/go.sum') }}" >> $GITHUB_OUTPUT
38+
39+ - name : Cache Go mods
40+ id : go-mods-cache
41+ uses : actions/cache@v4
42+ with :
43+ lookup-only : true
44+ path : ${{ steps.gopath.outputs.value }}/pkg/mod
45+ key : ${{ steps.cache-keys.outputs.go-mods-cache-key }}
46+
47+ - name : 📥 Download dependencies
48+ if : steps.go-mods-cache.outputs.cache-hit != 'true'
49+ run : go mod download
50+
51+
52+
53+ test :
54+ runs-on : ubuntu-latest
55+ needs : preflight
56+ services :
57+ postgres :
58+ image : postgres:17.4
59+ ports :
60+ - 5444:5432
61+ options : >-
62+ --health-cmd pg_isready
63+ --health-interval 10s
64+ --health-timeout 5s
65+ --health-retries 5
66+ env :
67+ POSTGRES_PASSWORD : password
68+ steps :
69+ - uses : actions/checkout@v4
70+ - uses : jdx/mise-action@v3
71+ with :
72+ cache : true
73+ reshim : true
74+ tool_versions : |
75+ go ${{ inputs.go-version }}
76+ github_token : ${{ secrets.GITHUB_TOKEN }}
77+ - name : 💾 Cache Go mods
78+ uses : actions/cache@v4
79+ with :
80+ path : ${{ needs.preflight.outputs.gopath }}/pkg/mod
81+ key : ${{ needs.preflight.outputs.go-mods-cache-key }}
82+ fail-on-cache-miss : true
83+ - name : Run tests units
84+ run : |
85+ mkdir -p /tmp/test-reports
86+ gotestsum --junitfile /tmp/test-reports/unit-tests.xml
87+ - uses : actions/upload-artifact@v4
88+ name : Upload test results
89+ with :
90+ name : test-reports-${{ matrix.go-version }}
91+ path : /tmp/test-reports
92+ - name : Run Examples
93+ run : make test-examples
94+
95+ - name : Update coverage report
96+ uses : ncruces/go-coverage-report@v0.3.0
97+ with :
98+ report : true
99+ chart : true
100+ amend : true
101+ if : |
102+ matrix.go-version == 'stable'
103+ continue-on-error : true
104+
105+ test-race :
106+ runs-on : ubuntu-latest
107+ needs : preflight
108+ steps :
109+ - uses : actions/checkout@v4
110+ - uses : jdx/mise-action@v3
111+ with :
112+ cache : true
113+ reshim : true
114+ tool_versions : |
115+ go ${{ inputs.go-version }}
116+ github_token : ${{ secrets.GITHUB_TOKEN }}
117+ - name : 💾 Cache Go mods
118+ uses : actions/cache@v4
119+ with :
120+ path : ${{ needs.preflight.outputs.gopath }}/pkg/mod
121+ key : ${{ needs.preflight.outputs.go-mods-cache-key }}
122+ fail-on-cache-miss : true
123+ - name : Run tests with race detector
124+ run : make test-race
125+
126+ lint :
127+ runs-on : ubuntu-latest
128+ needs : preflight
129+ steps :
130+ - uses : actions/checkout@v4
131+ - uses : jdx/mise-action@v3
132+ with :
133+ cache : true
134+ reshim : true
135+ tool_versions : |
136+ go ${{ inputs.go-version }}
137+ github_token : ${{ secrets.GITHUB_TOKEN }}
138+ - name : 💾 Cache Go mods
139+ uses : actions/cache@v4
140+ with :
141+ path : ${{ needs.preflight.outputs.gopath }}/pkg/mod
142+ key : ${{ needs.preflight.outputs.go-mods-cache-key }}
143+ fail-on-cache-miss : true
144+ - name : go vet
145+ run : mise vet
146+ - name : Running staticcheck
147+ run : mise static
148+ - name : Running vulncheck
149+ run : mise vuln
150+
151+ fmt :
152+ runs-on : ubuntu-latest
153+ needs : preflight
154+ steps :
155+ - uses : actions/checkout@v4
156+ - uses : jdx/mise-action@v3
157+ with :
158+ cache : true
159+ reshim : true
160+ tool_versions : |
161+ go ${{ inputs.go-version }}
162+ github_token : ${{ secrets.GITHUB_TOKEN }}
163+ - name : 💾 Cache Go mods
164+ uses : actions/cache@v4
165+ with :
166+ path : ${{ needs.preflight.outputs.gopath }}/pkg/mod
167+ key : ${{ needs.preflight.outputs.go-mods-cache-key }}
168+ fail-on-cache-miss : true
169+ - name : Running formatting
170+ run : |
171+ mise fmt
172+ mise has-changes
0 commit comments