-
Notifications
You must be signed in to change notification settings - Fork 41
ci: add a qemu/arm64 VM to GH workflows #515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1de5cb6
53bf89f
341c889
43f185a
fd9cb31
1752e8b
3832ad8
3c836f9
ac720b9
4820a31
a6a1df5
c204799
2b59da5
4808b91
4e98222
77e7bf9
f8e6bd9
5ca650d
f579c1b
8f5de5b
69c91d6
637cca8
0e7ff91
821663b
9db5ab3
3a00aa1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| name: cross-build using qemu | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| release: | ||
| types: | ||
| - published | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: oracle-vm-16cpu-64gb-x86-64 | ||
| strategy: | ||
| matrix: | ||
| ubuntu: ['noble'] | ||
| arch: ['arm64'] | ||
| steps: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you know if we can use the githubToken thing to save the state of the image after we do all of the steps to prep for running the VM? Wasn't sure if that's only used in that run-on-arch-action
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specific to that action iinm |
||
| - uses: actions/checkout@v4 | ||
| - name: Clean disk space | ||
| uses: ./.github/actions/clean-runner | ||
| - name: Setup Environment | ||
| run: | | ||
| echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV | ||
| cat "$GITHUB_ENV" | ||
| - name: Install qemu dependencies | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y qemu-system-arm qemu-efi-aarch64 qemu-utils cloud-image-utils wget | ||
| - name: Provision qemu vm | ||
| run: | | ||
| wget https://cloud-images.ubuntu.com/${{ matrix.ubuntu }}/current/${{ matrix.ubuntu }}-server-cloudimg-${{ matrix.arch }}.img | ||
|
|
||
| qemu-img create -f qcow2 -F qcow2 \ | ||
| -b ${{ matrix.ubuntu }}-server-cloudimg-${{ matrix.arch }}.img \ | ||
| ${{ matrix.ubuntu }}-snapshot.qcow2 256G | ||
|
|
||
| cat >"user-data" << EOF | ||
| #cloud-config | ||
| password: passw0rd | ||
| chpasswd: { expire: False } | ||
| ssh_pwauth: True | ||
| EOF | ||
| cloud-localds user-data.img user-data | ||
|
|
||
| cp /usr/share/AAVMF/AAVMF_CODE.fd . | ||
| cp /usr/share/AAVMF/AAVMF_VARS.fd . | ||
|
|
||
| qemu-system-aarch64 \ | ||
| -m 16384 \ | ||
| -cpu max -smp 8 \ | ||
| -machine virt,gic-version=max \ | ||
| -display none \ | ||
| -drive if=pflash,format=raw,readonly=on,file=AAVMF_CODE.fd \ | ||
| -drive if=pflash,format=raw,file=AAVMF_VARS.fd \ | ||
| -drive if=none,file="${{ matrix.ubuntu }}-snapshot.qcow2",format=qcow2,id=hd0 \ | ||
| -device virtio-blk-device,drive=hd0 \ | ||
| -drive file=user-data.img,format=raw,media=cdrom,if=none,id=cd0 \ | ||
| -device virtio-blk-device,drive=cd0 \ | ||
| -netdev type=user,id=net0,hostfwd=tcp::22225-:22 \ | ||
| -device virtio-net-device,netdev=net0 \ | ||
| -virtfs local,path=$GITHUB_WORKSPACE,mount_tag=host_share,security_model=passthrough,id=host_share_fs \ | ||
| -daemonize | ||
| - name: Install dependencies | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y sshpass | ||
| - name: Check ssh connectivity | ||
| run: | | ||
| set +e | ||
| while true; do | ||
| echo Trying to connect | ||
| sshpass -p passw0rd ssh -v -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 22225 ubuntu@localhost whoami | ||
| if [ $? -eq 0 ]; then | ||
| break | ||
| fi | ||
| ps -axf | grep qemu | ||
| netstat -tnlp | ||
| sudo dmesg | ||
| echo "intel" | ||
| cat /sys/module/kvm_intel/parameters/nested | ||
| echo "amd" | ||
| cat /sys/module/kvm_amd/parameters/nested | ||
| sleep 10 | ||
| done | ||
| - name: Setup passthrough fs mount | ||
| run: | | ||
| set +e | ||
| sshpass -p passw0rd ssh -v -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 22225 ubuntu@localhost \ | ||
| sudo mkdir /mnt/host_share | ||
| sshpass -p passw0rd ssh -v -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 22225 ubuntu@localhost \ | ||
| sudo mount -t 9p -o trans=virtio,version=9p2000.L host_share /mnt/host_share | ||
| sshpass -p passw0rd ssh -v -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 22225 ubuntu@localhost \ | ||
| 'mkdir /home/ubuntu/src && cp -R /mnt/host_share/* /home/ubuntu/src/' | ||
| - name: Set up golang | ||
| run: | | ||
| sshpass -p passw0rd ssh -v -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 22225 ubuntu@localhost \ | ||
| 'cd /mnt/host_share && sudo tools/install-go' | ||
| - name: install dependencies | ||
| run: | | ||
| sshpass -p passw0rd ssh -v -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 22225 ubuntu@localhost \ | ||
| 'cd /home/ubuntu/src && sudo ./install-build-deps.sh' | ||
| sshpass -p passw0rd ssh -v -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 22225 ubuntu@localhost \ | ||
| 'sudo usermod --add-subuids 100000-165535 --add-subgids 100000-165535 ubuntu' | ||
| - name: Build-level1 | ||
| run: | | ||
| sshpass -p passw0rd ssh -v -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 22225 ubuntu@localhost \ | ||
| ". /etc/profile; cd /home/ubuntu/src; go env; sudo rm -rf .build ./test/centos ./test/ubuntu; sudo make -C cmd/stacker/lxc-wrapper clean" | ||
| sshpass -p passw0rd ssh -v -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 22225 ubuntu@localhost \ | ||
| ". /etc/profile; cd /home/ubuntu/src; make show-info" | ||
| sshpass -p passw0rd ssh -v -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 22225 ubuntu@localhost \ | ||
| ". /etc/profile; cd /home/ubuntu/src; make stacker-dynamic VERSION_FULL=$SHORT_SHA" | ||
| - name: Build | ||
| run: | | ||
| sshpass -p passw0rd ssh -v -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 22225 ubuntu@localhost \ | ||
| ". /etc/profile; cd /home/ubuntu/src; make stacker VERSION_FULL=$SHORT_SHA; cat .build/stacker/imports/build-env/.stacker-run.sh; cat .build/stacker/lxc.log; sudo cp /home/ubuntu/src/stacker /mnt/host_share/" | ||
| - name: Check binary | ||
| run: | | ||
| cd $GITHUB_WORKSPACE | ||
| ls -al stacker | ||
| file stacker | ||
| - if: github.event_name == 'release' && github.event.action == 'published' | ||
| name: Publish artifacts on releases | ||
| uses: svenstaro/upload-release-action@v2 | ||
| with: | ||
| repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
| file: stacker | ||
| asset_name: stacker-${{ matrix.arch }} | ||
| tag: ${{ github.ref }} | ||
| overwrite: true | ||
| file_glob: true | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #!/bin/sh | ||
|
|
||
| set -xe | ||
|
|
||
| cd /tmp | ||
| wget -N https://go.dev/dl/go1.24.7.linux-arm64.tar.gz -O golang.tar.gz | ||
| rm -rf /usr/local/go | ||
| tar -xzvf golang.tar.gz -C /usr/local | ||
| echo 'export PATH=/usr/local/go/bin:$PATH' >> /etc/profile | ||
| echo 'export GOROOT=/usr/local/go' >> /etc/profile | ||
| . /etc/profile | ||
| go env |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are native arm runners on github:
https://github.com/project-machine/machine/blob/main/.github/workflows/build.yml