Build Under QEMU (incl. x32) #2
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/qemux32.yaml | |
| name: Build Under QEMU (incl. x32) | |
| on: | |
| workflow_dispatch: NULL | |
| jobs: | |
| qemux32-build: | |
| name: Build with ${{matrix.compiler.label}}/${{matrix.march.label}} | |
| strategy: | |
| fail-fast: FALSE | |
| matrix: | |
| compiler: | |
| - { label: 'gcc9', gcc: 'gcc', gxx: 'g++' } | |
| - { label: 'gcc10', gcc: 'gcc-10', gxx: 'g++-10' } | |
| - { label: 'clang18', gcc: 'clang-18', gxx: 'clang++-18' } | |
| march: | |
| - { label: '64' } | |
| - { label: '32', flags: '-m32 -msse2 -mfpmath=sse' } | |
| - { label: 'x32', flags: '-mx32' } | |
| include: | |
| - compiler: { label: 'clang18-libcxx', gcc: 'clang-18', gxx: 'clang++-18 -stdlib=libc++' } | |
| march: { label: '64' } | |
| runs-on: ubuntu-latest | |
| needs: [ qemux32-cache ] | |
| defaults: | |
| run: { shell: bash } | |
| steps: | |
| - &minfo | |
| name: Host Machine Information | |
| run: | | |
| exec 2>&1 | |
| set -x | |
| lscpu; free -h; df -H . | |
| - &sinfo | |
| name: Host System Information | |
| run: | | |
| exec 2>&1 | |
| date; uname -a; uptime | |
| set -x | |
| systemd-detect-virt || : | |
| cat /etc/os-release | |
| ls -C /boot || : | |
| - &cinfo | |
| 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: Host Setup | |
| run: | | |
| exec 2>&1 | |
| set -x | |
| sudo sed -i /azure/d /etc/apt/apt-mirrors.txt | |
| sudo apt-get update | |
| sudo apt-get install --no-install-recommends qemu-system-x86 | |
| - name: QEMU Information | |
| run: | | |
| exec 2>&1 | |
| qemu-system-x86_64 --version | |
| - name: Cache Object Lookup | |
| uses: actions/cache@v4 | |
| with: | |
| key: ubuntu-focal-cloud-generic | |
| path: | | |
| ~/root.img | |
| ~/.ssh/id_rsa | |
| /usr/local/bin/vmbash.sh | |
| - name: Start Guest | |
| run: | | |
| exec 2>&1 | |
| set -x | |
| cd | |
| sudo qemu-system-x86_64 -enable-kvm -cpu host -smp 4 -m 10G \ | |
| -drive file=root.img,if=virtio,cache=unsafe -nic user,model=virtio,hostfwd=:127.0.0.1:222-:22 \ | |
| -daemonize -vga none -display none | |
| until ssh -oStrictHostKeyChecking=no -p222 root@127.0.0.1 : 2>/dev/null; do sleep 1; done | |
| - name: Time Synchronization | |
| shell: vmbash.sh {0} | |
| run: | | |
| exec 2>&1 | |
| until [ "$(set -x; timedatectl show --value -pNTPSynchronized)" = yes ]; do (set -x; sleep 1) done | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: { ref: master } | |
| - name: Upload to Guest | |
| run: | | |
| exec 2>&1 | |
| set -x | |
| cd .. | |
| tar c --{owner,group}=0 manool | ssh -p222 root@127.0.0.1 tar x | |
| - name: Build and Test | |
| shell: vmbash.sh {0} | |
| run: | | |
| exec 2>&1 | |
| set -x | |
| make --version; ${{matrix.compiler.gcc}} --version | |
| make -Cmanool -j4 run \ | |
| GCC='${{matrix.compiler.gcc}}' GXX='${{matrix.compiler.gxx}}' \ | |
| MARCH='${{matrix.march.flags}}' | |
| - name: Download from Guest | |
| run: | | |
| exec 2>&1 | |
| set -x | |
| cd .. | |
| rm -r manool | |
| ssh -p222 root@127.0.0.1 tar c --{owner,group}=0 manool | tar x | |
| - name: Upload Results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: focal-${{matrix.compiler.label}}-${{matrix.march.label}} | |
| path: build | |
| qemux32-cache: | |
| name: Prepare Guest VM | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: { shell: bash } | |
| steps: | |
| - *minfo | |
| - *sinfo | |
| - *cinfo | |
| - name: Cache Object Lookup | |
| id: cache | |
| uses: actions/cache@v4 | |
| with: | |
| key: ubuntu-focal-cloud-generic | |
| path: | | |
| ~/root.img | |
| ~/.ssh/id_rsa | |
| /usr/local/bin/vmbash.sh | |
| lookup-only: TRUE | |
| - name: Host Setup | |
| if: steps.cache.outputs.cache-hit != 'true' | |
| run: | | |
| exec 2>&1 | |
| set -x | |
| sudo sed -i /azure/d /etc/apt/apt-mirrors.txt | |
| sudo apt-get update | |
| sudo apt-get install --no-install-recommends qemu-system-x86 cloud-image-utils | |
| - name: QEMU Information | |
| if: steps.cache.outputs.cache-hit != 'true' | |
| run: | | |
| exec 2>&1 | |
| qemu-system-x86_64 --version | |
| - name: Deploy and Start Guest | |
| if: steps.cache.outputs.cache-hit != 'true' | |
| run: | | |
| exec 2>&1 | |
| set -x | |
| cd | |
| wget --no-show-progress -Oroot.img \ | |
| https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img | |
| qemu-img resize root.img 6G | |
| mkdir -m700 .ssh | |
| ssh-keygen -N '' -t ed25519 -f .ssh/id_rsa | |
| cloud-localds seed.iso - <<END | |
| #cloud-config | |
| users: | |
| - name: root | |
| ssh_authorized_keys: [ '$(<.ssh/id_rsa.pub)' ] | |
| END | |
| sudo qemu-system-x86_64 -enable-kvm -cpu host -smp 4 -m 10G \ | |
| -drive file=root.img,if=virtio,cache=unsafe -nic user,model=virtio,hostfwd=:127.0.0.1:222-:22 \ | |
| -daemonize -vga none -display none -cdrom seed.iso | |
| until ssh -oStrictHostKeyChecking=no -p222 root@127.0.0.1 : 2>/dev/null; do sleep 1; done | |
| tee /usr/local/bin/vmbash.sh <<'END' >/dev/null; chmod +x /usr/local/bin/vmbash.sh | |
| #!/bin/bash | |
| ssh -p222 root@127.0.0.1 bash --noprofile --norc -e -o pipefail <$1 | |
| END | |
| - name: Time Synchronization | |
| if: steps.cache.outputs.cache-hit != 'true' | |
| shell: vmbash.sh {0} | |
| run: | | |
| exec 2>&1 | |
| until [ "$(set -x; timedatectl show --value -pNTPSynchronized)" = yes ]; do (set -x; sleep 1) done | |
| - name: Guest Information | |
| if: steps.cache.outputs.cache-hit != 'true' | |
| shell: vmbash.sh {0} | |
| run: | | |
| exec 2>&1 | |
| set -x | |
| lscpu; free -h; df -H . | |
| - name: Guest Setup | |
| if: steps.cache.outputs.cache-hit != 'true' | |
| shell: vmbash.sh {0} | |
| run: | | |
| exec 2>&1 | |
| set -x | |
| apt-get update | |
| apt-get -y install make g++{,-10}-multilib clang-18 libc++{,abi}-18-dev | |
| df -H . | |
| - name: Guest Shutdown | |
| if: steps.cache.outputs.cache-hit != 'true' | |
| run: | | |
| exec 2>&1 | |
| (set -x; ssh -p222 root@127.0.0.1 poweroff) || : | |
| while [ "$(set -x; sudo lsof -w ~/root.img)" ]; do (set -x; sleep 1) done |