Skip to content

Commit 565eafe

Browse files
crazy
1 parent 9fe0b75 commit 565eafe

2 files changed

Lines changed: 179 additions & 149 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 7 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -9,155 +9,13 @@ on:
99
- main
1010

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

.github/workflows/lint-tests.yaml

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
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

Comments
 (0)