Skip to content

Build on Alpine Linux (Chroot) #133

Build on Alpine Linux (Chroot)

Build on Alpine Linux (Chroot) #133

Workflow file for this run

# .github/workflows/alpine.yaml
name: Build on Alpine Linux (Chroot)
on:
workflow_dispatch: NULL
jobs:
build:
name: On ${{matrix.target.guest}} with ${{matrix.compiler.gcc}}
strategy:
fail-fast: FALSE
matrix:
target: # default ISA options are sufficient and should be preferred on Alpine
- { guest: x86_64 }
- { guest: x86 }
- { guest: aarch64, host: -arm }
- { guest: armv7, host: -arm }
- { guest: ppc64le, qemu: TRUE }
- { guest: riscv64, qemu: TRUE }
- { guest: armhf, host: -arm }
- { guest: loongarch64, qemu: TRUE }
- { guest: s390x, qemu: TRUE }
compiler: # omitted: clang15 (partial), clang17
- { pkg: g++, gcc: gcc, gxx: g++ }
- { pkg: clang16, gcc: clang-16, gxx: clang++-16 }
- { pkg: clang18, gcc: clang-18, gxx: clang++-18 }
- { pkg: clang19, gcc: clang-19, gxx: clang++-19 }
- { pkg: clang20, gcc: clang-20, gxx: clang++-20 }
runs-on: ubuntu-24.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 -e --sort ppid,pid -o ppid,pid,user:12,group:12,comm:24,rsz:11,vsz:11,thcount,bsdstart,state,tname
- name: Update Package DB
if: (matrix.target.qemu)
run: |
exec 2>&1
set -x
sudo sed -i /azure/d /etc/apt/apt-mirrors.txt
sudo apt-get -o=Dpkg::Use-Pty=0 update
- name: Install QEMU
if: (matrix.target.qemu)
run: |
exec 2>&1
sudo apt-get -o=Dpkg::Use-Pty=0 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)
#(for d in dev proc sys; do (set -x; sudo mount -v -R -r {,/srv/alpine}/"$d" --make-rprivate) done)
#(for d in run tmp; do (set -x; sudo mount -v -R {,/srv/alpine}/"$d" --make-rprivate) done)
(for d in dev proc sys run tmp; do (set -x; sudo mount -v -R {,/srv/alpine}/"$d") done)
(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.pkg}}
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'
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 'double f(double a, double b) { return a + b; }' >main.cc
#${{matrix.compiler.gxx}} -pipe -v -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 -S -o-
#./a.out
make -j4 run GCC=${{matrix.compiler.gcc}} GXX=${{matrix.compiler.gxx}}
END