Skip to content

Commit 5a1aae6

Browse files
authored
ci: publish coverage report (#3)
Signed-off-by: Zibi Mandziejewicz <shaxbee@gmail.com>
1 parent be199fd commit 5a1aae6

File tree

11 files changed

+164
-49
lines changed

11 files changed

+164
-49
lines changed

.github/workflows/ci.yaml

Lines changed: 102 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: ci
1+
name: CI
22

33
on:
44
push:
@@ -22,14 +22,109 @@ jobs:
2222
registry: ghcr.io
2323
username: ${{ github.actor }}
2424
password: ${{ secrets.GITHUB_TOKEN }}
25-
- name: Build images
26-
uses: hiberbee/github-action-skaffold@1.19.0
25+
- name: Setup Skaffold
26+
uses: heypigeonhq/setup-skaffold@v1.0.0
2727
with:
28-
skaffold-version: 2.14.1
29-
command: build
30-
file-output: build/images.json
28+
version: 2.14.1
29+
- name: Build images
30+
run: |
31+
mkdir build
32+
skaffold build --file-output=build/images.json
3133
- name: Archive image tags
3234
uses: actions/upload-artifact@v4
3335
with:
3436
name: images
35-
path: build/images.json
37+
path: build/images.json
38+
39+
verify:
40+
name: Verify
41+
runs-on: ubuntu-latest
42+
env:
43+
CODECOV_FILE: build/coverage.xml
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@v4
47+
- name: Setup Go
48+
uses: actions/setup-go@v5
49+
with:
50+
go-version: '1.24'
51+
- name: Generate
52+
run: make generate format
53+
- name: No changed files
54+
run: git diff --name-status --exit-code
55+
- name: Lint
56+
run: make lint
57+
- name: Integration test
58+
run: make integration-test coverage
59+
- name: Generate
60+
uses: irongut/CodeCoverageSummary@v1.3.0
61+
with:
62+
filename: build/coverage.xml,build/coverage.e2e.xml
63+
badge: true
64+
format: markdown
65+
output: both
66+
- name: Archive coverage report
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: coverage
70+
path: ${{ env.CODECOV_FILE }}
71+
72+
# e2e:
73+
# name: E2E Test
74+
# needs:
75+
# - verify
76+
# - image-build
77+
# runs-on: ubuntu-latest
78+
# env:
79+
# CODECOV_FILE: build/coverage.e2e.xml
80+
# SKAFFOLD_NAMESPACE: sandbox
81+
# SKAFFOLD_RUN_ID: e2e-test
82+
# steps:
83+
# - name: Checkout
84+
# uses: actions/checkout@v4
85+
# - name: Setup Skaffold
86+
# uses: heypigeonhq/setup-skaffold@v1.0.0
87+
# with:
88+
# version: 2.14.1
89+
# - name: Create Kind cluster
90+
# uses: helm/kind-action@v1
91+
# with:
92+
# cluster_name: kind-etcd
93+
# - name: Bootstrap
94+
# run: |
95+
# kustomize build --enable-helm config/bootstrap | kubectl apply -f -
96+
# kubectl --namespace cert-manager wait --for=condition=Available deployment/cert-manager-webhook
97+
# kubectl get namespace sandbox 2>/dev/null || kubectl create namespace sandbox
98+
# - name: Build images
99+
# run: |
100+
# mkdir build
101+
# skaffold build --file-output=build/images.json
102+
# - name: Deploy
103+
# run: skaffold deploy --profile e2e --build-artifacts=build/images.json
104+
# - name: Run E2E tests
105+
# run: skaffold verify --namespace sandbox --build-artifacts=build/images.json
106+
# - name: Fetch coverage
107+
# run: make fetch-coverage
108+
# - name: Archive coverage report
109+
# uses: actions/upload-artifact@v4
110+
# with:
111+
# name: coverage-e2e
112+
# path: ${{ env.CODECOV_FILE }}
113+
114+
# coverage:
115+
# name: Coverage Report
116+
# needs:
117+
# - verify
118+
# - e2e
119+
# runs-on: ubuntu-latest
120+
# steps:
121+
# - name: Download coverage report
122+
# uses: actions/download-artifact@v4
123+
# with:
124+
# name: coverage
125+
# path: build
126+
# - name: Download E2E coverage report
127+
# uses: actions/download-artifact@v4
128+
# with:
129+
# name: coverage-e2e
130+
# path: build

.golangci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: "2"
2+
run:
3+
concurrency: 4
4+
modules-download-mode: readonly
5+
tests: true
6+
linters:
7+
exclusions:
8+
generated: lax
9+
paths:
10+
- third_party$
11+
- builtin$
12+
- examples$
13+
issues:
14+
max-issues-per-linter: 0
15+
max-same-issues: 0

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Agoda Company Pte Ltd.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ SKAFFOLD_NAMESPACE ?= fleet
1818
GOCOVERPKG := github.com/agoda-com/etcd-operator/pkg/...
1919
GOTESTARGS := -test.timeout=30m
2020
GOMUTESTARGS := ./pkg
21-
GOLANGCILINT_VERSION := v1.64.8
21+
GOLANGCILINT_VERSION := v2.0.2
2222

2323
include makefiles/go.mk
2424
include makefiles/controller.mk

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# ETCD Operator
22

3+
![Code Coverage](https://img.shields.io/badge/Code%20Coverage-26%25-critical?style=flat)
4+
35
## Docs
46

57
* [API](/docs/api.md)
@@ -15,8 +17,8 @@
1517
* [config/rbac](config/rbac) - cluster-wide RBAC
1618

1719
## Profiles
18-
* [config/sandbox](config/sandbox) - single namespace deployment with namespace-scoped RBAC
19-
* [config/e2e](config/e2e) - sandbox with coverage enabled on etcd-operator
20+
* [default](config/default) - default deployment
21+
* [config/e2e](config/e2e) - e2e rbac sandbox with coverage enabled on etcd-operator
2022

2123
## Running locally
2224

@@ -28,7 +30,14 @@ Operator requires cert-manager and CRDs to be installed in the cluster.
2830
kustomize build --enable-helm config/bootstrap | kubectl apply -f -
2931
```
3032

31-
### Run
33+
### Deploy (docker+kubectl)
34+
35+
```
36+
docker build --tag ghcr.io/agoda-com/etcd .
37+
kubectl apply -k config/default
38+
```
39+
40+
### Deploy (skaffold)
3241

3342
```
3443
skaffold run
@@ -74,11 +83,6 @@ End-to-end tests:
7483
make e2e-test
7584
```
7685

77-
Run end-to-end tests on dev cluster:
78-
```sh
79-
make e2e-test
80-
```
81-
8286
Coverage:
8387
```sh
8488
make test coverage

config/default/kustomization.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
apiVersion: kustomize.config.k8s.io/v1beta1
22
kind: Kustomization
3-
namespace: default
3+
namespace: etcd
44
resources:
55
- ../rbac
6-
- ../base
6+
- ../base
7+
- namespace.yaml

config/default/namespace.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: Namespace
2+
metadata:
3+
name: etcd

e2e/backup_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestBackup(t *testing.T) {
4343

4444
// create some data
4545
k, v := "leela", "turanga"
46-
if _, err := ecl.KV.Put(ctx, k, v); err != nil {
46+
if _, err := ecl.Put(ctx, k, v); err != nil {
4747
t.Fatal("failed to put key:", err)
4848
}
4949

@@ -55,7 +55,7 @@ func TestBackup(t *testing.T) {
5555
triggerCronJob(t, ctx, kcl, key, 5*time.Minute)
5656

5757
// delete data
58-
if _, err := ecl.KV.Delete(ctx, k); err != nil {
58+
if _, err := ecl.Delete(ctx, k); err != nil {
5959
t.Fatal("failed to delete key:", err)
6060
}
6161

pkg/cluster/reconciler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,8 @@ func (r *Reconciler) ReconcileStatus(ctx context.Context, cluster *apiv1.EtcdClu
352352
return
353353
}
354354

355-
switch {
356-
case resp.Leader == resp.Header.MemberId:
355+
switch resp.Leader {
356+
case resp.Header.MemberId:
357357
status.Role = apiv1.MemberRoleLeader
358358
default:
359359
status.Role = apiv1.MemberRoleMember

pkg/resources/pki.go

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
cmv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
99
cmmeta "github.com/cert-manager/cert-manager/pkg/apis/meta/v1"
1010
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
11-
"sigs.k8s.io/controller-runtime/pkg/client"
1211
)
1312

1413
type CertificateBuilder struct{ *cmv1.Certificate }
@@ -105,38 +104,20 @@ func (c CertificateBuilder) Subject(cn string, orgs ...string) CertificateBuilde
105104
return c
106105
}
107106

108-
func (c CertificateBuilder) SecretLabel(key, value string) CertificateBuilder {
107+
func (c CertificateBuilder) SecretLabels(labels map[string]string) CertificateBuilder {
109108
if c.Spec.SecretTemplate == nil {
110109
c.Spec.SecretTemplate = &cmv1.CertificateSecretTemplate{}
111110
}
112111

113112
if c.Spec.SecretTemplate.Labels == nil {
114-
c.Spec.SecretTemplate.Labels = make(map[string]string)
115-
}
116-
117-
c.Spec.SecretTemplate.Labels[key] = value
118-
return c
119-
}
120-
121-
func (c CertificateBuilder) SecretLabels(labels map[string]string) CertificateBuilder {
122-
if c.Spec.SecretTemplate == nil {
123-
c.Spec.SecretTemplate = &cmv1.CertificateSecretTemplate{}
113+
c.Spec.SecretTemplate.Labels = map[string]string{}
124114
}
125115

126-
switch {
127-
case c.Spec.SecretTemplate.Labels == nil:
128-
c.Spec.SecretTemplate.Labels = labels
129-
default:
130-
maps.Copy(c.Spec.SecretTemplate.Labels, labels)
131-
}
116+
maps.Copy(c.Spec.SecretTemplate.Labels, labels)
132117

133118
return c
134119
}
135120

136-
func (c CertificateBuilder) Key() client.ObjectKey {
137-
return client.ObjectKeyFromObject(c.Certificate)
138-
}
139-
140121
func (b *Builder) Certificate(names ...string) CertificateBuilder {
141122
name := b.name(names)
142123
cert := &cmv1.Certificate{

0 commit comments

Comments
 (0)