diff --git a/.ci/publish_coverage.sh b/.ci/publish_coverage.sh new file mode 100755 index 0000000000..36c9301f51 --- /dev/null +++ b/.ci/publish_coverage.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +set -e + +trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG +trap 'echo "$0: \"${last_command}\" command failed with exit code $?"' ERR + +ARTIFACT_FOLDER=$1 + +# are there any coverage files? + +ARGS="" + +for file in `ls $ARTIFACT_FOLDER`; do + + ARGS="-a ${ARTIFACT_FOLDER}/${file}" + +done + +lcov $ARGS --output-file /tmp/coverage.info + +genhtml -o /tmp/coverage_html /tmp/coverage.info | tee /tmp/coverage.log + +COVERAGE_PCT=`cat /tmp/coverage.log | tail -n 1 | awk '{print $2}'` + +echo "Coverage: $COVERAGE_PCT" diff --git a/.ci/test.sh b/.ci/test.sh index 25ecf8c269..050da0b173 100755 --- a/.ci/test.sh +++ b/.ci/test.sh @@ -78,5 +78,5 @@ echo "$0: tests finished" echo "$0: storing coverage data" lcov --capture --directory ${WORKSPACE} --output-file /tmp/coverage.original -[ -e /tmp/coverage.original ] && lcov --remove /tmp/coverage.original "*/test/" --output-file /tmp/coverage.removed -[ -e /tmp/coverage.removed ] && lcov --extract /tmp/coverage.removed "*/${WORKSPACE}/*" --output-file $ARTIFACT_FOLDER/$REPOSITORY_NAME.info +lcov --remove /tmp/coverage.original "*/test/" --output-file /tmp/coverage.removed || echo "$0: coverage tracefile is empty" +lcov --extract /tmp/coverage.removed "*/${WORKSPACE}/*" --output-file $ARTIFACT_FOLDER/$REPOSITORY_NAME.info || echo "$0: coverage tracefile is empty" diff --git a/.github/workflows/rostest_to_release_coverage.yml b/.github/workflows/rostest_to_release_coverage.yml index a353469a7d..c3e0f9fab7 100644 --- a/.github/workflows/rostest_to_release_coverage.yml +++ b/.github/workflows/rostest_to_release_coverage.yml @@ -105,3 +105,10 @@ jobs: run: | ls -la /tmp/artifacts .ci/publish_coverage.sh /tmp/artifacts + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: /tmp/coverage_html + allow_empty_commit: true + force_orphan: true