Build on Alpine Linux (Chroot) #151
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # .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 -oDpkg::Use-Pty=0 update | |
| - name: Install QEMU | |
| if: (matrix.target.qemu) | |
| run: | | |
| exec 2>&1 | |
| sudo apt-get -oDpkg::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 run tmp; do (set -x; sudo mount -R {,/srv/alpine}/"$d") done) | |
| (set -x; sudo ln -s ../run/systemd/resolve/stub-resolv.conf /srv/alpine/etc/resolv.conf) | |
| sudo chroot /srv/alpine /bin/su - <<'END' | |
| set -x | |
| adduser -D -u1001 -s/bin/ash runner | |
| END | |
| (set -x; sudo mkdir /srv/alpine/home/runner/manool; sudo mount -R . /srv/alpine/home/runner/manool) | |
| 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 | |
| - name: Quick Test | |
| run: | | |
| exec 2>&1 | |
| sudo chroot /srv/alpine /bin/su - runner <<'END' | |
| set -x | |
| tee main.cc <<'EOF' >/dev/null | |
| # include <cstdio> | |
| int main() { | |
| std::puts("Hi"); | |
| } | |
| EOF | |
| ${{matrix.compiler.gxx}} -pipe -w -Wno-psabi -pthread -std=c++17 \ | |
| -fmath-errno -O3 -fno-stack-protector -fcf-protection=none -fno-stack-clash-protection -U_FORTIFY_SOURCE \ | |
| -include manool/prelude.cc main.cc -s -Wl,--as-needed -lm -ldl -lrt && | |
| ./a.out | |
| 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 | |
| make -Cmanool -j4 run GCC=${{matrix.compiler.gcc}} GXX=${{matrix.compiler.gxx}} | |
| END |