Skip to content

Commit cea6ed9

Browse files
committed
Update make test to run envtest tests after basic tests
* Update make rule to run envtest tests using Ginkgo CLI if available * Update github actions to install ginkgo and upload both coverage files * Allow skipping envtest tests by setting env var Signed-off-by: Angel Misevski <[email protected]>
1 parent a8a9c7b commit cea6ed9

File tree

6 files changed

+18
-12
lines changed

6 files changed

+18
-12
lines changed

.github/workflows/code-coverage.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ jobs:
4040
name: Run Go Tests
4141
run: |
4242
python -m pip install --upgrade pip yq
43+
go install github.com/onsi/ginkgo/v2/[email protected]
4344
make test
4445
-
4546
name: Build Codecov report
46-
uses: codecov/codecov-action@v1
47+
uses: codecov/codecov-action@v3
4748
with:
48-
files: cover.out
49+
files: ./cover.out,./controller.cover.out

.github/workflows/pr.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ jobs:
7474
run: |
7575
go install github.com/google/addlicense@latest
7676
go install golang.org/x/tools/cmd/goimports@latest
77-
7877
make check_fmt
7978
if [[ $? != 0 ]]
8079
then
@@ -110,12 +109,14 @@ jobs:
110109
name: Run Go Tests
111110
run: |
112111
python -m pip install --upgrade pip yq
112+
go install github.com/onsi/ginkgo/v2/[email protected]
113113
make test
114114
-
115115
name: Build Codecov report
116-
uses: codecov/codecov-action@v1
116+
uses: codecov/codecov-action@v3
117117
with:
118-
files: cover.out
118+
files: ./cover.out,./controller.cover.out
119+
119120

120121

121122
docker:

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,14 @@ update_devworkspace_crds:
9696

9797
### test: Runs tests
9898
test: generate fmt vet manifests envtest
99-
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $(shell go list ./... | grep -v test/e2e) -coverprofile cover.out
99+
ifneq ($(shell command -v ginkgo 2> /dev/null),)
100+
go test $(shell go list ./... | grep -v test/e2e | grep -v controllers/workspace) -coverprofile cover.out
101+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" \
102+
ginkgo run --timeout 5m --randomize-all -coverprofile controller.cover.out controllers/workspace
103+
else
104+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" \
105+
go test $(shell go list ./... | grep -v test/e2e) -coverprofile cover.out
106+
endif
100107

101108
### test_e2e: Runs e2e test on the cluster set in context. DevWorkspace Operator must be already deployed
102109
test_e2e:

controllers/workspace/suite_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ var (
6464
)
6565

6666
func TestAPIs(t *testing.T) {
67-
// if os.Getenv("TEST_CONTROLLER") != "true" {
68-
// t.Skip()
69-
// }
67+
if os.Getenv("SKIP_CONTROLLER_TESTS") == "true" {
68+
t.Skip()
69+
}
7070

7171
RegisterFailHandler(Fail)
7272

pkg/library/container/container_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ func loadTestCaseOrPanic(t *testing.T, testPath string) testCase {
6666
if err := yaml.Unmarshal(bytes, &test); err != nil {
6767
t.Fatal(err)
6868
}
69-
t.Logf("Read file:\n%+v\n\n", test)
7069
return test
7170
}
7271

pkg/library/lifecycle/prestart_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package lifecycle
1717

1818
import (
19-
"fmt"
2019
"os"
2120
"path/filepath"
2221
"testing"
@@ -48,7 +47,6 @@ func loadPreStartTestCaseOrPanic(t *testing.T, testFilename string) preStartTest
4847
if err := yaml.Unmarshal(bytes, &test); err != nil {
4948
t.Fatal(err)
5049
}
51-
t.Log(fmt.Sprintf("Read file:\n%+v\n\n", test))
5250
return test
5351
}
5452

0 commit comments

Comments
 (0)