Skip to content

Commit 71612ad

Browse files
fentasclaude
andcommitted
fix(ci): use docker run for musl builds (Alpine container JS bug on arm64)
GitHub Actions JS actions (checkout, upload-artifact) don't work inside Alpine containers on arm64 runners. Use docker run instead of container: to keep the runner native while building inside Alpine. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c4a3bea commit 71612ad

2 files changed

Lines changed: 23 additions & 20 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ jobs:
7070
rust-musl:
7171
name: Rust (musl-${{ matrix.arch }})
7272
runs-on: ${{ matrix.runner }}
73-
container: alpine:latest
7473
strategy:
7574
matrix:
7675
include:
@@ -80,10 +79,12 @@ jobs:
8079
runner: ubuntu-24.04-arm
8180
steps:
8281
- uses: actions/checkout@v6
83-
- name: Install build tools
84-
run: apk add --no-cache rust cargo musl-dev
85-
- name: Build (musl)
86-
run: cargo build --release
82+
- name: Build in Alpine container
83+
run: |
84+
docker run --rm -v "$PWD:/src" -w /src alpine:latest sh -c '
85+
apk add --no-cache rust cargo musl-dev
86+
cargo build --release
87+
'
8788
- name: Upload .so
8889
uses: actions/upload-artifact@v7
8990
with:

.github/workflows/publish.yaml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,64 +46,66 @@ jobs:
4646
name: Build ${{ matrix.variant }}-${{ matrix.arch }}
4747
runs-on: ${{ matrix.runner }}
4848
needs: [meta]
49-
container: ${{ matrix.container || '' }}
5049
strategy:
5150
matrix:
5251
include:
5352
- arch: amd64
5453
runner: ubuntu-latest
5554
target: x86_64-unknown-linux-gnu
5655
variant: linux
56+
musl: false
5757
- arch: arm64
5858
runner: ubuntu-24.04-arm
5959
target: aarch64-unknown-linux-gnu
6060
variant: linux
61+
musl: false
6162
- arch: amd64
6263
runner: ubuntu-latest
6364
variant: linux-musl
64-
container: alpine:latest
65+
musl: true
6566
- arch: arm64
6667
runner: ubuntu-24.04-arm
6768
variant: linux-musl
68-
container: alpine:latest
69+
musl: true
6970
steps:
7071
- uses: actions/checkout@v6
7172
- name: Check if lib has a builtin
7273
id: check
7374
run: |
7475
lib="${{ needs.meta.outputs.lib }}"
75-
if [ -d "${lib}-builtin" ]; then
76+
if [[ -d "${lib}-builtin" ]]; then
7677
echo "has_builtin=true" >> "${GITHUB_OUTPUT}"
7778
else
7879
echo "has_builtin=false" >> "${GITHUB_OUTPUT}"
7980
fi
8081
# glibc builds
8182
- uses: dtolnay/rust-toolchain@stable
82-
if: steps.check.outputs.has_builtin == 'true' && !matrix.container
83+
if: steps.check.outputs.has_builtin == 'true' && !matrix.musl
8384
with:
8485
targets: ${{ matrix.target }}
8586
- uses: Swatinem/rust-cache@v2
86-
if: steps.check.outputs.has_builtin == 'true' && !matrix.container
87+
if: steps.check.outputs.has_builtin == 'true' && !matrix.musl
8788
with:
8889
shared-key: publish-${{ matrix.variant }}-${{ matrix.arch }}
8990
- name: Build (glibc)
90-
if: steps.check.outputs.has_builtin == 'true' && !matrix.container
91+
if: steps.check.outputs.has_builtin == 'true' && !matrix.musl
9192
run: cargo build --release --target ${{ matrix.target }}
9293
- name: Rename .so (glibc)
93-
if: steps.check.outputs.has_builtin == 'true' && !matrix.container
94+
if: steps.check.outputs.has_builtin == 'true' && !matrix.musl
9495
run: |
9596
lib="${{ needs.meta.outputs.lib }}"
9697
cp "target/${{ matrix.target }}/release/lib${lib}.so" \
9798
"${lib}-${{ matrix.variant }}-${{ matrix.arch }}.so"
98-
# musl builds (Alpine container)
99-
- name: Install build tools (musl)
100-
if: steps.check.outputs.has_builtin == 'true' && matrix.container
101-
run: apk add --no-cache rust cargo musl-dev
99+
# musl builds (docker run Alpine — avoids container: alpine JS action bug on arm64)
102100
- name: Build (musl)
103-
if: steps.check.outputs.has_builtin == 'true' && matrix.container
104-
run: cargo build --release
101+
if: steps.check.outputs.has_builtin == 'true' && matrix.musl
102+
run: |
103+
docker run --rm -v "$PWD:/src" -w /src alpine:latest sh -c '
104+
apk add --no-cache rust cargo musl-dev
105+
cargo build --release
106+
'
105107
- name: Rename .so (musl)
106-
if: steps.check.outputs.has_builtin == 'true' && matrix.container
108+
if: steps.check.outputs.has_builtin == 'true' && matrix.musl
107109
run: |
108110
lib="${{ needs.meta.outputs.lib }}"
109111
cp "target/release/lib${lib}.so" \

0 commit comments

Comments
 (0)