Skip to content

Commit

Permalink
#32: make ci action decide to activate coverage for the first image
Browse files Browse the repository at this point in the history
  • Loading branch information
tlamonthezie committed Jul 23, 2024
1 parent c6cf7df commit 975cd0f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- ubuntu_22.04-clang_14-vtk_9.2.2-py_3.8
env:
OUTPUT_DIR: '/tmp/artifacts'
VT_TV_COVERAGE_ENABLED: ${{ matrix.image == 'ubuntu_22.04-gcc_11-vtk_9.2.2-py_3.8' && 'ON' || 'OFF' }}
name: vt-tv build and test
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -51,6 +52,7 @@ jobs:
file: ./ci/docker/build-and-test.dockerfile
build-args: |
BASE_IMAGE=pierrpebay/vt-tv:${{ matrix.image }}
VT_TV_COVERAGE_ENABLED=${{ env.VT_TV_COVERAGE_ENABLED }}
outputs: type=local,dest=${{ env.OUTPUT_DIR }}

- name: Upload artifacts
Expand All @@ -70,7 +72,7 @@ jobs:
output-to: step-summary

- name: Coverage
if: contains(${{matrix.image }}, "gcc_11")
if: ${{ env.VT_TV_COVERAGE_ENABLED == 'ON' }}
run: |
echo '## Coverage' >> $GITHUB_STEP_SUMMARY
echo '```shell' >> $GITHUB_STEP_SUMMARY
Expand Down
5 changes: 3 additions & 2 deletions ci/docker/build-and-test.dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
ARG BASE_IMAGE=pierrpebay/vt-tv:ubuntu_22.04-gcc_11-vtk_9.2.2-py_3.8
ARG VT_TV_COVERAGE_ENABLED=OFF

FROM ${BASE_IMAGE} AS base

ENV VT_TV_COVERAGE_ENABLED=$VT_TV_COVERAGE_ENABLED

# setup requirements for rendering tests (xvfb) + coverage report (lcov)
RUN apt-get update && apt-get install -y \
xvfb \
Expand All @@ -11,8 +14,6 @@ COPY . /opt/src/vt-tv
RUN mkdir -p /opt/build/vt-tv

# Build
FROM base AS build
RUN bash -c 'if [[ "$CC" == "/usr/bin/gcc-11" ]]; then export VT_TV_COVERAGE_ENABLED=ON; fi'
RUN /opt/src/vt-tv/ci/build.sh

# Unit tests
Expand Down
37 changes: 19 additions & 18 deletions ci/test_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,25 @@ cat /opt/build/vt-tv/Testing/Temporary/LastTest.log
[ -f "/opt/src/vt-tv/output/test-render/ccm_example0.png" ] && cp "/opt/src/vt-tv/output/test-render/ccm_example0.png" /tmp/artifacts/

# coverage reporting
pushd /opt/src/vt-tv/output
lcov --capture --directory /opt/build/vt-tv --output-file lcov_vt-tv_test.info
lcov --remove lcov_vt-tv_test.info -o lcov_vt-tv_test_no_deps.info '*/lib/*' '/usr/include/*' '*/vtk/*' '*/tests/*'
lcov --list lcov_vt-tv_test_no_deps.info
# add simple coverage artifact
lcov --list lcov_vt-tv_test_no_deps.info > lcov-list-report.txt
cp lcov_vt-tv_test_no_deps.info /tmp/artifacts/
cp /opt/src/vt-tv/output/lcov-list-report.txt /tmp/artifacts/

# extract total coverage (Lines) for later use in a badge in the CI
LCOV_SUMMARY=$(lcov --summary lcov_vt-tv_test_no_deps.info)
LCOV_TOTAL_LINES_COV=$(echo $LCOV_SUMMARY | grep -E -o 'lines......: ([0-9.]+)*' | grep -o -E '[0-9]+.[0-9]+')
echo $LCOV_TOTAL_LINES_COV > lcov-lines-total.txt
cp /opt/src/vt-tv/output/lcov-lines-total.txt /tmp/artifacts/

ls /tmp/artifacts

popd
if [[ $VT_TV_COVERAGE_ENABLED=="ON" ]]; then
pushd /opt/src/vt-tv/output
lcov --capture --directory /opt/build/vt-tv --output-file lcov_vt-tv_test.info
lcov --remove lcov_vt-tv_test.info -o lcov_vt-tv_test_no_deps.info '*/lib/*' '/usr/include/*' '*/vtk/*' '*/tests/*'
lcov --list lcov_vt-tv_test_no_deps.info
# add simple coverage artifact
lcov --list lcov_vt-tv_test_no_deps.info > lcov-list-report.txt
cp lcov_vt-tv_test_no_deps.info /tmp/artifacts/
cp /opt/src/vt-tv/output/lcov-list-report.txt /tmp/artifacts/

# extract total coverage (Lines) for later use in a badge in the CI
LCOV_SUMMARY=$(lcov --summary lcov_vt-tv_test_no_deps.info)
LCOV_TOTAL_LINES_COV=$(echo $LCOV_SUMMARY | grep -E -o 'lines......: ([0-9.]+)*' | grep -o -E '[0-9]+.[0-9]+')
echo $LCOV_TOTAL_LINES_COV > lcov-lines-total.txt
cp /opt/src/vt-tv/output/lcov-lines-total.txt /tmp/artifacts/

ls /tmp/artifacts
popd
fi

popd

Expand Down

0 comments on commit 975cd0f

Please sign in to comment.