diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f945a578..92caadd9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -123,6 +123,17 @@ jobs: - uses: actions/checkout@v3 - name: 'Sanitizer Tests' run: build-scripts/test-sanitizers + CodeCov: + runs-on: ubuntu-latest + needs: Prebuild + steps: + - uses: actions/checkout@v3 + - name: 'Code Coverage' + run: build-scripts/test-coverage + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} QuickJobs: runs-on: ubuntu-latest needs: Prebuild diff --git a/README.md b/README.md index 07e1ee03..aac4ef9b 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![QPDF](logo/qpdf.svg)](https://qpdf.sourceforge.io) [![QPDF Build](https://github.com/qpdf/qpdf/workflows/QPDF%20Build/badge.svg)](https://github.com/qpdf/qpdf/actions) +[![codecov](https://codecov.io/gh/qpdf/qpdf/graph/badge.svg?token=ODijhBtAoW)](https://codecov.io/gh/qpdf/qpdf) [![Documentation Status](https://readthedocs.org/projects/qpdf/badge/?version=latest)](https://qpdf.readthedocs.io/en/latest/?badge=latest) QPDF is a command-line tool and C++ library that performs content-preserving transformations on PDF files. It supports linearization, encryption, and numerous other features. It can also be used for splitting and merging files, creating PDF files (but you have to supply all the content yourself), and inspecting files for study or analysis. QPDF does not render PDFs or perform text extraction, and it does not contain higher-level interfaces for working with page contents. It is a low-level tool for working with the structure of PDF files and can be a valuable tool for anyone who wants to do programmatic or command-line-based manipulation of PDF files. diff --git a/build-scripts/test-coverage b/build-scripts/test-coverage new file mode 100755 index 00000000..fc2f2fbd --- /dev/null +++ b/build-scripts/test-coverage @@ -0,0 +1,15 @@ +#!/bin/bash +set -e +sudo apt-get update +sudo apt-get -y install \ + build-essential cmake lcov \ + zlib1g-dev libjpeg-dev libgnutls28-dev libssl-dev +cmake -S . -B build \ + -DCI_MODE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Debug \ + -DREQUIRE_CRYPTO_OPENSSL=1 -DREQUIRE_CRYPTO_GNUTLS=1 \ + -DENABLE_QTC=1 -DENABLE_COVERAGE=ON +cmake --build build --verbose -j$(nproc) -- -k +(cd build; ctest --verbose) +lcov --capture --directory . --output-file coverage.info +lcov --remove coverage.info '/usr/*' --output-file coverage.info +lcov --list coverage.info diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..05cc35f3 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,11 @@ +# When modifying this file, please validate using +# curl -X POST --data-binary @codecov.yml https://codecov.io/validate + +coverage: + status: + project: + default: + informational: true + patch: + default: + informational: true