diff --git a/.github/workflows/content-sources-actions.yml b/.github/workflows/content-sources-actions.yml index 00edfca4d..2cc03ca8c 100644 --- a/.github/workflows/content-sources-actions.yml +++ b/.github/workflows/content-sources-actions.yml @@ -1,4 +1,7 @@ name: build-test +permissions: + checks: write + contents: read on: push: branches: @@ -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 @@ -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 @@ -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' diff --git a/mk/go-rules.mk b/mk/go-rules.mk index e8c13e83f..db419a9b2 100644 --- a/mk/go-rules.mk +++ b/mk/go-rules.mk @@ -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 @@ -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