rsyslog/.github/workflows/run_codecov_kafka.yml
Rainer Gerhards e1bb712923
CI: enable pushing to Codecov for main branch push
This usually happens by merging. It is important because it sets
the baseline for codecov reports.
2025-09-09 14:37:37 +02:00

177 lines
5.1 KiB
YAML

---
name: codecov kafka
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
on:
push:
branches: [ main ]
pull_request:
paths:
- '**/*.c'
- '**/*.h'
- 'grammar/lexer.l'
- 'grammar/grammar.y'
- 'tests/*.sh'
- 'diag.sh'
- '**/Makefile.am'
- 'configure.ac'
- '.github/workflows/run_codecov_kafka.yml'
jobs:
CI:
runs-on: ubuntu-24.04
timeout-minutes: 25
steps:
- name: hosts
run: |
cat -n /etc/hosts
echo resetting
sudo bash -c 'echo "127.0.0.1 localhost" > /etc/hosts'
cat -n /etc/hosts
- name: add extra dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
lcov \
autoconf-archive \
gdb \
faketime \
libgcrypt20-dev \
libgnutls28-dev \
libnet1-dev \
libsasl2-dev \
libsystemd-dev \
libtirpc-dev \
libtool-bin \
uuid-dev \
valgrind \
libestr-dev \
librdkafka-dev \
libfastjson-dev \
librelp-dev \
liblognorm-dev \
kcat
- name: git checkout project
uses: actions/checkout@v4
# NEW: cache Autotools feature-probe results
- name: cache configure results
uses: actions/cache@v4
with:
path: config.cache
key: >
cfgcache-${{ runner.os }}-${{ runner.arch }}-gcc14
-cfg-${{ hashFiles('configure.ac','m4/**','**/Makefile.am') }}
-flags--g-O0--coverage
restore-keys: |
cfgcache-${{ runner.os }}-${{ runner.arch }}-gcc14-
cfgcache-${{ runner.os }}-${{ runner.arch }}-
- name: enable coverage flags
run: |
echo 'CFLAGS=-g -O0 --coverage' >> "$GITHUB_ENV"
echo 'LDFLAGS=--coverage' >> "$GITHUB_ENV"
- name: prepare for build
env:
CFLAGS: ${{ env.CFLAGS }}
LDFLAGS: ${{ env.LDFLAGS }}
run: |
autoreconf -fvi
./configure \
--cache-file=config.cache \
--enable-compile-warning=error \
--enable-testbench \
--enable-omstdout \
--enable-imdiag \
--disable-generate-man-pages \
--disable-impstats \
--enable-imfile \
--disable-imfile-tests \
--disable-fmhttp \
--enable-valgrind \
--enable-valgrind-testbench \
--disable-helgrind \
--disable-default-tests \
--disable-imtcp-tests \
--enable-omkafka \
--enable-gnutls \
--disable-gnutls-tests \
--enable-kafka-tests \
--enable-imkafka
- name: build
env:
CFLAGS: ${{ env.CFLAGS }}
LDFLAGS: ${{ env.LDFLAGS }}
run: make -j10
- name: make check
env:
CFLAGS: ${{ env.CFLAGS }}
LDFLAGS: ${{ env.LDFLAGS }}
run: make -j3 check
- name: show all logs
run: |
cat -n tests/*.log
- name: show error logs (if we errored)
if: ${{ failure() || cancelled() }}
run: |
devtools/gather-check-logs.sh
cat failed-tests.log
- name: generate coverage (lcov)
if: ${{ always() }}
run: |
lcov --capture --directory . \
--rc geninfo_unexecuted_blocks=1 \
--ignore-errors mismatch \
--output-file coverage.raw.info
lcov --remove coverage.raw.info '/usr/*' '*/tests/*' -o coverage.info || true
rm -f coverage.raw.info
lcov --list coverage.info | sed -n '1,60p' || true
[ -s coverage.info ] || { echo "coverage.info is empty"; exit 1; }
# Push to protected branches -> needs token
- name: Upload coverage to Codecov (push)
if: ${{ always() && github.event_name == 'push' }}
uses: codecov/codecov-action@v4
with:
files: coverage.info
token: ${{ secrets.CODECOV_TOKEN }}
flags: main
fail_ci_if_error: false
# Same-repo PRs: use org/repo secret (protected branches need token)
- name: Upload coverage to Codecov (internal)
if: ${{ always() && github.event.pull_request.head.repo.full_name == github.repository }}
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.info
flags: kafka
fail_ci_if_error: false
- name: Upload coverage to Codecov (fork PR)
if: ${{ always() && github.event.pull_request.head.repo.full_name != github.repository }}
uses: codecov/codecov-action@v4
with:
files: coverage.info
flags: kafka
fail_ci_if_error: false
# Forked PRs: tokenless upload
- name: show error logs (if we errored)
#if: ${{ failure() || cancelled() }}
run: |
devtools/gather-check-logs.sh
cat failed-tests.log