diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..053e419 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,39 @@ +name: Bug report +description: The kernel doesn't build, doesn't boot, or misbehaves in QEMU +title: "[Bug]: " +labels: ["bug"] +body: + - type: textarea + id: what + attributes: + label: What happened? + description: What you saw versus what you expected. + validations: + required: true + - type: textarea + id: repro + attributes: + label: Steps to reproduce + description: Exact commands, starting from a clean checkout. + placeholder: | + 1. `nasm -f bin boot.asm -o boot.bin` + 2. `qemu-system-x86_64 -fda boot.bin` + 3. … + validations: + required: true + - type: textarea + id: env + attributes: + label: Environment + description: OS and tool versions. + placeholder: | + OS: Ubuntu 24.04 + nasm: 2.16.01 (`nasm -v`) + QEMU: 8.2.2 (`qemu-system-x86_64 --version`) + validations: + required: true + - type: textarea + id: logs + attributes: + label: Logs / screenshots + description: Paste terminal output or attach a screenshot of the QEMU window. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..0086358 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: true diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..99106d5 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,11 @@ +## What does this change do? + + + +## Checklist + +- [ ] Builds cleanly without error +- [ ] Boots in QEMU and shows the expected output +- [ ] No generated artifacts committed (`*.o`, `*.bin`, `*.iso`, `build/` etc) +- [ ] Documentation updated if behavior changed +- [ ] AI policy respected: code is human-authored (or fully understood) see [CONTRIBUTING.md](CONTRIBUTING.md) diff --git a/.github/scripts/check_boot.py b/.github/scripts/check_boot.py new file mode 100644 index 0000000..e7302d9 --- /dev/null +++ b/.github/scripts/check_boot.py @@ -0,0 +1,67 @@ +"""QEMU boot check for Nadir CI. + +Runs the boot sector headless on a pseudo-terminal with the curses display, +waits for the boot, then asserts the welcome message reached the screen. +A garbage image (SeaBIOS "No bootable device") fails this check. + +Usage: python3 .github/scripts/check_boot.py (from the repository root) +Requires: qemu-system-x86_64 on PATH. Stdlib only. +""" + +import fcntl +import os +import pty +import select +import struct +import subprocess +import sys +import termios +import time + +IMAGE = "boot.bin" +NEEDLE = b"Nadir" +BOOT_WAIT_S = 8 + + +def main() -> int: + master, slave = pty.openpty() + fcntl.ioctl(slave, termios.TIOCSWINSZ, struct.pack("HHHH", 24, 80, 0, 0)) + env = dict(os.environ, TERM="xterm") + proc = subprocess.Popen( + ["qemu-system-x86_64", "-display", "curses", "-fda", IMAGE], + stdin=slave, + stdout=slave, + stderr=subprocess.DEVNULL, + env=env, + ) + os.close(slave) + time.sleep(BOOT_WAIT_S) + proc.terminate() + try: + proc.wait(timeout=10) + except subprocess.TimeoutExpired: + proc.kill() + proc.wait() + fcntl.fcntl(master, fcntl.F_SETFL, os.O_NONBLOCK) + data = b"" + while True: + ready, _, _ = select.select([master], [], [], 1) + if not ready: + break + try: + chunk = os.read(master, 65536) + except OSError: + break + if not chunk: + break + data += chunk + os.close(master) + if NEEDLE not in data: + print(f"FAIL: {NEEDLE!r} not found on the QEMU screen") + return 1 + print("OK: QEMU booted and printed the welcome message") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..a37aafe --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,26 @@ +# Nadir Kernel CI. Runs on every pull request and every push to main. +# + +name: CI + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +jobs: + build-and-boot: + name: Build and boot in QEMU + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Install toolchain + run: sudo apt-get update && sudo apt-get install -y nasm qemu-system-x86 + + - name: Build boot sector + run: nasm -f bin boot.asm -o boot.bin \ No newline at end of file