Skip to content

ci/unit-tests: add verbose mode with Ginkgo #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/unit_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
run: |
set -e

make unit-tests
make VERBOSE=true unit-tests

# Remove mock files from coverage analysis
sed -n -i '/\/mock\//!p' coverprofile.out
Expand Down
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,22 @@ LDFLAGS:=-w -s
LDFLAGS+=-X "$(GO_MODULE)/internal/cli/cmd.version=$(GIT_TAG)"
LDFLAGS+=-X "$(GO_MODULE)/internal/cli/cmd.gitCommit=$(GIT_COMMIT)"

# No verbose unit tests by default
ifeq ($(VERBOSE),true)
VERBOSE_TEST?=-v
endif

elemental:
go build -ldflags '$(LDFLAGS)' -o $@ ./cmd/...

.PHONY: unit-tests
unit-tests:
go run $(GINKGO) --label-filter '!rootlesskit' --race --cover --coverpkg=github.com/suse/elemental/... --github-output -p -r ${PKG}
go run $(GINKGO) --label-filter '!rootlesskit' --race --cover --coverpkg=github.com/suse/elemental/... --github-output -p -r $(VERBOSE_TEST) ${PKG}
ifeq (, $(shell which rootlesskit 2>/dev/null))
@echo "No rootlesskit utility found, not executing tests requiring it"
else
@mv coverprofile.out coverprofile.out.bk
rootlesskit go run $(GINKGO) --label-filter 'rootlesskit' --race --cover --coverpkg=github.com/suse/elemental/... --github-output -p -r ${PKG}
rootlesskit go run $(GINKGO) --label-filter 'rootlesskit' --race --cover --coverpkg=github.com/suse/elemental/... --github-output -p -r $(VERBOSE_TEST) ${PKG}
@grep -v "mode: atomic" coverprofile.out >> coverprofile.out.bk
@mv coverprofile.out.bk coverprofile.out
endif