Skip to content

Commit

Permalink
workflows: include splunk_logger sub module in tests
Browse files Browse the repository at this point in the history
also implement a target to create coverage-report
  • Loading branch information
schuellerf committed Aug 14, 2024
1 parent 13737f9 commit 41872bb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
run: git config --global --add safe.directory "$(pwd)"

- name: Run unit tests
run: go test -race -covermode=atomic -coverprofile=coverage.txt -coverpkg=$(go list ./... | grep -v rpmmd/test$ | tr "\n" ",") ./...
run: make unit-tests

- uses: codecov/codecov-action@v4
if: env.CODECOV_TOKEN
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ __pycache__
container_composer_golangci_built.info
processed-templates

coverage.txt
coverage.html

coverage_splunk_logger.txt
coverage_splunk_logger.html
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ help:
@echo " (do this before pushing!)"
@echo " lint: Runs linters as close as github workflow as possible"
@echo " process-templates: Execute the OpenShift CLI to check the templates"
@echo " coverage-report: Run unit tests and generate HTML coverage reports"

$(BUILDDIR)/:
mkdir -p "$@"
Expand Down Expand Up @@ -234,8 +235,18 @@ worker-key-pair: ca
rm /etc/osbuild-composer/worker-csr.pem

.PHONY: unit-tests
.ONESHELL:
unit-tests:
go test -race ./...
go test -race -covermode=atomic -coverprofile=coverage.txt -coverpkg=$(go list ./... | grep -v rpmmd/test$ | tr "\n" ",") ./...
# sub module is not tested automatically
pushd pkg/splunk_logger
go test -race -covermode=atomic -coverprofile=../../coverage_splunk_logger.txt -coverpkg=$(go list ./... | grep -v rpmmd/test$ | tr "\n" ",") ./...
popd

.PHONY: coverage-report
coverage-report: unit-tests
go tool cover -o coverage.html -html coverage.txt
go tool cover -o coverage_splunk_logger.html -html coverage_splunk_logger.txt

#
# Building packages
Expand Down

0 comments on commit 41872bb

Please sign in to comment.