Merge pull request 'ci: run the tests and build the package on every push and pull request' (#14) from ci/workflow into master
CI / test (3.10) (push) Successful in 33s
CI / test (3.11) (push) Successful in 31s
CI / test (3.12) (push) Successful in 37s

This commit was merged in pull request #14.
This commit is contained in:
2026-10-07 06:51:13 +00:00
2 changed files with 56 additions and 1 deletions
+48
View File
@@ -0,0 +1,48 @@
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"]
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
# napalm-device-types lives in git.netork.io/NAPALM, not on PyPI: without this
# pip looks there, finds an unrelated 0.1.0 and the job dies before any test.
python -m pip install "napalm-device-types @ git+https://git.netork.io/NAPALM/napalm-device-types.git"
python -m pip install -e ".[dev]"
- 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/*
+8 -1
View File
@@ -459,7 +459,13 @@ def test_destroy_vm_success():
def test_destroy_vm_already_stopped(): def test_destroy_vm_already_stopped():
"""destroy_vm succeeds even if VM already stopped.""" """destroy_vm succeeds even if VM already stopped.
Proxmox refuses to stop a VM that is not running, so the stop call raises.
(A bare MagicMock as the stop task never reports "stopped": _wait_for_task
then spun for the full timeout with sleep patched out, and every recorded
mock call made the test take 60 s and several GB, enough for CI to kill it.)
"""
mixin = ProxmoxVMProvisionMixin() mixin = ProxmoxVMProvisionMixin()
mock_node = MagicMock() mock_node = MagicMock()
@@ -468,6 +474,7 @@ def test_destroy_vm_already_stopped():
# Mock VM operations # Mock VM operations
mock_vm = MagicMock() mock_vm = MagicMock()
mock_node.qemu.return_value = mock_vm mock_node.qemu.return_value = mock_vm
mock_vm.status.stop.post.side_effect = Exception("VM 101 not running")
mock_vm.config.get.return_value = {} mock_vm.config.get.return_value = {}
mock_vm.delete.return_value = None mock_vm.delete.return_value = None