Skip to content

Commit 97e5a70

Browse files
committed
Add build and test workflow
1 parent c77cf28 commit 97e5a70

File tree

3 files changed

+164
-2
lines changed

3 files changed

+164
-2
lines changed

.github/workflows/build-and-test.yml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Build And Test
2+
on:
3+
# push:
4+
# pull_request:
5+
workflow_dispatch:
6+
inputs:
7+
host-os:
8+
required: false
9+
type: choice
10+
options:
11+
- ubuntu-22.04
12+
- ubuntu-20.04
13+
default: ubuntu-22.04
14+
ack:
15+
required: true
16+
type: choice
17+
options:
18+
- '0'
19+
- '1'
20+
arch:
21+
required: true
22+
type: choice
23+
options:
24+
- x86_64
25+
- arm64
26+
version:
27+
required: true
28+
type: string
29+
workflow_call:
30+
inputs:
31+
host-os:
32+
required: false
33+
type: string
34+
default: ubuntu-22.04
35+
ack:
36+
required: true
37+
type: string
38+
arch:
39+
required: true
40+
type: string
41+
version:
42+
required: true
43+
type: string
44+
45+
jobs:
46+
build:
47+
uses: ./.github/workflows/build2.yml
48+
with:
49+
host-os: ${{ inputs.host-os }}
50+
ack: ${{ inputs.ack }}
51+
arch: ${{ inputs.arch }}
52+
version: ${{ inputs.version }}
53+
54+
test:
55+
uses: ./.github/workflows/test.yml
56+
needs: build
57+
with:
58+
ack: ${{ inputs.ack }}
59+
arch: ${{ inputs.arch }}
60+
version: ${{ inputs.version }}
61+
artifact-dir: ${{ needs.build.outputs.artifact-dir }}
62+
kernel-image-name: ${{ needs.build.outputs.kernel-image-name }}
63+
suffix: ${{ needs.build.outputs.suffix }}

.github/workflows/build2.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ on:
1010
- ubuntu-20.04
1111
ack:
1212
required: true
13-
type: number
13+
type: choice
14+
options:
15+
- "0"
16+
- "1"
1417
arch:
1518
required: true
1619
type: choice
@@ -28,7 +31,7 @@ on:
2831
default: ubuntu-22.04
2932
ack:
3033
required: true
31-
type: number
34+
type: string
3235
arch:
3336
required: true
3437
type: string

.github/workflows/test.yml

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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

Comments
 (0)