Repository navigation
207 lines (196 loc) · 5.68 KB
/
Copy pathci.yml
File metadata and controls
207 lines (196 loc) · 5.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: "30 2 * * *"
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
GOWORK: "off"
jobs:
changes:
runs-on: ubuntu-latest
outputs:
quality_ci: ${{ steps.filter.outputs.quality_ci }}
docker_ci: ${{ steps.filter.outputs.docker_ci }}
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Detect changed paths
id: filter
uses: dorny/paths-filter@v4
with:
filters: |
quality_ci:
- '**/*.go'
- 'go.mod'
- 'go.sum'
- '.golangci.yml'
- '.mise.toml'
- 'README.md'
- 'CONTEXT.md'
- 'docs/**'
- 'examples/**'
- 'e2e/**'
- 'internal/service/scaffold/templates/**'
- '.github/workflows/**'
- '.github/scripts/**'
docker_ci:
- 'Dockerfile'
- '.dockerignore'
linux:
name: quality (Linux)
needs: changes
if: needs.changes.outputs.quality_ci == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
cache-dependency-path: |
go.sum
examples/orders-api/go.sum
- name: Set up project tools
uses: jdx/mise-action@v4
with:
cache: true
install: true
github_token: ${{ github.token }}
- name: Run check
run: MISE_JOBS=1 mise run check:core
lint:
name: lint (Linux)
needs: changes
if: needs.changes.outputs.quality_ci == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
cache-dependency-path: |
go.sum
examples/orders-api/go.sum
- name: Set up project tools
uses: jdx/mise-action@v4
with:
cache: true
install: true
github_token: ${{ github.token }}
- name: Cache golangci-lint analysis
uses: actions/cache@v5
with:
path: ~/.cache/golangci-lint
key: golangci-lint-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.mise.toml', '.golangci.yml', 'go.mod', 'go.sum') }}
restore-keys: |
golangci-lint-${{ runner.os }}-${{ runner.arch }}-
- name: Run lint
run: mise run lint
e2e:
name: e2e (Linux)
needs: changes
if: needs.changes.outputs.quality_ci == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
cache-dependency-path: |
go.sum
examples/orders-api/go.sum
- name: Set up project tools
uses: jdx/mise-action@v4
with:
cache: true
install: true
github_token: ${{ github.token }}
- name: Run e2e
run: mise run e2e
race:
name: race (Linux)
if: github.event_name == 'schedule' || (github.event_name == 'push' && github.ref == 'refs/heads/main')
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version-file: go.mod
cache: true
cache-dependency-path: |
go.sum
examples/orders-api/go.sum
- name: Run race tests
run: GOWORK=off go test -race ./...
docker:
name: docker (linux/amd64)
needs: changes
if: needs.changes.outputs.docker_ci == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build Docker image
uses: docker/build-push-action@v7
with:
context: .
platforms: linux/amd64
load: true
push: false
tags: devctl:ci
build-args: |
VERSION=ci
COMMIT=${{ github.sha }}
cache-from: type=gha,scope=docker-amd64
cache-to: type=gha,scope=docker-amd64,mode=max
provenance: false
- name: Verify image metadata
env:
EXPECTED_COMMIT: ${{ github.sha }}
run: |
set -euo pipefail
version_output="$(docker run --rm --platform linux/amd64 devctl:ci --version)"
grep -Fqx "devctl version ci" <<< "${version_output}"
grep -Fqx "commit: ${EXPECTED_COMMIT}" <<< "${version_output}"
- name: Verify project runner tools
run: |
set -euo pipefail
docker run --rm --platform linux/amd64 --entrypoint sh devctl:ci -ceu '
test -x /devctl
command -v devctl
go version
git --version
node --version | grep -E "^v24\\."
quicktype --version
'
release-helper:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Run release helper tests
run: python3 -B -m unittest discover -s .github/scripts/tests -t .github/scripts