@@ -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,41 @@ 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_DIR : " config/e2e"
86+ OPERATOR_CONTROLLER_MANIFEST : " operator-controller-e2e.yaml"
6787 KIND_CLUSTER_NAME : " {{.KIND_CLUSTER_NAME}}-e2e"
88+ KIND_EXTRA_FLAGS : " --config ./kind-e2e.yaml"
89+ GO_COVER : " true"
90+ - defer :
91+ task : kind:delete
92+ vars :
93+ KIND_CLUSTER_NAME : " {{.KIND_CLUSTER_NAME}}-e2e"
94+ - " {{.TOOLSBIN}}/ginkgo --tags {{.GO_BUILD_TAGS}} --progress --trace {{with .FOCUS}}--focus '{{.}}'{{end}} ./test/e2e"
95+
96+ # Delete the operator controller manager pod to write the coverage data to disk.
97+ - kubectl delete --wait pod -n operator-controller-system -l control-plane=controller-manager
98+ - go tool covdata percent -i={{.GOCOVERDIR}}
99+ deps : [tools:ginkgo]
68100
69101 sanity :
70102 desc : " Run sanity checks"
@@ -78,3 +110,9 @@ tasks:
78110 cmds :
79111 - git diff --exit-code
80112 deps : [ style, build:generate ]
113+
114+ rm-file :
115+ cmds :
116+ - rm -f {{.FILE}}
117+ silent : true
118+ internal : true
0 commit comments