@@ -44,8 +44,16 @@ tasks:
4444
4545 The FOCUS variable can be used to filter tests by name.
4646 The PKGS variable can be used to filter tests by package.
47+ vars :
48+ GOCOVERDIR : " ./coverage/unit"
4749 cmds :
48- - eval $({{.TOOLSBIN}}/setup-envtest use -p env {{.ENVTEST_VERSION}}) && {{.TOOLSBIN}}/ginkgo --tags {{.GO_BUILD_TAGS}} {{with .FOCUS}}-focus "{{.}}"{{end}} -coverprofile cover.out {{.PKGS}}
50+ - rm -rf {{.GOCOVERDIR}} && mkdir -p {{.GOCOVERDIR}} && chmod 1777 {{.GOCOVERDIR}}
51+ - defer :
52+ task : rm-file
53+ vars :
54+ FILE : .ginkgo.coverprofile.out
55+ - eval $({{.TOOLSBIN}}/setup-envtest use -p env {{.ENVTEST_VERSION}}) && {{.TOOLSBIN}}/ginkgo --coverprofile=.ginkgo.coverprofile.out --tags {{.GO_BUILD_TAGS}} --progress --trace {{with .FOCUS}}--focus "{{.}}"{{end}} {{.PKGS}} -- -test.gocoverdir="{{.ROOT_DIR}}/{{.GOCOVERDIR}}"
56+ - go tool covdata percent -i={{.GOCOVERDIR}}
4957 deps : [tools:setup-envtest, tools:ginkgo]
5058
5159 e2e :
@@ -54,17 +62,40 @@ tasks:
5462 Run e2e tests.
5563
5664 The FOCUS variable can be used to filter tests by name.
65+ vars :
66+ GOCOVERDIR : " ./coverage/e2e"
5767 cmds :
68+ - rm -rf {{.GOCOVERDIR}} && mkdir -p {{.GOCOVERDIR}} && chmod 1777 {{.GOCOVERDIR}}
69+ - |
70+ cat << EOF > ./kind-e2e.yaml
71+ kind: Cluster
72+ apiVersion: kind.x-k8s.io/v1alpha4
73+ nodes:
74+ - role: control-plane
75+ extraMounts:
76+ - hostPath: {{.GOCOVERDIR}}
77+ containerPath: /tmp/coverdata
78+ EOF
5879 - defer :
59- task : kind:delete
80+ task : rm-file
6081 vars :
61- KIND_CLUSTER_NAME : " {{.KIND_CLUSTER_NAME}}-e2e"
62- - " {{.TOOLSBIN}}/ginkgo --tags {{.GO_BUILD_TAGS}} -progress -trace {{with .FOCUS}}-focus '{{.}}'{{end}} ./test/e2e"
63- deps :
64- - tools:ginkgo
82+ FILE : " ./kind-e2e.yaml"
6583 - task : deploy:kind
6684 vars :
85+ KUSTOMIZE_MANAGER_DIR : " config/e2e"
6786 KIND_CLUSTER_NAME : " {{.KIND_CLUSTER_NAME}}-e2e"
87+ KIND_EXTRA_FLAGS : " --config ./kind-e2e.yaml"
88+ GO_COVER : " true"
89+ - defer :
90+ task : kind:delete
91+ vars :
92+ KIND_CLUSTER_NAME : " {{.KIND_CLUSTER_NAME}}-e2e"
93+ - " {{.TOOLSBIN}}/ginkgo --tags {{.GO_BUILD_TAGS}} --progress --trace {{with .FOCUS}}--focus '{{.}}'{{end}} ./test/e2e"
94+
95+ # Delete the operator controller manager pod to write the coverage data to disk.
96+ - kubectl delete --wait pod -n operator-controller-system -l control-plane=controller-manager
97+ - go tool covdata percent -i={{.GOCOVERDIR}}
98+ deps : [tools:ginkgo]
6899
69100 sanity :
70101 desc : " Run sanity checks"
@@ -78,3 +109,9 @@ tasks:
78109 cmds :
79110 - git diff --exit-code
80111 deps : [ style, build:generate ]
112+
113+ rm-file :
114+ cmds :
115+ - rm -f {{.FILE}}
116+ silent : true
117+ internal : true
0 commit comments