-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaskfile.test.yml
More file actions
150 lines (137 loc) · 5.63 KB
/
Copy pathTaskfile.test.yml
File metadata and controls
150 lines (137 loc) · 5.63 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
# yaml-language-server: $schema=https://taskfile.dev/schema.json
---
version: "3"
set:
- pipefail
run: once
env:
GOTOOLCHAIN:
sh: echo "go$(sed -n 's/^go //p' go.mod | head -1)"
# renovate: datasource=kubernetes-api depName=kubernetes
SETUP_ENVTEST_K8S_VERSION: "1.35.x!"
tasks:
.skip:
internal: true
silent: true
cmds: []
generate:
desc: Generate test mocks (mockery)
cmds:
- task: generate:mockery
generate:mockery:
internal: true
cmds:
- |
if ! grep -q 'packages:' .mockery.yaml 2>/dev/null || grep -q 'packages: {}' .mockery.yaml; then
echo "generate:mockery skipped (no mockery targets yet)"
exit 0
fi
go tool mockery
run:
desc: Run unit tests (excludes e2e build tag), with race detector
env:
CGO_ENABLED: "1"
KUBEBUILDER_ASSETS:
sh: go tool setup-envtest use ${SETUP_ENVTEST_K8S_VERSION} -p path
cmds:
- |
set -euo pipefail
rm -f coverage.out coverage-api.out coverage-summary.txt coverage-api-summary.txt
# Non-internal, non-api packages (e.g. test/schema) run without -coverprofile so they do
# not append to a coverage profile; mixed cache + multi-package cover merge can corrupt the
# profile (go tool cover: token too long / malformed import path). internal/ and api/ each
# get their own dedicated, floored coverprofile run below.
other_pkgs="$(go list ./... | grep -v /e2e | grep -v '/internal/' | grep -v '/api/' || true)"
if [ -n "${other_pkgs}" ]; then
go test -race ${other_pkgs}
fi
go test -race -count=1 -p 1 -coverpkg=./internal/... -coverprofile=coverage.out ./internal/...
if [ ! -s coverage.out ] || [ "$(wc -l < coverage.out)" -lt 2 ]; then
echo "coverage.out missing or empty after go test ./internal/..."
exit 1
fi
go tool cover -func=coverage.out | tee coverage-summary.txt | tail -1
pct="$(awk '/^total:/ {gsub(/%/,"",$3); print $3}' coverage-summary.txt)"
min=90
awk -v p="${pct}" -v m="${min}" 'BEGIN { if (p+0 < m+0) { printf "internal/ coverage %.1f%% is below %d%% floor\n", p, m; exit 1 } }'
# api/ hub types: CEL markers + v1alpha1<->v1beta1 conversion + deepcopy. Floored separately
# from internal/ so the ~3.2k-LOC hub API is measured, not just exercised (HA-S2).
go test -race -count=1 -p 1 -coverpkg=./api/... -coverprofile=coverage-api.out ./api/...
if [ ! -s coverage-api.out ] || [ "$(wc -l < coverage-api.out)" -lt 2 ]; then
echo "coverage-api.out missing or empty after go test ./api/..."
exit 1
fi
go tool cover -func=coverage-api.out | tee coverage-api-summary.txt | tail -1
api_pct="$(awk '/^total:/ {gsub(/%/,"",$3); print $3}' coverage-api-summary.txt)"
api_min=75
awk -v p="${api_pct}" -v m="${api_min}" 'BEGIN { if (p+0 < m+0) { printf "api/ coverage %.1f%% is below %d%% floor\n", p, m; exit 1 } }'
e2e:
desc: Run end-to-end tests (requires kind cluster; set KURATOR_E2E_MQ=1 for IBM MQ scenarios)
env:
CGO_ENABLED: "1"
KURATOR_E2E_DEPLOY:
sh: echo "${KURATOR_E2E_DEPLOY:-kustomize}"
KURATOR_E2E_MQ:
sh: echo "${KURATOR_E2E_MQ:-0}"
KIND_CLUSTER:
sh: echo "${KIND_CLUSTER:-${CLUSTER_NAME:-mkurator}}"
KUBECONFIG:
sh: |
ROOT="$(git rev-parse --show-toplevel)"
KIND_KUBECONFIG="${ROOT}/hack/kind-cluster/.state/kubeconfig.yaml"
if [ -n "${KUBECONFIG:-}" ] && [ -f "${KUBECONFIG}" ]; then
echo "${KUBECONFIG}"
else
echo "${KIND_KUBECONFIG}"
fi
cmds:
- bash hack/ci/run-e2e.sh
e2e:helm:
desc: Run e2e with Helm operator deploy (KURATOR_E2E_DEPLOY=helm; CI on schedule/dispatch)
env:
CGO_ENABLED: "1"
KURATOR_E2E_DEPLOY: "helm"
KURATOR_E2E_MQ:
sh: echo "${KURATOR_E2E_MQ:-0}"
KIND_CLUSTER:
sh: echo "${KIND_CLUSTER:-${CLUSTER_NAME:-mkurator}}"
KUBECONFIG:
sh: |
ROOT="$(git rev-parse --show-toplevel)"
KIND_KUBECONFIG="${ROOT}/hack/kind-cluster/.state/kubeconfig.yaml"
if [ -n "${KUBECONFIG:-}" ] && [ -f "${KUBECONFIG}" ]; then
echo "${KUBECONFIG}"
else
echo "${KIND_KUBECONFIG}"
fi
cmds:
- bash hack/ci/run-e2e-helm.sh
integration:
desc: Run IBM MQ integration tests (requires KURATOR_INTEGRATION_MQ=1 and live mqweb; use task mq:integration:up)
env:
CGO_ENABLED: "1"
KURATOR_INTEGRATION_MQ: "1"
KURATOR_INTEGRATION_MQ_ENDPOINT:
sh: echo "${KURATOR_INTEGRATION_MQ_ENDPOINT:-https://127.0.0.1:9443}"
KURATOR_INTEGRATION_MQ_QMGR:
sh: echo "${KURATOR_INTEGRATION_MQ_QMGR:-QM1}"
KURATOR_INTEGRATION_MQ_USER:
sh: echo "${KURATOR_INTEGRATION_MQ_USER:-admin}"
KURATOR_INTEGRATION_MQ_PASSWORD:
sh: echo "${KURATOR_INTEGRATION_MQ_PASSWORD:-passw0rd}"
KURATOR_INTEGRATION_MQ_INSECURE_TLS:
sh: echo "${KURATOR_INTEGRATION_MQ_INSECURE_TLS:-true}"
cmds:
- bash hack/ci/run-integration.sh
integration:local:
desc: Start Docker MQ, wait for mqweb, run integration tests (container left running)
cmds:
- bash hack/ci/run-integration-local.sh
schema:
desc: CRD OpenAPI spec fragment contract tests (no cluster; also run by task verify)
cmds:
- go test ./test/schema/ -count=1
schema:update:
desc: Regenerate test/schema/golden from config/crd/bases
cmds:
- UPDATE_GOLDEN=1 go test ./test/schema/ -run TestCRDSpecOpenAPIFragments -count=1