Skip to content

Commit

Permalink
CI: add a coverage job
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Jun 26, 2023
1 parent b11bb61 commit 914a6f6
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 1 deletion.
19 changes: 19 additions & 0 deletions .github/workflows/coverage/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

set -eu

export CXXFLAGS="--coverage"
export CFLAGS="--coverage"
export LDFLAGS="-lgcov"

cmake ${GDAL_SOURCE_DIR:=..} \
-DUSE_CCACHE=ON \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX=/usr \
-DGDAL_USE_TIFF_INTERNAL=ON \
-DGDAL_USE_GEOTIFF_INTERNAL=ON \
-DECW_ROOT=/opt/libecwj2-3.3 \
-DMRSID_ROOT=/usr/local \
-DFileGDB_ROOT=/usr/local/FileGDB_API

make -j$(nproc)
23 changes: 23 additions & 0 deletions .github/workflows/coverage/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

set -eu

export OGR_HANA_CONNECTION_STRING='DRIVER=/usr/sap/hdbclient/libodbcHDB.so;HOST=917df316-4e01-4a10-be54-eac1b6ab15fb.hana.prod-us10.hanacloud.ondemand.com;PORT=443;USER=GDALCI;PASSWORD=u7t!Ukeugzq7'

ctest -V -j $(nproc)

lcov --directory . --capture --output-file gdal.info 2>/dev/null
cp gdal.info gdal_filtered.info
lcov --remove gdal_filtered.info '/usr/*' --output-file gdal_filtered.info
lcov --remove gdal_filtered.info '/opt/*' --output-file gdal_filtered.info
lcov --remove gdal_filtered.info '*jpeg/libjpeg*' --output-file gdal_filtered.info
lcov --remove gdal_filtered.info '*pcraster/libcsf*' --output-file gdal_filtered.info
lcov --remove gdal_filtered.info '*googletest-src*' --output-file gdal_filtered.info
genhtml -o ./coverage_html --ignore-errors source --num-spaces 2 gdal_filtered.info >/dev/null

if test "${COVERALLS_REPO_TOKEN:-}" != ""; then
pip install cpp-coveralls
echo "Running git config --global --add safe.directory ${GDAL_SOURCE_DIR}"
git config --global --add safe.directory ${GDAL_SOURCE_DIR}
coveralls -n -l gdal_filtered.info
fi
53 changes: 52 additions & 1 deletion .github/workflows/linux_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
GDAL_SOURCE_DIR: /gdal # Directory to which workspace (source root) will be mounted inside container

permissions:
contents: read
contents: write # for Git to git push
packages: write

strategy:
Expand Down Expand Up @@ -84,6 +84,13 @@ jobs:
build_script: build.sh
test_script: test.sh

- name: Ubuntu 20.04, coverage
id: coverage
travis_branch: ubuntu_2004
container: ubuntu_20.04
build_script: build.sh
test_script: test.sh

- name: Ubuntu 20.04, Intel compiler
id: icc
container: icc
Expand Down Expand Up @@ -248,6 +255,8 @@ jobs:
-e GITHUB_WORKFLOW \
-e TRAVIS \
-e TRAVIS_BRANCH \
-e GDAL_SOURCE_DIR \
-e "COVERALLS_REPO_TOKEN=${{ secrets.COVERALLS_REPO_TOKEN }}" \
--security-opt seccomp=unconfined \
--add-host=host.docker.internal:host-gateway \
--rm \
Expand All @@ -265,3 +274,45 @@ jobs:
run: |
docker push ${CONTAINER_NAME_FULL}
- name: Upload coverage artifacts
uses: actions/upload-artifact@v3
if: ${{ matrix.id }} == 'coverage'
with:
name: coverage_index.html
path: build-${{ matrix.id }}/coverage_html/index.html

- name: Upload coverage artifacts
uses: actions/upload-artifact@v3
if: ${{ matrix.id }} == 'coverage'
with:
name: HTML
path: build-${{ matrix.id }}/coverage_html/*

- name: Deploy ssh key (for coverage)
if: ${{ matrix.id }} == 'coverage' && github.event_name == 'push' && github.ref_name == 'master' && github.repository == 'OSGeo/gdal'
shell: bash -l {0}
run: |
mkdir $HOME/.ssh && echo "${{ secrets.GDAL_TEST_COVERAGE_RESULTS_SSH_KEY }}" > $HOME/.ssh/id_rsa
chmod 700 $HOME/.ssh && chmod 600 $HOME/.ssh/id_rsa
ssh-keyscan -t rsa github.com >> $HOME/.ssh/known_hosts
eval `ssh-agent -s`
ssh-add $HOME/.ssh/id_rsa
- name: Deploy to https://github.com/OSGeo/gdal-test-coverage-results
if: ${{ matrix.id }} == 'coverage' && github.event_name == 'push' && github.ref_name == 'master' && github.repository == 'OSGeo/gdal'
shell: bash -l {0}
run: |
set -x
set -e
mkdir -p output_html/coverage_html
cp -r $GITHUB_WORKSPACE/build-${{ matrix.id }}/coverage_html/* output_html/coverage_html/
cd output_html
git init
git config user.email "[email protected]"
git config user.name "GDAL test coverage results bot"
git remote add origin [email protected]:gdalautotest-coverage-results/gdalautotest-coverage-results.github.io
git remote -v
echo "Results of coverage of GDAL autotest See https://gdalautotest-coverage-results.github.io/coverage_html/index.html" > README.md
git add -A
git commit -m "Update with OSGeo/gdal commit $GITHUB_SHA"
git push -f origin master
1 change: 1 addition & 0 deletions .github/workflows/ubuntu_20.04/Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ RUN apt-get update -y \
curl \
git \
gnupg \
lcov \
libarmadillo-dev \
libblosc-dev \
libboost-dev \
Expand Down

0 comments on commit 914a6f6

Please sign in to comment.