Skip to content
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

Convert test coverage report to junit format #1148

Merged
merged 15 commits into from
Sep 26, 2024
65 changes: 65 additions & 0 deletions .github/workflows/test-reporting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
name: Generate junit test report

on: # yamllint disable-line rule:truthy
pull_request: # yamllint disable-line rule:empty-values
push:
branches: [devel]

env:
DESIRED_GO_VERSION: '1.20'

jobs:
go_test_coverage:
name: go test coverage
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.DESIRED_GO_VERSION }}

- name: build and install receptor
run: |
make build-all
sudo cp ./receptor /usr/local/bin/receptor

- name: Download kind binary
run: curl -Lo ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64 && chmod +x ./kind

- name: Create k8s cluster
run: ./kind create cluster

- name: Interact with the cluster
run: kubectl get nodes

- name: Run receptor tests with coverage
Copy link
Contributor

@AaronH88 AaronH88 Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe something like this?:

  - name: Install go junit reporting
    run: make go-junit-report

  - name: Run receptor tests
    run: PATH="${PWD}:${PATH}" go test -v 2>&1 ./... | go-junit-report -set-exit-code > report.xml

run: make coverage -v 2>&1 ./... | go-junit-report -set-exit-code > report.xml

- name: get k8s logs
if: ${{ failure() }}
run: .github/workflows/artifact-k8s-logs.sh

- name: remove sockets before archiving logs
if: ${{ failure() }}
run: find /tmp/receptor-testing -name controlsock -delete

- name: Artifact receptor data
uses: actions/upload-artifact@v4.4.0
if: ${{ failure() }}
with:
name: test-logs
path: /tmp/receptor-testing

- name: Archive receptor binary
uses: actions/upload-artifact@v4.4.0
with:
name: receptor
path: /usr/local/bin/receptor
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,20 @@ build-package:
cd dist/ && \
$(CHECKSUM_PROGRAM) $(DIST).tar.gz >> checksums.txt

GO-JUNIT-REPORT = $(shell pwd)/go-junit-report
go-junit-report: ## Download go-junit-report locally if necessary.
ifeq (,$(wildcard $(GO-JUNIT-REPORT)))
ifeq (,$(shell which go-junit-report 2>/dev/null))
@{ \
set -e ;\
mkdir -p $(dir $(GO-JUNIT-REPORT)) ;\
GOBIN=$(dir $(GO-JUNIT-REPORT)) go install github.com/jstemmer/go-junit-report/v2@latest;\
}
else
GO-JUNIT-REPORT = $(shell which go-junit-report)
endif
endif

RUNTEST ?=
ifeq ($(RUNTEST),)
TESTCMD =
Expand Down Expand Up @@ -227,4 +241,4 @@ tc-image: container
@cp receptor packaging/tc-image/
@$(CONTAINERCMD) build packaging/tc-image -t receptor-tc

.PHONY: lint format fmt pre-commit build-all test clean testloop container version receptorctl-tests kubetest
.PHONY: lint format fmt pre-commit build-all test clean testloop container version receptorctl-tests kubetest go-junit-report
Loading