Repository navigation
ci: GitHub Actions pytest workflow + bundled test fixture - #4
Merged
Merged
Conversation
The repo had no CI configuration (no .github/workflows). This meant PRs were merged without automated test verification, depending on the author's local run. PR #3 was merged with 69 passed / 5 skipped but nothing prevented a future change from regressing unnoticed. This commit adds: 1. .github/workflows/tests.yml - Triggers: push to master, pull_request to master - Matrix: Python 3.11, 3.12 (matches pyproject requires-python >=3.11) - Steps: checkout → setup-python → pip install -e '.[dev]' → pytest -v - Plus a CLI-wrapper import check (no execution, because the wrappers read from the operator's production dataset by default — pytest already covers end-to-end via the fixture) 2. tests/conftest.py - Routes CMDB_DATA_DIR to tests/fixtures/dataset/ for every pytest run - Idempotent: respects user override via env var - Local behavior unchanged when CMDB_DATA_DIR is already set 3. tests/fixtures/dataset/ - 3 minimal entities (2 assets, 1 software) + 1 relation - Covers test_acceptance.py requirements: * cmdb_list(kind='asset') returns non-empty * cmdb_impact can resolve fixture-server-a's runs_on relation - Synthetic data — no infrastructure IPs, no hostnames, no secrets - All entities tagged 'ci-fixture' Verified locally: - 69 passed, 5 skipped (same numbers as pre-change) - YAML lints as valid - conftest.py correctly redirects CMDB_DATA_DIR - Workflow does NOT execute the wrapper (would read production dataset) The user's local dataset at ~/knowledge/knowledge-kernel is NOT touched. The fixture only activates when pytest runs from this repo's tests/.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The repo had no CI configuration. PR #3 was merged with 69 passed / 5 skipped locally but nothing prevented future regressions from going unnoticed.
This PR adds a complete CI setup that makes the test suite reproducible in any clean environment:
What's added
.github/workflows/tests.ymlmasterand on every PRtests/conftest.pyCMDB_DATA_DIRto the bundled fixture for every pytest run (idempotent — respects user env override)tests/fixtures/dataset/asset/fixture-server-a.yamlcmdb_impactcoverage)tests/fixtures/dataset/asset/fixture-server-b.yamlcmdb_listcoverage)tests/fixtures/dataset/software/fixture-software-x.yamlDiff summary
Design decisions
Why a bundled fixture instead of mocking?
test_acceptance.pyreads the realcmdb.apiagainst a real dataset. Mocking would mean rewriting tests, breaking their contract. A small YAML fixture preserves the test surface verbatim and is reusable for any contributor (no~/knowledge/...required).Why matrix
[3.11, 3.12]?pyproject.tomldeclaresrequires-python = ">=3.11". Adding 3.13 would be over-reach without testing it locally first. Stick to the declared minimum + one newer.Why no pip caching in step 1? Cache config adds noise to the workflow file. Add it after we see the workflow runs cleanly. KISS.
Why doesn't the workflow execute the CLI wrappers? They use
os.environ.setdefault("CMDB_DATA_DIR", "~/knowledge/knowledge-kernel")— same as the other 11 wrappers. Running them in CI would either fail (no production dataset) or leak test data into the operator's environment. The workflow verifies they import cleanly, which catches syntax/contract regressions without execution risk.Why no
pip-audit/ noruff/ nomypy?pyproject.tomldeclares ruff + mypy as dev-deps, so they're available. But adding them to CI is scope creep — separate PRs with rationale each. This PR is "tests run on every PR", not "everything runs on every PR".Verification done locally
python3 -m pytest tests/ -q→ 69 passed, 5 skipped (same numbers as pre-change)env -u CMDB_DATA_DIR python3 -m pytest tests/ -q→ same (conftest.py correctly redirects)python3 -c "import yaml; yaml.safe_load(open('.github/workflows/tests.yml'))"→ valid YAMLgit add-ed (nogit add .scope creep)Verification pending (happens after merge)
Checklist
feature/ci-github-actionsmaster