Skip to content

Commit 040fa6e

Browse files
amannocciclaude
andcommitted
build: migrate to uv + poethepoet, replace bats with pytest
Complete overhaul of build system and test framework: Build System: - Replace Task CLI with uv + poethepoet - Remove Taskfile.yml, add pyproject.toml with poe tasks: uv run poe env:configure # setup uv run poe test # run tests uv run poe package # create tarball - Require Python 3.13+ instead of 3.11 - Pin pre-commit 4.5, poethepoet 0.42, pytest 8.0 Test Framework: - Replace 8 bats test files (lib.bash + 7 *.bats) with 7 pytest modules - Total: 23 tests (boot, preboot, envs, perms, init, finalize, services) - Create tests/conftest.py with podman image build/run helpers - Image building delegated to pytest module-scoped fixtures - Organize fixture Dockerfiles and rootfs into tests/fixtures/ Code Quality: - Type annotations throughout (tuple[str, ...] for BASE_DOCKER_ARGS) - Immutable structures (tuple instead of list) - Pytest assertions instead of bats exit code checks CI/CD: - Update .github/workflows/ci.yml to use astral-sh/setup-uv@v8 - Remove bats system dependency from CI (now pytest + podman only) - Update .gitignore: add .venv/, __pycache__/, *.pyc - Update README.md with new command documentation All 23 tests passing. Fixture data (Dockerfiles, rootfs overlays) now properly separated from test code in tests/fixtures/ structure. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent 4040b9e commit 040fa6e

File tree

48 files changed

+612
-256
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+612
-256
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,10 @@ jobs:
1414
test:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v4
17+
- uses: actions/checkout@v6
1818

19-
- name: Install Task
20-
uses: arduino/setup-task@v2
21-
22-
- name: Install dependencies
23-
run: sudo apt install -y bats
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v8
2421

2522
- name: Run tests
26-
run: task test
23+
run: uv run poe test

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
dist/
1+
dist/
2+
.venv/
3+
__pycache__/
4+
*.pyc
5+
.idea

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
## :package: Prerequisites
2727

28-
- [Taskfile](https://taskfile.dev/) for development.
28+
- [uv](https://docs.astral.sh/uv/getting-started/installation/) for development.
2929
- [Podman](https://podman.io/docs/installation) for development.
3030

3131
## :sparkles: Features
@@ -49,14 +49,14 @@
4949
The following steps will ensure your project is cloned properly.
5050

5151
1. `git clone https://github.com/techcode-io/ignity`
52-
2. `cd ignity && task setup`
52+
2. `cd ignity && uv run poe env:configure`
5353

5454
### Test
5555

5656
- To test you have to use the workflow script.
5757

5858
```bash
59-
task test
59+
uv run poe test
6060
```
6161

6262
- It will test project code with the current environment.
@@ -66,7 +66,7 @@ task test
6666
- To package you have to use the workflow script.
6767

6868
```bash
69-
task package
69+
uv run poe package
7070
```
7171

7272
- It will create a tar archive containing ignity.

Taskfile.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

pyproject.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[project]
2+
name = "ignity"
3+
version = "0.1.0"
4+
description = "Dead simple process supervision for containers based on s6"
5+
readme = "README.md"
6+
requires-python = ">=3.13"
7+
dependencies = []
8+
9+
[dependency-groups]
10+
dev = [
11+
"pre-commit>=4.5",
12+
"poethepoet>=0.42",
13+
"pytest>=8.0",
14+
]
15+
16+
[tool.uv]
17+
package = false
18+
19+
[tool.poe.tasks."env:configure"]
20+
help = "Setup project environment"
21+
cmd = "pre-commit install"
22+
23+
[tool.poe.tasks."test"]
24+
help = "Run all tests."
25+
cmd = "pytest tests"
26+
27+
[tool.poe.tasks.package]
28+
help = "Package source into dist/ignity.tar.gz"
29+
sequence = [
30+
{ shell = "rm -rf dist && mkdir -p dist" },
31+
{ cmd = "tar zcvf dist/ignity.tar.gz -C src/ ." },
32+
]

scripts/test.sh

Lines changed: 0 additions & 29 deletions
This file was deleted.

tests/boot/tests.bats

Lines changed: 0 additions & 31 deletions
This file was deleted.

tests/conftest.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
"""Shared helpers for ignity pytest tests."""
2+
3+
import os
4+
import secrets
5+
import subprocess
6+
import tempfile
7+
from pathlib import Path
8+
from typing import Final
9+
10+
ROOT: Final[Path] = Path(__file__).parent.parent.resolve()
11+
12+
BASE_DOCKER_ARGS: tuple[str, ...] = (
13+
"-e", "IGNITY_KILL_GRACETIME=0",
14+
"-e", "IGNITY_KILL_FINALIZE_MAXTIME=0",
15+
"-e", "IGNITY_SERVICES_GRACETIME=0",
16+
"-e", "IGNITY_CMD_WAIT_FOR_SERVICES_MAXTIME=0",
17+
)
18+
19+
20+
def build_image(kind: str) -> str:
21+
"""Build a container image for a test suite kind."""
22+
tag = secrets.token_hex(16)
23+
image_name = f"ignity-test-{kind}-{tag}"
24+
dockerfile_tpl = ROOT / "tests" / "fixtures" / kind / "Dockerfile.tpl"
25+
base_image = os.environ.get("DOCKER_BASE_IMAGE", "debian:bookworm-slim")
26+
rendered = dockerfile_tpl.read_text().replace(
27+
"{{DOCKER_BASE_IMAGE}}", base_image
28+
)
29+
with tempfile.NamedTemporaryFile(
30+
mode="w", delete=False, suffix=".Dockerfile"
31+
) as f:
32+
f.write(rendered)
33+
tmp_path = f.name
34+
try:
35+
subprocess.run(
36+
["podman", "build", "-t", image_name, "-f", tmp_path, str(ROOT)],
37+
check=True,
38+
)
39+
finally:
40+
Path(tmp_path).unlink(missing_ok=True)
41+
return image_name
42+
43+
44+
def run_in_container(
45+
image: str, command: str, extra_args: list[str] | None = None
46+
) -> subprocess.CompletedProcess:
47+
"""Run a command in a container and return the result."""
48+
args = [
49+
"podman",
50+
"run",
51+
"--name",
52+
f"ignity-{secrets.token_hex(8)}",
53+
"--entrypoint",
54+
"/init",
55+
"--rm",
56+
"-i",
57+
*BASE_DOCKER_ARGS,
58+
*(extra_args or []),
59+
image,
60+
"bash",
61+
]
62+
return subprocess.run(args, input=command, capture_output=True, text=True)

tests/envs/tests.bats

Lines changed: 0 additions & 21 deletions
This file was deleted.

tests/finalize/tests.bats

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)