STANDARDS.md binds every repository in the NAPALM org: one default branch, Conventional Commits, the device-types contract, test-driven development, clean-code limits, a quality ratchet for existing code, packaging rules and releases by tag to PyPI. napalm-standard holds what a tool can check: the conformance check (with release rules on a tag), the quality ratchet (ported from netOrk's quality_ratchet.py), and the Gitea release from the CHANGELOG section. .gitea/workflows/driver.yml is the CI every driver calls; template/ is a new driver's starting point and passes the check as it is.
30 lines
869 B
Python
30 lines
869 B
Python
"""The template a new driver starts from meets the standard as it is."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pathlib
|
|
import shutil
|
|
|
|
from napalm_standard import ratchet
|
|
from napalm_standard.check import check_repo
|
|
|
|
TEMPLATE = pathlib.Path(__file__).resolve().parents[1] / "template"
|
|
|
|
|
|
def test_the_template_passes_the_check() -> None:
|
|
assert check_repo(TEMPLATE) == []
|
|
|
|
|
|
def test_the_template_is_within_its_ratchet(tmp_path: pathlib.Path) -> None:
|
|
repo = tmp_path / "repo"
|
|
shutil.copytree(TEMPLATE, repo)
|
|
|
|
assert ratchet.run(repo, "napalm_example") == (0, "within the baseline")
|
|
|
|
|
|
def test_the_template_ci_calls_the_shared_workflow() -> None:
|
|
ci = (TEMPLATE / ".gitea" / "workflows" / "ci.yml").read_text()
|
|
|
|
assert "uses: NAPALM/driver-standard/.gitea/workflows/driver.yml@" in ci
|
|
assert "PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}" in ci
|