diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..7530c79 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,15 @@ +name: CI + +on: + push: + branches: [main] + tags: ["v*"] + pull_request: + +jobs: + driver: + uses: NAPALM/driver-standard/.gitea/workflows/driver.yml@main + with: + standard-ref: main + secrets: + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 372e184..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: CI - -on: - push: - branches: ["**"] - pull_request: - branches: ["**"] - -jobs: - test: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - python-version: ["3.10", "3.11", "3.12", "3.13"] - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - cache: pip - - - name: Install package with dev extras - run: | - python -m pip install --upgrade pip - python -m pip install -e ".[dev]" - - - name: Type-check - run: | - python -m mypy napalm_device_types - - - name: Run unit tests - run: | - python -m pytest -q --tb=short - - - name: Build wheel and sdist - run: | - python -m pip install build - python -m build - - - name: Upload dist artifacts - # v4 refuses to run on Gitea ("not currently supported on GHES"). - uses: actions/upload-artifact@v3 - with: - name: dist-${{ matrix.python-version }} - path: dist/* \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..4ccc0f8 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,17 @@ +# Changelog + +All notable changes to napalm-device-types. The format follows +[Keep a Changelog](https://keepachangelog.com/), versions follow +[Semantic Versioning](https://semver.org/). Versions up to 4.21.0 were not +recorded here; their history is the git log. + +## [Unreleased] + +### Changed +- The package follows the NAPALM driver standard + (https://git.netork.io/NAPALM/driver-standard): CI on Gitea runs ruff, strict + mypy, the tests on Python 3.10–3.13 and at the lowest declared versions, + bandit, pip-audit and a build check, and a release tag publishes to PyPI. +- Type annotations use builtin generics (`list[str]`, `X | None`) instead of + `typing.List` and `Optional`. They mean the same to a type checker. +- The project links point at git.netork.io instead of GitHub. diff --git a/README.md b/README.md index 1689662..b675bbf 100644 --- a/README.md +++ b/README.md @@ -569,7 +569,7 @@ from napalm_device_types.models import ( ## Development ```bash -git clone https://github.com/chrismanivong/napalm-device-types.git +git clone https://git.netork.io/NAPALM/napalm-device-types.git cd napalm-device-types pip install -e ".[dev]" ``` @@ -582,10 +582,15 @@ mypy napalm_device_types ## Contributing -1. Fork the repository -2. Create a feature branch (`git checkout -b feature/router-driver`) -3. Implement your changes -4. Open a Pull Request +This package follows the +[NAPALM driver standard](https://git.netork.io/NAPALM/driver-standard/src/branch/main/STANDARDS.md): +test first, ruff and strict mypy, Conventional Commits, one pull request per change +against `main`. CI checks what a tool can check: + +```bash +pip install "napalm-standard @ git+https://git.netork.io/NAPALM/driver-standard.git" +napalm-standard check && napalm-standard ratchet +``` ## License diff --git a/pyproject.toml b/pyproject.toml index e6e83da..fb84677 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=68", "wheel"] +requires = ["setuptools>=77"] build-backend = "setuptools.build_meta" [project] @@ -8,7 +8,7 @@ version = "4.21.0" description = "Abstract device-type base classes for NAPALM drivers" readme = "README.md" requires-python = ">=3.10" -license = { text = "Apache-2.0" } +license = "Apache-2.0" authors = [ { name = "Christian Manivong", email = "christian@manivong.de" }, ] @@ -28,7 +28,6 @@ classifiers = [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Intended Audience :: System Administrators", - "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.10", @@ -45,16 +44,16 @@ dependencies = [ ] [project.urls] -Homepage = "https://github.com/chrismanivong/napalm-device-types" -Repository = "https://github.com/chrismanivong/napalm-device-types" -Issues = "https://github.com/chrismanivong/napalm-device-types/issues" +Repository = "https://git.netork.io/NAPALM/napalm-device-types" +Issues = "https://git.netork.io/NAPALM/napalm-device-types/issues" +Changelog = "https://git.netork.io/NAPALM/napalm-device-types/src/branch/main/CHANGELOG.md" [project.optional-dependencies] dev = [ - "pytest", - "mypy", - "build", - "twine", + "pytest>=8", + "pytest-cov>=5", + "mypy>=1.11", + "ruff>=0.6", ] [tool.setuptools.packages.find] @@ -79,3 +78,12 @@ select = ["E", "F", "I", "UP", "B"] python_version = "3.10" strict = true ignore_missing_imports = true + +[tool.pytest.ini_options] +testpaths = ["tests"] + +[tool.coverage.run] +source = ["napalm_device_types"] + +[tool.coverage.report] +fail_under = 95 diff --git a/tests/quality_baseline.json b/tests/quality_baseline.json new file mode 100644 index 0000000..488f4d5 --- /dev/null +++ b/tests/quality_baseline.json @@ -0,0 +1,39 @@ +{ + "coverage_floor": 95.0, + "function_complexity": { + "napalm_device_types/_ucd_metrics.py::build_if_metrics": 20, + "napalm_device_types/_ucd_metrics.py::collect_ucd_metrics": 17, + "napalm_device_types/host_firewall.py::_iptables_rule": 11, + "napalm_device_types/host_firewall.py::_module_match": 13, + "napalm_device_types/host_firewall.py::_module_options": 14, + "napalm_device_types/host_firewall.py::_nft_field": 15, + "napalm_device_types/host_firewall.py::_nft_match": 12, + "napalm_device_types/host_firewall.py::_nft_rule": 16, + "napalm_device_types/host_firewall.py::_parse_nft": 14, + "napalm_device_types/host_firewall.py::rule_text": 14, + "napalm_device_types/host_status.py::_reboot": 12, + "napalm_device_types/lag.py::add_lag_interfaces": 11, + "napalm_device_types/listening.py::parse_listening_sockets": 13, + "napalm_device_types/service_clusters.py::_patroni": 11, + "napalm_device_types/ssh_server.py::plan_ssh_hardening": 38, + "napalm_device_types/virtual_ips.py::_keepalived": 12 + }, + "function_lines": { + "napalm_device_types/_ucd_metrics.py::collect_ucd_metrics": 119, + "napalm_device_types/dhcp.py::DhcpServerMixin.diff_dhcp_reservations": 54, + "napalm_device_types/dhcp.py::DhcpServerMixin.diff_dhcp_subnets": 60, + "napalm_device_types/firewall_rules.py::FirewallRuleMixin.diff_firewall_rules": 56, + "napalm_device_types/hypervisor.py::HypervisorDriver.create_vm_from_cloud_init": 84, + "napalm_device_types/hypervisor.py::HypervisorDriver.get_vm_config": 77, + "napalm_device_types/ssh_server.py::OpenSshServerMixin.harden_ssh_server": 52, + "napalm_device_types/ssh_server.py::plan_ssh_hardening": 60, + "napalm_device_types/storage.py::StorageDriver.get_volumes": 52, + "napalm_device_types/switch.py::SwitchDriver.get_dot1x_ports": 51, + "napalm_device_types/switch.py::SwitchDriver.get_poe_status": 63 + }, + "mypy_relaxed": [], + "python_file_lines": { + "napalm_device_types/models.py": 1504 + }, + "untyped_public": [] +}