@@ -150,15 +150,10 @@ jobs:
150150 platform :
151151 - amd64
152152 - arm64
153- # arm
154- # ppc64le
155- # s390x
156153 libc :
157154 - gnu
158- include :
159- - platform : amd64
160- libc : musl
161- name : Build (linux)
155+ - musl
156+ name : Build (linux) (${{ matrix.platform }}, ${{ matrix.libc }})
162157 outputs :
163158 GEM_VERSION : ${{ steps.set-metadata.outputs.GEM_VERSION }}
164159 runs-on : ubuntu-24.04
@@ -178,7 +173,14 @@ jobs:
178173 esac
179174 ;;
180175 arm64)
181- echo 'aarch64-linux-gnu'
176+ case ${{ matrix.libc }} in
177+ gnu)
178+ echo 'aarch64-linux-gnu'
179+ ;;
180+ musl)
181+ echo 'aarch64-alpine-linux-musl'
182+ ;;
183+ esac
182184 ;;
183185 esac | tee target_platform
184186 case ${{ matrix.platform }} in
@@ -193,11 +195,22 @@ jobs:
193195 esac
194196 ;;
195197 arm64)
196- echo 'aarch64-linux'
198+ case ${{ matrix.libc }} in
199+ gnu)
200+ echo 'aarch64-linux'
201+ ;;
202+ musl)
203+ echo 'aarch64-linux-musl'
204+ ;;
205+ esac
197206 ;;
198207 esac | tee ruby_target_platform
199208 echo "target_platform=$(cat target_platform)" >> $GITHUB_OUTPUT
200209 echo "ruby_target_platform=$(cat ruby_target_platform)" >> $GITHUB_OUTPUT
210+ - name : Enable ${{ matrix.platform }} platform
211+ if : ${{ matrix.platform != 'amd64' && matrix.libc == 'musl' }}
212+ run : |
213+ docker run --privileged --rm tonistiigi/binfmt:latest --install ${{ matrix.platform }}
201214 - name : Start container
202215 id : container
203216 run : |
@@ -210,7 +223,16 @@ jobs:
210223 ;;
211224 esac | tee container_image
212225 echo "image=$(cat container_image)" >> $GITHUB_OUTPUT
213- docker run --rm -d -v "${PWD}":"${PWD}" -w "${PWD}" --platform linux/amd64 -e RUBY_TARGET_PLATFORM=${{ steps.platform.outputs.ruby_target_platform }} -e TARGET_PLATFORM=${{ steps.platform.outputs.target_platform }} $(cat container_image) /bin/sleep 64d | tee container_id
226+
227+ # use native platform for musl builds (via QEMU if needed)
228+ # use amd64 for gnu builds (cross-compilation is faster)
229+ if [ "${{ matrix.libc }}" = "musl" ]; then
230+ platform="linux/${{ matrix.platform }}"
231+ else
232+ platform="linux/amd64"
233+ fi
234+
235+ docker run --rm -d -v "${PWD}":"${PWD}" -w "${PWD}" --platform "${platform}" -e RUBY_TARGET_PLATFORM=${{ steps.platform.outputs.ruby_target_platform }} -e TARGET_PLATFORM=${{ steps.platform.outputs.target_platform }} $(cat container_image) /bin/sleep 64d | tee container_id
214236 docker exec -w "${PWD}" $(cat container_id) uname -a
215237 echo "id=$(cat container_id)" >> $GITHUB_OUTPUT
216238 - name : Install Alpine system dependencies
@@ -224,7 +246,11 @@ jobs:
224246 - name : Install Debian cross-compiler
225247 if : ${{ matrix.libc == 'gnu' && matrix.platform != 'amd64' }}
226248 run : |
227- docker exec -w "${PWD}" ${{ steps.container.outputs.id }} apt-get install -y binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
249+ case ${{ matrix.platform }} in
250+ arm64)
251+ docker exec -w "${PWD}" ${{ steps.container.outputs.id }} apt-get install -y binutils-aarch64-linux-gnu gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
252+ ;;
253+ esac
228254 - name : Update Rubygems and Bundler
229255 run : |
230256 docker exec -w "${PWD}" ${{ steps.container.outputs.id }} gem update --system
@@ -266,7 +292,7 @@ jobs:
266292 run : |
267293 docker exec -w "${PWD}" ${{ steps.container.outputs.id }} ./libexec/inject-libv8 ${{ steps.set-metadata.outputs.NODE_VERSION }}
268294 - name : Test V8 in C++
269- if : matrix.platform != 'arm64'
295+ if : ${{ matrix.platform == 'amd64' || matrix.libc == 'musl' }}
270296 run : |
271297 docker exec -w "${PWD}" ${{ steps.container.outputs.id }} bash -c "cd test/gtest && cmake -S . -B build && cd build && cmake --build . && ctest"
272298 - name : Build binary gem
@@ -387,10 +413,7 @@ jobs:
387413 - ' 3.4'
388414 platform :
389415 - amd64
390- # arm64
391- # arm
392- # ppc64le
393- # s390x
416+ - arm64
394417 libc :
395418 - gnu
396419 - musl
@@ -404,7 +427,10 @@ jobs:
404427 - version : ' 3.4'
405428 platform : ' arm64'
406429 libc : ' gnu'
407- name : Test (linux)
430+ - version : ' 3.4'
431+ platform : ' arm64'
432+ libc : ' musl'
433+ name : Test (linux) (${{ matrix.platform }}, ${{ matrix.libc }}, ruby ${{ matrix.version }})
408434 needs : build-linux
409435 runs-on : ubuntu-24.04
410436 steps :
@@ -429,7 +455,7 @@ jobs:
429455 echo "id=$(cat container_id)" >> $GITHUB_OUTPUT
430456 - name : Install Alpine system dependencies
431457 if : ${{ matrix.libc == 'musl' }}
432- run : docker exec -w "${PWD}" ${{ steps.container.outputs.id }} apk add --no-cache build-base git libstdc++
458+ run : docker exec -w "${PWD}" ${{ steps.container.outputs.id }} apk add --no-cache build-base git libstdc++ bash
433459 - name : Update Rubygems and Bundler
434460 run : |
435461 docker exec -w "${PWD}" ${{ steps.container.outputs.id }} gem update --system
0 commit comments