Test a library against its downstream consumer in CI by patching the consumer's dependency pin to the commit under test
When to use#
The library has no unit tests of its own, or a change can only be shown to work inside a downstream consumer. Example: cpp-logger's libc bypass under the dftracer GOTCHA preload. Also use it to catch ABI or header breaks before the consumer notices.
Steps#
- Put the logic in scripts under
test/integration/. Run them by hand on a real host first, so the workflow only calls them. - Use a separate workflow that is not a required check. Trigger it on PRs that touch
src/,include/,cmake/orCMakeLists.txt, plus manual runs. Add a cancel-in-progress concurrency group. - Run it in the same base image as the release wheels (
quay.io/pypa/manylinux_2_28_x86_64, glibc 2.28). Installgitbefore the checkout steps so the checkout keeps its.gitdirectory. - Check out the consumer (dftracer
develop) and this repo at${{ github.sha }}. - Patch the consumer's pin (
dependency/manifest.txtanddependency/CMakeLists.txt) to a localfile://<checkout>path. Stop the job if either patch does not apply. A local path works for fork PRs and needs no push. - Build the consumer's dependencies, build it with tests on, and run
ctest. Skip thetest_py_*tests. - Add a probe that fails on the specific bug. Example: log 20 lines through the library under the preload. Fail if the trace holds any logger
fputsorfflushevents, and also fail if the consumer did not trace the probe at all. - In bash probe scripts, guard every
grep -corgrep | wccount.grepexits 1 on no match, so underset -ewithpipefaila zero count kills the script silently. Use|| true. - Run a negative control of the probe against the old library version. This was not done in this session.
Evidence#
"The commit comes from the local checkout, so it works for PRs from forks too and needs no push first." Run on lemur: 63 of 63 dftracer tests passed, and the probe printed log lines=20 traced fopen=1 fputs=0 fflush=0 then OK: logger output bypasses GOTCHA. The first probe version "exited silently when a count was 0, because grep returns 1 on no match and pipefail made that fatal." The job takes about 10 minutes, and a break in consumer develop can fail it. It had not run on GitHub when this was written.