-
Notifications
You must be signed in to change notification settings - Fork 0
279 lines (237 loc) · 7.4 KB
/
ci.yaml
File metadata and controls
279 lines (237 loc) · 7.4 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
278
279
name: Continuous Integration
on:
push:
branches: ["main", "develop"]
pull_request:
branches: ["main", "develop"]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
GO_VERSION: "1.25.3"
GOLANGCI_LINT_VERSION: "v2.5.0"
HELM_VERSION: "v3.19.0"
KUBECTL_VERSION: "v1.34.1"
GOTOOLCHAIN: local
jobs:
# Fast parallel jobs that can run independently
lint:
name: Lint and Vet
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Cache Go modules
uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run go vet
run: go vet ./...
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
args: --timeout=5m --fast
- name: Check code formatting
run: |
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
echo "The following files are not formatted:"
gofmt -s -l .
exit 1
fi
test:
name: Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Cache Go modules
uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install test dependencies
run: |
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
ENVTEST_ASSETS_DIR=$(setup-envtest use ${{ env.KUBECTL_VERSION }} --bin-dir $(pwd)/bin/k8s -p path)
echo "ENVTEST_ASSETS_DIR=$ENVTEST_ASSETS_DIR" >> $GITHUB_ENV
- name: Run unit tests
run: |
go test ./... -race -v -coverprofile=coverage.out -covermode=atomic
- name: Generate test coverage
run: |
go tool cover -html=coverage.out -o coverage.html
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
files: ./coverage.out
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
build:
name: Build and Verify
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Cache Go modules
uses: actions/cache@v4
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Generate code
run: make generate
- name: Generate manifests
run: make manifests
- name: Verify generated code
run: |
if ! git diff --quiet; then
echo "Generated code is out of date. Please run 'make generate' and 'make manifests'"
git diff
exit 1
fi
- name: Build operator binary
run: |
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o manager cmd/main.go
- name: Verify binary
run: |
./manager --help || true
ls -la manager
helm-lint:
name: Helm Chart Lint
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: ${{ env.HELM_VERSION }}
- name: Lint Helm chart
run: helm lint helm/helios-operator/
- name: Template Helm chart
run: helm template helios-operator helm/helios-operator/ --dry-run
- name: Package Helm chart
run: |
mkdir -p dist
helm package helm/helios-operator/ --destination dist/
e2e-tests:
name: End-to-End Tests
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Set up kubectl
uses: azure/setup-kubectl@v4
with:
version: ${{ env.KUBECTL_VERSION }}
- name: Set up Minikube
uses: medyagh/setup-minikube@v0.0.20
with:
driver: docker
memory: 4096
cpus: 2
- name: Install dependencies
run: |
# Install cert-manager
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.19.1/cert-manager.yaml
kubectl wait --for=condition=ready pod -l app=cert-manager -n cert-manager --timeout=60s
# Install Tekton
kubectl apply -f https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml
kubectl apply -f https://storage.googleapis.com/tekton-releases/triggers/latest/release.yaml
# Install ArgoCD
helm repo add argo https://argoproj.github.io/argo-helm
helm repo update
helm upgrade --install argocd argo/argo-cd --version 8.6.3 --namespace argocd --create-namespace --wait
- name: Run E2E tests
run: make test-e2e
- name: Collect logs on failure
if: failure()
run: |
kubectl get pods --all-namespaces
kubectl describe pods --all-namespaces | head -1000
# Only run on main branch pushes
release:
name: Create Release
runs-on: ubuntu-latest
needs: [lint, test, build, helm-lint, e2e-tests]
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
timeout-minutes: 15
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Generate changelog
id: changelog
run: |
if [ -f CHANGELOG.md ]; then
echo "changelog<<EOF" >> $GITHUB_OUTPUT
head -50 CHANGELOG.md >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
else
echo "changelog=No changelog available" >> $GITHUB_OUTPUT
fi
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ github.run_number }}
name: Release v${{ github.run_number }}
body: ${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false