Skip to content

Build on Alpine Linux (Chroot) #106

Build on Alpine Linux (Chroot)

Build on Alpine Linux (Chroot) #106

Workflow file for this run

# .github/workflows/alpine.yaml
name: Build on Alpine Linux (Chroot)
on:
workflow_dispatch: NULL
jobs:
alpine-build:
name: Build on Alpine Linux for ${{matrix.target.guest}} with ${{matrix.compiler.GCC}}
strategy:
fail-fast: FALSE
matrix:
#target: [ # empty MARCH is always sufficient (just by chance) --- TODO: add using -arm host!
# x86_64, x86, aarch64, armhf, ppc64le, armv7, riscv64, loongarch64, s390x
#]
target:
- { guest: x86_64 }
- { guest: x86 }
- { guest: aarch64, host: '-arm' }
- { guest: armhf, host: '-arm' }
- { guest: ppc64le, qemu: TRUE }
- { guest: armv7, host: -arm, march: '-mthumb' }
- { guest: riscv64, qemu: TRUE }
- { guest: loongarch64, qemu: TRUE }
- { guest: s390x, qemu: TRUE }
compiler:
- { label: gcc, apk: g++, gcc: gcc, gxx: g++ }
- { label: clang16, apk: clang16, gcc: clang-16, gxx: clang++-16 }
- { label: clang18, apk: clang18, gcc: clang-18, gxx: clang++-18 }
- { label: clang19, apk: clang19, gcc: clang-19, gxx: clang++-19 }
- { label: clang20, apk: clang20, gcc: clang-20, gxx: clang++-20 }
# clang15 (partial), clang17
runs-on: ubuntu-2${{matrix.target.guest == 'loongarch64' && '4' || '2'}}.04${{matrix.target.host}}
defaults:
run: { shell: bash }
steps:
- name: Machine Information
run: |
exec 2>&1
set -x
lscpu; free -h; df -H .
- name: System Information
run: |
exec 2>&1
date; uname -a; uptime
set -x
systemd-detect-virt || :
cat /etc/os-release
ls -C /boot || :
- name: Context Information
run: |
exec 2>&1
tty || :; id; printf %s\\n SHELL="$SHELL" PATH="$PATH"
set -x
pwd
ps -eH --sort pid -o pid,user:12,group:12,comm:24,rsz,vsz,thcount,bsdstart,state,tname
- name: Host Setup
if: (matrix.target.qemu)
run: |
exec 2>&1
set -x
sudo sed -i /azure/d /etc/apt/apt-mirrors.txt
sudo apt-get update
sudo apt-get install qemu-user-static
- name: Chroot Setup
run: |
exec 2>&1
(set -x; wget --no-show-progress -O- \
https://dl-cdn.alpinelinux.org/alpine/v3.22/releases/${{matrix.target.guest}}/alpine-minirootfs-3.22.2-${{matrix.target.guest}}.tar.gz) |
(set -x; sudo mkdir /srv/alpine; sudo tar xz -C /srv/alpine)
(for d in dev proc sys; do (set -x; sudo mount -R -r {,/srv/alpine}/"$d") done)
(for d in run tmp; do (set -x; sudo mount {-t,}tmpfs /srv/alpine/"$d") done; set -x; sudo chmod 1777 /srv/alpine/tmp)
(set -x; sudo cp -L /etc/resolv.conf /srv/alpine/etc)
sudo chroot /srv/alpine /bin/su - <<'END'
set -x
adduser -D -u1001 -s/bin/ash runner
END
(set -x; sudo mount -R . /srv/alpine/home/runner)
sudo chroot /srv/alpine /bin/su - <<'END'
set -x
apk update && apk add make ${{matrix.compiler.apk}} libc-dev
END
- name: Context Information
run: |
exec 2>&1
sudo chroot /srv/alpine /bin/su - runner <<'END'
uname -a; id; printf %s\\n SHELL="$SHELL" PATH="$PATH"
set -x
pwd
END
- name: Build Tools Information
run: |
exec 2>&1
sudo chroot /srv/alpine /bin/su - runner <<'END'
set -x
make --version; ${{matrix.compiler.gcc}} --version
END
- name: Checkout
uses: actions/checkout@v4
with: { ref: master }
- name: Run Make (and Check)
if: matrix.target.guest != 's390x'
run: |
exec 2>&1
sudo chroot /srv/alpine /bin/su - runner <<'END'
set -x
#echo 'int main() {}' >main.cc
#${{matrix.compiler.gxx}} -pipe -w -pthread -std=c++17 -fPIC -fno-math-errno -Wno-psabi -O3 \
# -fno-stack-protector -fcf-protection=none -fno-stack-clash-protection -U_FORTIFY_SOURCE \
# -include prelude.cc main.cc
#./a.out
make -j4 run GCC='${{matrix.compiler.gcc}}' GXX='${{matrix.compiler.gxx}}' \
${{matrix.target.march && format('MARCH=''{0}''', matrix.target.march)}}
END
- name: Upload Results
if: matrix.target.guest != 's390x'
uses: actions/upload-artifact@v4
with:
name: build-${{matrix.target.guest}}-${{matrix.compiler.label}}
path: build