-
Notifications
You must be signed in to change notification settings - Fork 0
277 lines (252 loc) · 9.92 KB
/
Copy pathci.yaml
File metadata and controls
277 lines (252 loc) · 9.92 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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
name: CI
# Consolidated pipeline per RELEASE_PIPELINE_PLAN.md.
#
# One workflow, one `build` matrix, one source of truth for binaries.
# Every consumer (e2e-serve, image, release-assets) pulls from the
# uploaded artifacts so a tag run ships the same bytes everywhere.
#
# Triggers:
# push main → lint, test, build, e2e-serve, image(sha)
# push tag v* → all of the above + image(tag) + release-assets
# pull_request → lint, test, build, e2e-serve only
# workflow_dispatch → same as push main
#
# Image is only published under Yolean (not YoleanAgents) — the `if:`
# on the image/release-assets jobs is belt-and-braces; the human owner
# mirrors manually when ready to open-source.
on:
push:
branches: [main]
tags: ['v*']
pull_request:
workflow_dispatch:
jobs:
# --- PR and main checks ---
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: go.mod
cache: true
- uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
with:
version: v2.11.4
args: --timeout=5m
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: go.mod
cache: true
- run: go test -count=1 ./...
- run: go vet ./...
e2e:
# Runs every test gated by `//go:build e2e` (kwok harness)
# plus the `//go:build e2e && docker` matrix (docker
# provisioner -- the k3s-in-docker airgap proof). Build tags
# compose, so a single `go test` call covers both. The kvm
# tag is intentionally omitted: github-hosted runners don't
# expose /dev/kvm, and adding it would force a self-hosted
# runner. Local devs run the kvm leg via test.sh.
#
# Gated on `test` so a broken unit suite short-circuits this
# ~5-minute job.
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: go.mod
cache: true
- run: go test -tags "e2e,docker" -count=1 -timeout=20m ./e2e/
# No e2e-multipass job here. The Linux multipass install path is
# snap-only, and snapcraft.io reachability from ubuntu-latest is
# too flaky to gate releases on (multiple consecutive runs on
# 2026-05-01 failed every retry against the snap store). The
# //go:build e2e && multipass test in e2e/multipass_test.go still
# exists and runs locally via:
#
# go test -tags 'e2e,multipass' -count=1 -timeout=30m ./e2e/
#
# so a developer or self-hosted runner with multipass already
# installed can verify the multipass provisioner end-to-end.
# The e2e (docker) job above is the release/image gate.
generate-drift:
# `go generate` regenerates the provisioner schema files from
# struct tags + pkg/provision/config/k3s.yaml. If the
# working tree differs after a fresh generate, the committed
# schemas have drifted from their source -- fail loudly so the
# PR carries the regenerated files.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: go.mod
cache: true
- run: go generate ./...
- name: Fail if generate produced changes
run: |
if ! git diff --exit-code; then
echo "::error::go generate produced changes; commit the regenerated files."
exit 1
fi
# --- Single source of truth for y-cluster binaries ---
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- goos: linux
goarch: amd64
- goos: linux
goarch: arm64
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: go.mod
cache: true
- name: Build y-cluster
env:
CGO_ENABLED: "0"
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
run: |
mkdir -p cmd/y-cluster/target/${GOOS}/${GOARCH}
go build -trimpath \
-ldflags "-s -w -X main.version=${GITHUB_REF_NAME}" \
-o cmd/y-cluster/target/${GOOS}/${GOARCH}/y-cluster \
./cmd/y-cluster
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: y-cluster-${{ matrix.goos }}-${{ matrix.goarch }}
path: cmd/y-cluster/target/${{ matrix.goos }}/${{ matrix.goarch }}/y-cluster
retention-days: 7
if-no-files-found: error
# --- E2e against the freshly-built linux/amd64 binary ---
e2e-serve:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: y-cluster-linux-amd64
path: bin
- name: Run serve e2e against the built binary
env:
Y_CLUSTER_BIN: ${{ github.workspace }}/bin/y-cluster
run: |
chmod +x "$Y_CLUSTER_BIN"
./scripts/e2e-serve-against-binary.sh
# --- Multi-arch image via contain, blocked on all prior jobs ---
image:
runs-on: ubuntu-latest
needs:
- lint
- test
- e2e
- build
- e2e-serve
if: github.repository_owner == 'Yolean' && github.event_name != 'pull_request'
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Download linux/amd64 binary
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: y-cluster-linux-amd64
path: cmd/y-cluster/target/linux/amd64
- name: Download linux/arm64 binary
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: y-cluster-linux-arm64
path: cmd/y-cluster/target/linux/arm64
- uses: solsson/setup-contain@49cc4cce1498df8a59e88fff52c1a9b747f11f08 # v1
with:
version: v0.9.0
- name: Log in to GitHub Container Registry
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image (SHA tag)
working-directory: cmd/y-cluster
env:
IMAGE: ghcr.io/yolean/y-cluster:${{ github.sha }}
run: contain build
- name: Build and push image (release tag)
if: startsWith(github.ref, 'refs/tags/v')
working-directory: cmd/y-cluster
env:
IMAGE: ghcr.io/yolean/y-cluster:${{ github.ref_name }}
run: contain build
# --- Release assets on tag push: raw binaries, no compression ---
release-assets:
runs-on: ubuntu-latest
needs: image
if: startsWith(github.ref, 'refs/tags/v') && github.repository_owner == 'Yolean'
permissions:
contents: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
pattern: y-cluster-*
path: downloaded
- name: Rename binaries (goreleaser naming) and checksum
id: assets
run: |
set -euo pipefail
tag="${GITHUB_REF_NAME}"
mkdir -p release
for d in downloaded/y-cluster-*; do
# Each artifact dir contains a single `y-cluster` binary.
base=$(basename "$d") # y-cluster-linux-amd64
suffix=${base#y-cluster-} # linux-amd64
os=${suffix%-*} # linux
arch=${suffix#*-} # amd64
cp "$d/y-cluster" "release/y-cluster_${tag}_${os}_${arch}"
chmod +x "release/y-cluster_${tag}_${os}_${arch}"
done
(cd release && sha256sum y-cluster_${tag}_* > "y-cluster_${tag}_checksums.txt")
ls -l release/
- name: Publish release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
tag="${GITHUB_REF_NAME}"
# Idempotent on re-runs and race-free with the
# `release: published` event that e2e-release.yaml
# listens for:
# - First run for a tag: `gh release create ... <files>`
# uploads atomically, so publish fires only after the
# assets are present. The previous shape called
# `release create` (empty publish, fires the event)
# THEN `release upload`; the event-driven validator
# raced in and saw an empty release ("no assets to
# download").
# - Re-run for an existing tag: skip create, use
# `release upload --clobber` to refresh the assets
# without retriggering publish.
if gh release view "$tag" >/dev/null 2>&1; then
gh release upload "$tag" release/y-cluster_${tag}_* --clobber
else
gh release create "$tag" --title "$tag" --generate-notes --verify-tag \
release/y-cluster_${tag}_*
fi