Skip to content

Commit

Permalink
Make it possible to opt out of junit (#950)
Browse files Browse the repository at this point in the history
  • Loading branch information
alenkacz committed Oct 16, 2019
1 parent 432f21a commit 43faa62
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ jobs:
machine: true
steps:
- checkout
- run: echo 'export INTEGRATION_OUTPUT_JUNIT="true"' >> $BASH_ENV
- run: ./test/run_tests.sh
- store_test_results:
path: reports/
Expand Down
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ test:
.PHONY: integration-test
# Run integration tests
integration-test: cli-fast
mkdir -p reports/
go get github.com/jstemmer/go-junit-report
go test -tags integration ./pkg/... ./cmd/... -v -mod=readonly -coverprofile cover-integration.out 2>&1 |tee /dev/fd/2 |go-junit-report -set-exit-code > reports/integration_report.xml
go run ./cmd/kubectl-kudo test 2>&1 |tee /dev/fd/2 |go-junit-report -set-exit-code > reports/kudo_test_report.xml
./hack/run-integration-tests.sh

.PHONY: test-clean
# Clean test reports
Expand Down
20 changes: 20 additions & 0 deletions hack/run-integration-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail

INTEGRATION_OUTPUT_JUNIT=${INTEGRATION_OUTPUT_JUNIT:-false}

if [ "$INTEGRATION_OUTPUT_JUNIT" == true ]
then
echo "Running tests with junit output"
mkdir -p reports/
go get github.com/jstemmer/go-junit-report
go test -tags integration ./pkg/... ./cmd/... -v -mod=readonly -coverprofile cover-integration.out 2>&1 |tee /dev/fd/2 |go-junit-report -set-exit-code > reports/integration_report.xml
go run ./cmd/kubectl-kudo test 2>&1 |tee /dev/fd/2 |go-junit-report -set-exit-code > reports/kudo_test_report.xml
else
echo "Running tests without junit output"
go test -tags integration ./pkg/... ./cmd/... -v -mod=readonly -coverprofile cover-integration.out
go run ./cmd/kubectl-kudo test
fi
1 change: 1 addition & 0 deletions test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ RUN make download
COPY config/ config/
COPY pkg/ pkg/
COPY cmd/ cmd/
COPY hack/run-integration-tests.sh hack/run-integration-tests.sh
COPY test/ test/
COPY kudo-test.yaml kudo-test.yaml

Expand Down
4 changes: 3 additions & 1 deletion test/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ set -o errexit
set -o nounset
set -o pipefail

INTEGRATION_OUTPUT_JUNIT=${INTEGRATION_OUTPUT_JUNIT:-false}

# Pull the builder image with retries if it doesn't already exist.
retries=0
builder_image=$(awk '/FROM/ {print $2}' test/Dockerfile)
Expand All @@ -21,7 +23,7 @@ if ! docker inspect "$builder_image"; then
fi

if docker build -f test/Dockerfile -t kudo-test .; then
if docker run -it -m 4g -v "$(pwd)"/reports:/go/src/github.com/kudobuilder/kudo/reports --rm kudo-test; then
if docker run -e INTEGRATION_OUTPUT_JUNIT -it -m 4g -v "$(pwd)"/reports:/go/src/github.com/kudobuilder/kudo/reports --rm kudo-test; then
echo "Tests finished successfully! ヽ(•‿•)ノ"
else
exit $?
Expand Down

0 comments on commit 43faa62

Please sign in to comment.