Skip to content

test: add coverage, integration tests, and CI pipeline - #3

Merged
bandrel merged 1 commit into
mainfrom
feat/test-infrastructure
Mar 4, 2026
Merged

test: add coverage, integration tests, and CI pipeline#3
bandrel merged 1 commit into
mainfrom
feat/test-infrastructure

Conversation

@bandrel

@bandrel bandrel commented Mar 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add pytest-cov (6.0.0) with 80% coverage threshold, currently at 85.62%
  • Add 39 new unit tests covering DockerAPI method branches and untested command handler paths
  • Add shared test fixtures in conftest.py with auto-applied unit/integration markers
  • Add 8 integration tests against Docker-in-Docker for live container lifecycle validation
  • Add GitHub Actions CI with three parallel jobs: lint, unit-tests, integration-tests

Test plan

  • uv sync --extra dev resolves cleanly
  • uv run pytest -q passes all 120 unit tests
  • uv run pytest --cov --cov-report=term-missing reports 80%+ coverage
  • uv run ruff check ahab.py tests/ && uv run ruff format --check ahab.py tests/ is clean
  • docker compose -f docker-compose.test.yml up -d --wait then uv run pytest -m integration -q passes integration tests
  • CI pipeline runs successfully on push

Add pytest-cov with 80% coverage threshold (currently 85.62%), shared
test fixtures in conftest.py, 39 new unit tests covering DockerAPI
methods and untested command handler branches, 8 integration tests
against Docker-in-Docker, and a GitHub Actions CI pipeline with lint,
unit-test, and integration-test jobs.
Copilot AI review requested due to automatic review settings March 4, 2026 19:25
@bandrel
bandrel merged commit 410a86d into main Mar 4, 2026
5 checks passed
@bandrel
bandrel deleted the feat/test-infrastructure branch March 4, 2026 19:26

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 00cae5526e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread tests/test_integration.py
Comment on lines +25 to +28
if not api.ping():
pytest.skip(f"Docker API at {DOCKER_URL} requires authentication")
except requests.exceptions.ConnectionError:
pytest.skip(f"Docker API at {DOCKER_URL} is not reachable")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Fail integration suite when Docker endpoint is unreachable

The live_api fixture converts both auth-required and unreachable Docker endpoints into pytest.skip, and every integration test depends on this fixture; in the new CI workflow this means a broken Docker-in-Docker setup can still produce a green integration-tests job with all tests skipped (pytest exits 0), so the pipeline no longer guarantees any real integration coverage. In CI contexts this should error/fail instead of skipping so setup regressions are caught.

Useful? React with 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR strengthens the project’s quality gates by adding coverage reporting, expanding the automated test suite (unit + live Docker integration), and introducing a GitHub Actions CI workflow to run linting and tests on every PR.

Changes:

  • Add pytest-cov and coverage configuration with an 80% minimum threshold.
  • Add/expand unit tests and introduce Docker-in-Docker–backed integration tests with shared pytest fixtures/markers.
  • Add a GitHub Actions CI workflow (lint, unit+coverage, integration) plus supporting docs/ignore entries.

Reviewed changes

Copilot reviewed 8 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
uv.lock Locks new dev dependency (pytest-cov) and its transitive deps.
pyproject.toml Adds pytest-cov, pytest markers/addopts, and coverage configuration.
tests/conftest.py Introduces shared fixtures and auto-marking for unit vs integration tests.
tests/test_docker_api.py Adds unit tests for DockerAPI behavior via mocked HTTP session.
tests/test_integration.py Adds live integration tests against a real Docker daemon endpoint.
tests/test_ahab.py Expands coverage for CLI flows, completer setup, and error branches.
docker-compose.test.yml Adds a Docker-in-Docker service to support integration tests in CI.
.github/workflows/ci.yml Adds CI pipeline with separate lint/unit/integration jobs.
README.md Updates dev instructions for uv/ruff/pytest/coverage/integration runs.
.gitignore Ignores coverage outputs (.coverage, coverage.xml, htmlcov/).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docker-compose.test.yml
environment:
DOCKER_TLS_CERTDIR: ""
ports:
- "2375:2375"

Copilot AI Mar 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Docker daemon port is published as 2375:2375, which binds on all host interfaces by default. Since this is an unauthenticated Docker Remote API endpoint, it should be bound to localhost only (or avoided entirely) to prevent exposing a root-equivalent control socket to the LAN/Wi‑Fi network.

Suggested change
- "2375:2375"
- "127.0.0.1:2375:2375"

Copilot uses AI. Check for mistakes.
Comment thread tests/test_integration.py
try:
if not api.ping():
pytest.skip(f"Docker API at {DOCKER_URL} requires authentication")
except requests.exceptions.ConnectionError:

Copilot AI Mar 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

live_api only skips on requests.exceptions.ConnectionError, but DockerAPI.ping() can also raise Timeout or other RequestExceptions (e.g., DNS issues). As written, those failures will error the whole integration suite instead of skipping with a clear message; consider catching requests.exceptions.RequestException (or at least Timeout) here and calling pytest.skip.

Suggested change
except requests.exceptions.ConnectionError:
except requests.exceptions.RequestException:

Copilot uses AI. Check for mistakes.
Comment thread tests/test_integration.py
Comment on lines +73 to +78
config = {
"Image": "alpine:latest",
"Cmd": ["sleep", "30"],
"Tty": False,
"HostConfig": {},
}

Copilot AI Mar 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lifecycle tests assume alpine:latest already exists in the target Docker daemon. On a clean daemon, create_container will fail with an image-not-found error before the test can proceed. To keep the integration suite self-contained (and less dependent on CI pre-steps), pull the image (or skip with a clear message) when it’s missing.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants