Skip to content

Commit e64bfcc

Browse files
committed
ci: add GitHub Actions workflow
1 parent 785099c commit e64bfcc

10 files changed

Lines changed: 182 additions & 0 deletions

File tree

.github/README.en.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# `.github/`
2+
3+
[中文 README](./README.md)
4+
5+
This directory stores GitHub-specific configuration. At the moment it mainly contains the continuous integration workflow definitions.
6+
7+
## Main Contents
8+
9+
- `workflows/`
10+
GitHub Actions workflow directory

.github/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# `.github/`
2+
3+
[English README](./README.en.md)
4+
5+
这个目录保存 GitHub 相关配置。目前主要包含持续集成工作流定义。
6+
7+
## 主要内容
8+
9+
- `workflows/`
10+
GitHub Actions 工作流目录

.github/workflows/README.en.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# `.github/workflows/`
2+
3+
[中文 README](./README.md)
4+
5+
This directory stores the GitHub Actions workflows. The current workflow verifies that the repository still completes unit tests, source build, and Linux 0.12 boot verification on Ubuntu 22.04.
6+
7+
## Current File
8+
9+
- `ci.yml`
10+
continuous integration workflow covering tests, build, and `ls` boot verification

.github/workflows/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# `.github/workflows/`
2+
3+
[English README](./README.en.md)
4+
5+
这个目录保存 GitHub Actions 工作流。当前工作流用于验证仓库在 Ubuntu 22.04 上仍然可以完成单测、源码构建和 Linux 0.12 启动验证。
6+
7+
## 当前文件
8+
9+
- `ci.yml`
10+
持续集成工作流,覆盖单测、构建和 `ls` 启动验证

.github/workflows/ci.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
linux-012:
13+
runs-on: ubuntu-22.04
14+
timeout-minutes: 60
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Install host dependencies
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install -y qemu-system-x86
24+
25+
- name: Run unit tests
26+
run: python3 -m unittest discover -s tests -v
27+
28+
- name: Check host dependencies
29+
run: ./scripts/bootstrap-host.sh
30+
31+
- name: Build Linux 0.12 images from source
32+
run: python3 rebuild/driver.py build
33+
34+
- name: Verify Linux 0.12 boots and runs ls
35+
run: ./scripts/verify.sh
36+
37+
- name: Upload verification artifacts
38+
if: always()
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: linux-012-ci-artifacts
42+
path: |
43+
out/verify
44+
rebuild/out/logs

README.en.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,17 @@ Force a fresh rebuild, sync `images/`, and then start QEMU in a visible window:
259259
python3 rebuild/driver.py build-and-run-repo-images-window
260260
```
261261

262+
## Continuous Integration
263+
264+
The repository now includes the GitHub Actions workflow [ci.yml](/Users/infoxmed-01/ai/workspace/linux-012/.github/workflows/ci.yml). On pushes to `main` and pull requests targeting `main`, it runs the following on `ubuntu-22.04`:
265+
266+
- `python3 -m unittest discover -s tests -v`
267+
- `./scripts/bootstrap-host.sh`
268+
- `python3 rebuild/driver.py build`
269+
- `./scripts/verify.sh`
270+
271+
On failure it uploads `out/verify` and `rebuild/out/logs` as debugging artifacts.
272+
262273
Build the images explicitly:
263274

264275
```sh

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,17 @@ python3 rebuild/driver.py build-and-run-repo-images
259259
python3 rebuild/driver.py build-and-run-repo-images-window
260260
```
261261

262+
## 持续集成
263+
264+
仓库现在包含 GitHub Actions 工作流 [ci.yml](/Users/infoxmed-01/ai/workspace/linux-012/.github/workflows/ci.yml)。它会在推送到 `main` 或对 `main` 发起 Pull Request 时,在 `ubuntu-22.04` 上执行:
265+
266+
- `python3 -m unittest discover -s tests -v`
267+
- `./scripts/bootstrap-host.sh`
268+
- `python3 rebuild/driver.py build`
269+
- `./scripts/verify.sh`
270+
271+
失败时会上传 `out/verify``rebuild/out/logs` 作为排查产物。
272+
262273
显式构建镜像:
263274

264275
```sh
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# GitHub Actions CI Implementation Plan
2+
3+
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
4+
5+
**Goal:** Add a GitHub Actions workflow that proves the repo still builds and boots Linux 0.12 from source on every push and pull request.
6+
7+
**Architecture:** Enforce workflow presence with a repository test, then add a single Ubuntu-based CI workflow under `.github/workflows/` that runs the existing host bootstrap, unit tests, source build, and QEMU `ls` verification. Keep the workflow aligned with current documented entrypoints instead of inventing a parallel CI-only path.
8+
9+
**Tech Stack:** GitHub Actions, Ubuntu runner, Docker, QEMU, Python `unittest`, repository shell scripts
10+
11+
---
12+
13+
### Task 1: Add The Failing Workflow Coverage Test
14+
15+
**Files:**
16+
- Create: `tests/test_ci_workflow.py`
17+
18+
- [ ] **Step 1: Write the failing test**
19+
- [ ] **Step 2: Run the targeted test and confirm it fails because `.github/workflows/ci.yml` does not exist**
20+
- [ ] **Step 3: Keep the test focused on the required workflow file and the key commands it must run**
21+
- [ ] **Step 4: Re-run the targeted test after the workflow is added**
22+
23+
### Task 2: Add The GitHub Actions Workflow
24+
25+
**Files:**
26+
- Create: `.github/workflows/ci.yml`
27+
28+
- [ ] **Step 1: Define a single CI workflow triggered on pushes and pull requests to `main`**
29+
- [ ] **Step 2: Install QEMU and Docker support on `ubuntu-22.04`**
30+
- [ ] **Step 3: Run `python3 -m unittest discover -s tests -v`**
31+
- [ ] **Step 4: Run `./scripts/bootstrap-host.sh`, `python3 rebuild/driver.py build`, and `./scripts/verify.sh`**
32+
- [ ] **Step 5: Upload verification artifacts so CI failures are debuggable**
33+
34+
### Task 3: Document And Verify The New CI Path
35+
36+
**Files:**
37+
- Modify: `README.md`
38+
- Modify: `README.en.md`
39+
- Modify: `tests/test_layout.py`
40+
41+
- [ ] **Step 1: Add `.github/workflows/ci.yml` to the expected repository layout**
42+
- [ ] **Step 2: Add a short CI section to both README files**
43+
- [ ] **Step 3: Run `python3 -m unittest discover -s tests -v`**
44+
- [ ] **Step 4: Run `git diff --check`**
45+
- [ ] **Step 5: Inspect `git status --short` and summarize the new CI files**

tests/test_ci_workflow.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import pathlib
2+
import unittest
3+
4+
5+
ROOT = pathlib.Path(__file__).resolve().parents[1]
6+
7+
8+
class GitHubActionsWorkflowTest(unittest.TestCase):
9+
def test_ci_workflow_exists_and_runs_required_commands(self) -> None:
10+
workflow = ROOT / ".github" / "workflows" / "ci.yml"
11+
12+
self.assertTrue(workflow.exists(), workflow)
13+
text = workflow.read_text(encoding="utf-8")
14+
self.assertIn("push:", text)
15+
self.assertIn("pull_request:", text)
16+
self.assertIn("ubuntu-22.04", text)
17+
self.assertIn("python3 -m unittest discover -s tests -v", text)
18+
self.assertIn("./scripts/bootstrap-host.sh", text)
19+
self.assertIn("python3 rebuild/driver.py build", text)
20+
self.assertIn("./scripts/verify.sh", text)
21+
22+
23+
if __name__ == "__main__":
24+
unittest.main()

tests/test_layout.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ class LayoutTest(unittest.TestCase):
1010
def test_expected_paths_exist(self) -> None:
1111
expected = [
1212
ROOT / "README.md",
13+
ROOT / ".github",
14+
ROOT / ".github" / "README.md",
15+
ROOT / ".github" / "README.en.md",
16+
ROOT / ".github" / "workflows",
17+
ROOT / ".github" / "workflows" / "README.md",
18+
ROOT / ".github" / "workflows" / "README.en.md",
19+
ROOT / ".github" / "workflows" / "ci.yml",
1320
ROOT / "images",
1421
ROOT / "images" / "bootimage-0.12-hd",
1522
ROOT / "images" / "hdc-0.12.img",

0 commit comments

Comments
 (0)