From 0ed590414e5754fc599a41c0e04109899f3875f8 Mon Sep 17 00:00:00 2001 From: Andy Stoneberg Date: Tue, 10 Dec 2024 07:12:25 -0500 Subject: [PATCH] chore(test): Integration Codecov coverage reporting for odh-notebook-controller (#492) This commit integrates Codecov into our testing process by publishing our coverage report generated during `make test` to Codecov via the official `codecov/codecov-action` GHA. The `CODECOV_TOKEN` was previously uploaded to our GH repository as a secret (and copied to the Dependabot Secrets as well) by a repo admin: - https://redhat-internal.slack.com/archives/C060A5FJEAD/p1733334721701649 Please be aware of functionality **NOT** included in this initial PR (that may be added in the future): - unit test results are not being shipped to `Codecov` (even though that capability is supported) - a `.codecov.yml` file is presently not included. this could come as a fast-follow after the team gets a "feel" for `Codecov` - but I think its a bit premature to take my personal opinions to create such a file. Example `odh-dashboard` config can be seen here: - https://github.com/opendatahub-io/odh-dashboard/blob/main/.codecov.yml The `Codecov` integration was added to the `odh_notebook_controller_unit_test.yaml` GHA - which is already configured to execute on `pull_request` and `push` triggers. As such, no additional modification was necessary. :warning: It should be noted that the `make test` target was modifed to ensure the coverage files for the 2 respective invocations of `go test` wrote to unique output files to prevent information loss. `*.out` files are already ignored via `.gitignore`, so no problems there. Also, Codecov claims to support report merging automatically - so this should cause no issues: - https://docs.codecov.com/docs/merging-reports Related-to: https://issues.redhat.com/browse/RHOAIENG-11142 --- .github/workflows/odh_notebook_controller_unit_test.yaml | 7 +++++++ components/odh-notebook-controller/Makefile | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/odh_notebook_controller_unit_test.yaml b/.github/workflows/odh_notebook_controller_unit_test.yaml index ec7f647528a..09affa2c596 100644 --- a/.github/workflows/odh_notebook_controller_unit_test.yaml +++ b/.github/workflows/odh_notebook_controller_unit_test.yaml @@ -27,3 +27,10 @@ jobs: run: | cd components/odh-notebook-controller make test + + - name: Upload results to Codecov + uses: codecov/codecov-action@v5 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./components/odh-notebook-controller/cover-rbac-false.out,./components/odh-notebook-controller/cover-rbac-true.out + disable_search: true \ No newline at end of file diff --git a/components/odh-notebook-controller/Makefile b/components/odh-notebook-controller/Makefile index 90de33e4e54..7ca6bb961fd 100644 --- a/components/odh-notebook-controller/Makefile +++ b/components/odh-notebook-controller/Makefile @@ -94,12 +94,12 @@ test-with-rbac-false: manifests generate fmt vet envtest ## Run tests. export SET_PIPELINE_RBAC=false && \ ACK_GINKGO_DEPRECATIONS=1.16.5 \ KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" \ - go test ./controllers/... -ginkgo.v -ginkgo.progress -test.v -coverprofile cover.out + go test ./controllers/... -ginkgo.v -ginkgo.progress -test.v -coverprofile cover-rbac-false.out test-with-rbac-true: manifests generate fmt vet envtest ## Run tests. export SET_PIPELINE_RBAC=true && \ ACK_GINKGO_DEPRECATIONS=1.16.5 \ KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" \ - go test ./controllers/... -ginkgo.v -ginkgo.progress -test.v -coverprofile cover.out + go test ./controllers/... -ginkgo.v -ginkgo.progress -test.v -coverprofile cover-rbac-true.out ##@ Build