Skip to content

Commit

Permalink
Build: publish junit style reports
Browse files Browse the repository at this point in the history
  • Loading branch information
jlsherrill committed Nov 8, 2024
1 parent 398a3d2 commit a6aa651
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/content-sources-actions.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
name: build-test
permissions:
checks: write
contents: read
on:
push:
branches:
Expand Down Expand Up @@ -100,10 +103,14 @@ jobs:
- uses: actions/setup-go@v2
with:
go-version: "1.23"
- name: Grab junit dep
run: |
go install github.com/jstemmer/go-junit-report/v2@latest
- name: unit tests
run: |
make get-deps ${PWD}/release/dbmigrate db-migrate-up test-unit
env:
JUNIT: y
DATABASE_HOST: localhost
DATABASE_PORT: 5433
DATABASE_USER: postgres
Expand Down Expand Up @@ -150,6 +157,7 @@ jobs:
go run cmd/candlepin/main.go init
make test-integration
env:
JUNIT: y
DATABASE_HOST: localhost
DATABASE_PORT: 5433
DATABASE_USER: postgres
Expand Down Expand Up @@ -179,3 +187,8 @@ jobs:
CLIENTS_PULP_SERVER: http://localhost:8080
CLIENTS_PULP_USERNAME: admin
CLIENTS_PULP_PASSWORD: password
- name: Publish Test Report
uses: mikepenz/action-junit-report@v5
if: success() || failure() # always run even if the previous step fails
with:
report_paths: 'report*.xml'
11 changes: 9 additions & 2 deletions mk/go-rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ else
MOD_VENDOR ?= -mod vendor
endif

ifeq (y,$(JUNIT))
JUNIT_UNIT_COMMAND ?= | go-junit-report -iocopy -set-exit-code -out report_unit.xml
JUNIT_INTEGRATION_COMMAND ?= | go-junit-report -iocopy -set-exit-code -out report_integ.xml
endif



# Meta rule to add dependency on the binaries generated
.PHONY: build
build: $(patsubst cmd/%,$(GO_OUTPUT)/%,$(wildcard cmd/*)) ## Build binaries
Expand Down Expand Up @@ -46,11 +53,11 @@ test: test-unit test-integration

.PHONY: test-unit
test-unit: ## Run tests for ci
CONFIG_PATH="$(PROJECT_DIR)/configs/" go test $(MOD_VENDOR) ./pkg/...
CONFIG_PATH="$(PROJECT_DIR)/configs/" go test $(MOD_VENDOR) ./pkg/... $(JUNIT_UNIT_COMMAND)

.PHONY: test-integration
test-integration: ## Run tests for ci
CONFIG_PATH="$(PROJECT_DIR)/configs/" go test $(MOD_VENDOR) ./test/integration/...
CONFIG_PATH="$(PROJECT_DIR)/configs/" go test $(MOD_VENDOR) ./test/integration/... $(JUNIT_INTEGRATION_COMMAND)

DB_CONNECT_INFO := dbname=$(DATABASE_NAME) sslmode=disable user=$(DATABASE_USER) host=$(DATABASE_HOST) password=$(DATABASE_PASSWORD)
.PHONY: test-db-migrations
Expand Down

0 comments on commit a6aa651

Please sign in to comment.