|
| 1 | +name: Test |
| 2 | +on: |
| 3 | + workflow_call: |
| 4 | + inputs: |
| 5 | + host-os: |
| 6 | + required: false |
| 7 | + type: string |
| 8 | + default: ubuntu-22.04 |
| 9 | + ack: |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + arch: |
| 13 | + required: true |
| 14 | + type: string |
| 15 | + version: |
| 16 | + required: true |
| 17 | + type: string |
| 18 | + artifact-dir: |
| 19 | + required: true |
| 20 | + type: string |
| 21 | + kernel-image-name: |
| 22 | + required: true |
| 23 | + type: string |
| 24 | + suffix: |
| 25 | + required: true |
| 26 | + type: string |
| 27 | + |
| 28 | + |
| 29 | +jobs: |
| 30 | + test: |
| 31 | + runs-on: ubuntu-22.04 |
| 32 | + # Put ACK and ARCH in the environment so it's picked up by the `make` commands |
| 33 | + env: |
| 34 | + ACK: ${{ inputs.ack }} |
| 35 | + ARCH: ${{ inputs.arch }} |
| 36 | + steps: |
| 37 | + - uses: actions/checkout@v4 |
| 38 | + |
| 39 | + - name: Download kernel artifacts |
| 40 | + uses: actions/download-artifact@v4 |
| 41 | + with: |
| 42 | + name: ${{ inputs.artifact-dir }} |
| 43 | + path: ${{ inputs.artifact-dir }} |
| 44 | + |
| 45 | + - run: ls -lR |
| 46 | + |
| 47 | + - name: Install common dependencies |
| 48 | + run: sudo apt update && sudo apt install -y debootstrap |
| 49 | + |
| 50 | + - name: Install x86_64 dependencies |
| 51 | + if: ${{ inputs.arch == 'x86_64' }} |
| 52 | + run: sudo apt install -y qemu-system-x86 |
| 53 | + |
| 54 | + - name: Install arm64 dependencies |
| 55 | + if: ${{ inputs.arch == 'arm64' }} |
| 56 | + run: sudo apt install -y qemu-system-arm qemu-user-static binfmt-support |
| 57 | + |
| 58 | + - name: Initialize rootfs and initramfs |
| 59 | + shell: bash |
| 60 | + run: | |
| 61 | + set -x |
| 62 | +
|
| 63 | + make rootfs-init |
| 64 | +
|
| 65 | + ALPINE_ROOTFS=alpine-${{ inputs.arch }}.img |
| 66 | + UBUNTU_ROOTFS=ubuntu-jammy-${{ inputs.arch }}.img |
| 67 | + |
| 68 | + ROOTFS=${ALPINE_ROOTFS} make rootfs-init |
| 69 | +
|
| 70 | + scripts/ubuntu_debootstrap.sh jammy ${{ inputs.arch }} |
| 71 | + SUDO=1 ROOTFS_DIR=./rootfs/ubuntu-jammy-${{ inputs.arch }} CPIO_FILE=ubuntu-jammy-${{ inputs.arch }}.cpio.gz make rootfs-overlay |
| 72 | +
|
| 73 | + echo "ALPINE_ROOTFS=$ALPINE_ROOTFS" >> $GITHUB_OUTPUT |
| 74 | + echo "UBUNTU_ROOTFS=$UBUNTU_ROOTFS" >> $GITHUB_OUTPUT |
| 75 | +
|
| 76 | + - name: Setup shared/init.sh |
| 77 | + run: | |
| 78 | + mkdir shared |
| 79 | + echo poweroff > shared/init.sh |
| 80 | + chmod +x shared/init.sh |
| 81 | +
|
| 82 | + - name: Run kernel |
| 83 | + run: | |
| 84 | + export QEMU_KERNEL_IMAGE=${{ inputs.artifact-dir }}/${{ inputs.kernel-image-name }} |
| 85 | +
|
| 86 | + make run |
| 87 | + ROOTFS=./rootfs/${{ env.UBUNTU_ROOTFS }} make run |
| 88 | + INITRD=1 make run |
| 89 | + INITRD=./ubuntu-jammy-${{ inputs.arch }}.cpio.gz make run |
| 90 | + CPU=2 MEM=2048M QEMU_EXTRA_ARGS="" QEMU_EXTRA_KERNEL_CMDLINE="nokaslr" ROOTFS=./${{ env.ALPINE_ROOTFS }} make run |
| 91 | +
|
| 92 | + - name: Upload rootfs artifact |
| 93 | + uses: actions/upload-artifact@v4 |
| 94 | + with: |
| 95 | + name: rootfs-${{ inputs.SUFFIX }} |
| 96 | + path: rootfs/${{ env.ALPINE_ROOTFS }} |
0 commit comments