mirror of
https://github.com/johndoe6345789/MetalOS.git
synced 2026-04-24 13:45:02 +00:00
- Add comment about GLOB usage in kernel/CMakeLists.txt - Improve clarity of optional screenshot capture in qemu-test.yml - All code review comments addressed - Security scan passed with 0 alerts Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
124 lines
3.1 KiB
YAML
124 lines
3.1 KiB
YAML
name: QEMU Boot Test
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, copilot/* ]
|
|
pull_request:
|
|
branches: [ main ]
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
qemu-boot-test:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
actions: write # For uploading artifacts
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
set -e # Exit on any error
|
|
|
|
sudo apt-get update
|
|
sudo apt-get install -y \
|
|
build-essential \
|
|
nasm \
|
|
qemu-system-x86 \
|
|
ovmf \
|
|
mtools \
|
|
xorriso \
|
|
imagemagick
|
|
|
|
- name: Build bootloader
|
|
run: |
|
|
cd bootloader
|
|
make
|
|
|
|
- name: Build kernel
|
|
run: |
|
|
cd kernel
|
|
make
|
|
|
|
- name: Create bootable image
|
|
run: |
|
|
make image
|
|
|
|
- name: Start QEMU and capture screenshot
|
|
run: |
|
|
set -e # Exit on any error
|
|
|
|
# Start Xvfb for headless screenshot capture
|
|
export DISPLAY=:99
|
|
Xvfb :99 -screen 0 1920x1080x24 &
|
|
XVFB_PID=$!
|
|
sleep 2
|
|
|
|
# Verify disk image exists (created by 'make image')
|
|
if [ ! -f build/metalos.img ]; then
|
|
echo "Error: build/metalos.img not found!"
|
|
exit 1
|
|
fi
|
|
|
|
# Start QEMU in the background with a timeout
|
|
timeout 30s qemu-system-x86_64 \
|
|
-bios /usr/share/OVMF/OVMF_CODE.fd \
|
|
-drive format=raw,file=build/metalos.img \
|
|
-m 512M \
|
|
-display gtk \
|
|
-serial file:build/serial.log \
|
|
-no-reboot &
|
|
QEMU_PID=$!
|
|
|
|
# Wait for boot (adjust timing as needed)
|
|
sleep 10
|
|
|
|
# Take screenshot using ImageMagick (optional - don't fail if this doesn't work)
|
|
# Using subshell to prevent 'set -e' from affecting this optional step
|
|
{ import -window root build/qemu-screenshot.png; } || echo "Screenshot capture failed (non-fatal)"
|
|
|
|
# Gracefully stop QEMU (don't fail if already stopped)
|
|
kill $QEMU_PID 2>/dev/null || true
|
|
wait $QEMU_PID 2>/dev/null || true
|
|
|
|
# Stop Xvfb (don't fail if already stopped)
|
|
kill $XVFB_PID 2>/dev/null || true
|
|
|
|
echo "Boot test completed"
|
|
|
|
- name: Show serial output
|
|
if: always()
|
|
run: |
|
|
if [ -f build/serial.log ]; then
|
|
echo "=== QEMU Serial Output ==="
|
|
cat build/serial.log
|
|
else
|
|
echo "No serial output captured"
|
|
fi
|
|
|
|
- name: Upload screenshot
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: qemu-screenshot
|
|
path: build/qemu-screenshot.png
|
|
if-no-files-found: warn
|
|
|
|
- name: Upload serial log
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: serial-log
|
|
path: build/serial.log
|
|
if-no-files-found: warn
|
|
|
|
- name: Upload built disk image
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: metalos-disk-image
|
|
path: build/metalos.img
|
|
if-no-files-found: warn
|