Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions .github/workflows/qemu-crossbuild.yaml
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']
Copy link
Copy Markdown
Contributor

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

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-22.04
            arch: amd64
            build: true
          - os: ubuntu-22.04-arm
            arch: arm64
            build: true

steps:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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?

# speeds up builds by storing container images in a GitHub package registry.
githubToken: ${{ github.token }}     

Wasn't sure if that's only used in that run-on-arch-action

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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
12 changes: 12 additions & 0 deletions tools/install-go
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
Loading