1+ # CI Strategy: Comprehensive Testing of Build and Precompiled Flows
2+ #
3+ # This workflow tests both compilation-from-source and precompiled binary distribution
4+ # strategies across multiple Ubuntu and Ruby versions to ensure broad compatibility and
5+ # reliability.
6+ #
7+ # WHY WE TEST BOTH UBUNTU 22.04 AND 24.04:
8+ # - Different system library versions (OpenSSL, zlib, libsasl2, libzstd, etc.)
9+ # - Different GCC compiler versions that affect native extension compilation
10+ # - Different glibc versions that can impact binary compatibility
11+ # - Real-world deployment scenarios where users run on various Ubuntu LTS versions
12+ # - Different Ruby versions
13+ #
14+ # COMPILATION FLOW (build_install + specs_install):
15+ # - Tests that librdkafka compiles correctly from source on each Ubuntu version
16+ # - Validates that mini_portile2 can successfully build native dependencies
17+ # - Ensures Ruby native extensions link properly with system libraries
18+ # - Verifies that the same codebase works across different toolchain versions
19+ #
20+ # PRECOMPILED FLOW (build_precompiled + specs_precompiled):
21+ # - Tests our precompiled static libraries work on different Ubuntu versions
22+ # - Validates that statically-linked binaries are truly portable across environments
23+ # - Ensures precompiled libraries don't have unexpected system dependencies
24+ # - Verifies that removing build tools doesn't break precompiled binary usage
25+ #
26+ # ARTIFACT ISOLATION:
27+ # - Each Ubuntu version gets separate artifacts (rdkafka-built-gem-22.04, etc.)
28+ # - Prevents cross-contamination of OS-specific compiled extensions
29+ # - Ensures test accuracy by matching build and test environments
30+ #
31+ # This comprehensive approach catches issues that single-platform testing would miss,
32+ # such as system library incompatibilities, compiler-specific bugs, or static linking
33+ # problems that only manifest on specific Ubuntu versions.
34+
135name : CI Linux x86_64 GNU
236
337concurrency :
2054 BUNDLE_JOBS : 4
2155
2256jobs :
23- build_install :
24- timeout-minutes : 30
25- runs-on : ubuntu-latest
26- steps :
27- - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
28- with :
29- fetch-depth : 0
30- - name : Install package dependencies
31- run : " [ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS"
32- - name : Set up Ruby
33- uses : ruby/setup-ruby@a4effe49ee8ee5b8b5091268c473a4628afb5651 # v1.245.0
34- with :
35- ruby-version : ' 3.4' # Use one Ruby version for building
36- bundler-cache : false
37- - name : Build gem with mini_portile
38- run : |
39- set -e
40- bundle install
41- cd ext && bundle exec rake
42- cd ..
43- - name : Upload built gem and bundle
44- uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
45- with :
46- name : rdkafka-built-gem
47- path : |
48- vendor/bundle/
49- .bundle/
50- ext/
51- lib/
52- retention-days : 1
53-
5457 specs_install :
5558 timeout-minutes : 30
56- runs-on : ubuntu-latest
57- needs : build_install
5859 strategy :
5960 fail-fast : false
6061 matrix :
@@ -65,20 +66,17 @@ jobs:
6566 - ' 3.2'
6667 - ' 3.1'
6768 - ' jruby-10.0'
69+ ubuntu-version : ['22.04', '24.04']
6870 include :
6971 - ruby : ' 3.4'
7072 coverage : ' true'
7173 - ruby : ' jruby-10.0'
7274 continue-on-error : true
75+ runs-on : ubuntu-${{ matrix.ubuntu-version }}
7376 steps :
7477 - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
7578 with :
7679 fetch-depth : 0
77- - name : Download built gem
78- uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
79- with :
80- name : rdkafka-built-gem
81- path : ./
8280 - name : Set up Ruby
8381 uses : ruby/setup-ruby@a4effe49ee8ee5b8b5091268c473a4628afb5651 # v1.245.0
8482 with :
@@ -108,12 +106,17 @@ jobs:
108106 echo "Sleeping 2 seconds..."
109107 sleep 2
110108 done
111- - name : Install remaining dependencies
109+ - name : Install dependencies
112110 env :
113111 RDKAFKA_EXT_PATH : ${{ github.workspace }}/ext
114112 run : |
115113 # Only install gems that aren't Ruby-version specific
116114 bundle install
115+ - name : Build gem with mini_portile
116+ run : |
117+ set -e
118+ cd ext && bundle exec rake
119+ cd ..
117120 - name : Run all specs
118121 env :
119122 GITHUB_COVERAGE : ${{matrix.coverage}}
@@ -124,7 +127,10 @@ jobs:
124127
125128 build_precompiled :
126129 timeout-minutes : 30
127- runs-on : ubuntu-latest
130+ # We precompile on older Ubuntu and check compatibility by running specs since we aim to
131+ # release only one precompiled version for all supported Ubuntu versions
132+ # This is why we do not want Renovate to update it automatically
133+ runs-on : ubuntu-22.04 # renovate: ignore
128134 steps :
129135 - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
130136 with :
@@ -135,15 +141,29 @@ jobs:
135141 sudo apt-get install -y --no-install-recommends \
136142 build-essential \
137143 gcc \
144+ g++ \
138145 make \
139- patch \
140146 tar \
147+ gzip \
141148 wget \
149+ curl \
150+ file \
151+ pkg-config \
152+ autoconf \
153+ automake \
154+ libtool \
155+ python3 \
156+ git \
142157 ca-certificates \
158+ patch \
143159 libsasl2-dev \
144160 libssl-dev \
145161 zlib1g-dev \
146- libzstd-dev
162+ libzstd-dev \
163+ bison \
164+ flex \
165+ perl \
166+ binutils-dev
147167 - name : Cache build-tmp directory
148168 uses : actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
149169 with :
@@ -162,7 +182,6 @@ jobs:
162182
163183 specs_precompiled :
164184 timeout-minutes : 30
165- runs-on : ubuntu-latest
166185 needs : build_precompiled
167186 strategy :
168187 fail-fast : false
@@ -173,9 +192,13 @@ jobs:
173192 - ' 3.3'
174193 - ' 3.2'
175194 - ' 3.1'
195+ ubuntu-version : ['22.04', '24.04']
176196 include :
177197 - ruby : ' 3.4'
198+ ubuntu-version : ' 24.04'
178199 coverage : ' true'
200+
201+ runs-on : ubuntu-${{ matrix.ubuntu-version }}
179202 steps :
180203 - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
181204 with :
@@ -199,7 +222,6 @@ jobs:
199222
200223 echo "=== Container status ==="
201224 docker compose ps kafka
202-
203225 for i in {1..30}; do
204226 echo "=== Attempt $i/30 ==="
205227
0 commit comments