diff --git a/CHANGELOG.md b/CHANGELOG.md index 5190ba033..f3b31f4a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Nothing should go in this section, please add to the latest unreleased version (and update the corresponding date), or add a new version. +## [1.7.16] - 2022-12-27 + ## [1.7.15] - 2022-09-22 ### Security diff --git a/Jenkinsfile b/Jenkinsfile index 23769e205..75f52381c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -102,9 +102,14 @@ pipeline { stage('Unit tests') { steps { sh './bin/test_unit' - sh 'cp ./test/unit-test-output/c.out ./c.out' + } + post { + always { + sh './bin/coverage' + sh 'cp ./test/unit-test-output/c.out ./c.out' - junit 'test/unit-test-output/junit.xml' + junit 'test/unit-test-output/junit.xml' + } } } } diff --git a/bin/coverage b/bin/coverage new file mode 100755 index 000000000..6d4788ed3 --- /dev/null +++ b/bin/coverage @@ -0,0 +1,29 @@ +#!/bin/bash + +set -eo pipefail + +current_dir=$("$(dirname "$0")"/abspath) +toplevel_dir=$current_dir/.. +junit_output_dir=test/unit-test-output + +function main() { + format_output +} + +function format_output() { + # Format output + docker run --rm \ + --volume "$toplevel_dir"/:/secretless \ + --workdir "/secretless/$junit_output_dir" \ + secretless-unit-test-runner:latest \ + sh -exc " + rm -f junit.xml + + # Format test output XML + cat junit.output | go-junit-report > junit.xml + + # Format coverage output XML + gocov convert c.out | gocov-xml > coverage.xml" +} + +main \ No newline at end of file diff --git a/bin/test_unit b/bin/test_unit index 427b08bb9..cc8410c03 100755 --- a/bin/test_unit +++ b/bin/test_unit @@ -12,7 +12,6 @@ function main() { retrieve_cyberark_ca_cert build_ut_docker_image run_unit_tests - format_output } function build_ut_docker_image() { @@ -24,7 +23,6 @@ function build_ut_docker_image() { function run_unit_tests() { echo "Running unit tests..." - set +e mkdir -p "$junit_output_dir" rm -f "$junit_output_dir/*" @@ -46,23 +44,6 @@ function run_unit_tests() { ./pkg/... \ | tee -a "./$junit_output_dir/junit.output" echo "Unit test exit status: $?" - set -e -} - -function format_output() { - # Format output - docker run --rm \ - --volume "$toplevel_dir"/:/secretless \ - --workdir "/secretless/$junit_output_dir" \ - secretless-unit-test-runner:latest \ - sh -exc " - rm -f junit.xml - - # Format test output XML - cat junit.output | go-junit-report > junit.xml - - # Format coverage output XML - gocov convert c.out | gocov-xml > coverage.xml" } main