|
| 1 | +# Generate code coverage report and upload to Codecov. |
| 2 | +name: coverage |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | +permissions: read-all |
| 7 | +jobs: |
| 8 | + coverage_cygwin: |
| 9 | + runs-on: windows-latest |
| 10 | + strategy: |
| 11 | + matrix: |
| 12 | + include: |
| 13 | + - configure_options: '--enable-code-coverage --enable-winapi=yes' |
| 14 | + codecov_name: 'cygwin64-gcc-no-optimization' |
| 15 | + steps: |
| 16 | + - name: Configure git |
| 17 | + run: git config --global core.autocrlf false |
| 18 | + - uses: actions/checkout@v6 |
| 19 | + - name: Install Cygwin and build dependencies |
| 20 | + uses: cygwin/cygwin-install-action@v6 |
| 21 | + with: |
| 22 | + packages: autoconf, automake, curl, gettext-devel, git, libtool, make, mingw-w64-x86_64-gcc, pkg-config |
| 23 | + platform: x86_64 |
| 24 | + add-to-path: true |
| 25 | + - name: Build from source |
| 26 | + shell: bash --login -e -o pipefail -o igncr {0} |
| 27 | + working-directory: ${{ github.workspace }} |
| 28 | + env: |
| 29 | + CHERE_INVOKING: 1 |
| 30 | + CONFIGURE_OPTIONS: ${{ matrix.configure_options }} |
| 31 | + LD: ld |
| 32 | + run: | |
| 33 | + if test -x "synctestdata.sh"; then ./synctestdata.sh; fi |
| 34 | + tests/build.sh ${CONFIGURE_OPTIONS} |
| 35 | + - name: Run tests |
| 36 | + shell: bash --login -e -o pipefail -o igncr {0} |
| 37 | + working-directory: ${{ github.workspace }} |
| 38 | + env: |
| 39 | + CHERE_INVOKING: 1 |
| 40 | + run: | |
| 41 | + tests/runtests.sh |
| 42 | + - name: Generate coverage data |
| 43 | + shell: bash --login -e -o pipefail -o igncr {0} |
| 44 | + working-directory: ${{ github.workspace }} |
| 45 | + env: |
| 46 | + CHERE_INVOKING: 1 |
| 47 | + run: | |
| 48 | + for DIRECTORY in `find . -maxdepth 1 -type d`; do \ |
| 49 | + (cd ${DIRECTORY} && find . -maxdepth 1 -name \*.gcno -type f -exec gcov -pb {} \;) \ |
| 50 | + done |
| 51 | + # Cannot use codecov/codecov-action@v6 given it tries to use cygwin sh and fails. |
| 52 | + - name: Upload coverage report to Codecov |
| 53 | + shell: pwsh |
| 54 | + env: |
| 55 | + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
| 56 | + run: | |
| 57 | + Invoke-WebRequest -Uri "https://cli.codecov.io/latest/windows/codecov.exe" -OutFile "codecov.exe" |
| 58 | + Unblock-File -Path "./codecov.exe" |
| 59 | + ./codecov.exe --verbose upload-coverage --git-service github --gcov-executable gcov --name "${{ matrix.codecov_name }}" |
| 60 | + coverage_linux: |
| 61 | + runs-on: ${{ matrix.os }} |
| 62 | + strategy: |
| 63 | + matrix: |
| 64 | + include: |
| 65 | + - os: ubuntu-24.04 |
| 66 | + compiler: 'gcc' |
| 67 | + configure_options: 'CPPFLAGS=-DHAVE_MEMORY_TESTS=1 --enable-code-coverage' |
| 68 | + codecov_name: 'ubuntu-24.04-gcc-no-optimization' |
| 69 | + steps: |
| 70 | + - uses: actions/checkout@v6 |
| 71 | + - name: Install build dependencies |
| 72 | + run: | |
| 73 | + sudo apt -y install curl autoconf automake autopoint build-essential git libtool pkg-config |
| 74 | + - name: Download test data |
| 75 | + run: | |
| 76 | + if test -x "synctestdata.sh"; then ./synctestdata.sh; fi |
| 77 | + - name: Build from source |
| 78 | + env: |
| 79 | + CC: ${{ matrix.compiler }} |
| 80 | + run: | |
| 81 | + tests/build.sh ${{ matrix.configure_options }} |
| 82 | + - name: Run tests |
| 83 | + run: | |
| 84 | + make check CHECK_WITH_STDERR=1 SKIP_TOOLS_END_TO_END_TESTS=1 |
| 85 | + - name: Generate coverage data |
| 86 | + run: | |
| 87 | + for DIRECTORY in `find . -maxdepth 1 -type d`; do \ |
| 88 | + (cd ${DIRECTORY} && find . -maxdepth 1 -name \*.gcno -type f -exec gcov -pb {} \;) \ |
| 89 | + done |
| 90 | + - name: Upload coverage report to Codecov |
| 91 | + uses: codecov/codecov-action@v6 |
| 92 | + with: |
| 93 | + name: ${{ matrix.codecov_name }} |
| 94 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 95 | + verbose: true |
| 96 | + coverage_mingw: |
| 97 | + runs-on: windows-latest |
| 98 | + strategy: |
| 99 | + matrix: |
| 100 | + include: |
| 101 | + - configure_options: '--enable-code-coverage --enable-winapi=yes' |
| 102 | + codecov_name: 'mingw-w64-gcc-no-optimization' |
| 103 | + steps: |
| 104 | + - uses: actions/checkout@v6 |
| 105 | + - name: Set up MSYS2 with MinGW-w64 |
| 106 | + uses: msys2/setup-msys2@v2 |
| 107 | + with: |
| 108 | + msystem: MINGW64 |
| 109 | + update: true |
| 110 | + install: autoconf automake gettext gettext-devel git libtool make mingw-w64-x86_64-gcc pkg-config |
| 111 | + - name: Build from source |
| 112 | + shell: msys2 {0} |
| 113 | + env: |
| 114 | + CONFIGURE_OPTIONS: ${{ matrix.configure_options }} |
| 115 | + run: | |
| 116 | + if test -x "synctestdata.sh"; then ./synctestdata.sh; fi |
| 117 | + tests/build.sh ${CONFIGURE_OPTIONS} |
| 118 | + - name: Run tests |
| 119 | + shell: msys2 {0} |
| 120 | + run: | |
| 121 | + tests/runtests.sh |
| 122 | + - name: Generate coverage data |
| 123 | + shell: msys2 {0} |
| 124 | + run: | |
| 125 | + for DIRECTORY in `find . -maxdepth 1 -type d`; do \ |
| 126 | + (cd ${DIRECTORY} && find . -maxdepth 1 -name \*.gcno -type f -exec gcov -pb {} \;) \ |
| 127 | + done |
| 128 | + - name: Upload coverage report to Codecov |
| 129 | + uses: codecov/codecov-action@v6 |
| 130 | + with: |
| 131 | + name: ${{ matrix.codecov_name }} |
| 132 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 133 | + verbose: true |
0 commit comments