Skip to content

Development

DenAV edited this page Feb 22, 2026 · 1 revision

Development

Branching Strategy

feature/fix-xxx  →  develop  →  main  →  release (tag vX.Y.Z)
                      ↑           ↑
                  lint + unit   lint + unit + molecule
Branch Purpose
feature/* or fix/* New features or bug fixes
develop Integration branch — collects all changes
main Stable release branch

Workflow

  1. Create a branch from develop: git checkout -b fix/issue-42
  2. Make changes, write tests
  3. Push and create PR to develop
  4. CI runs: ansible-lint + flake8 + syntax-check + pytest
  5. After review — squash merge to develop
  6. When develop is stable — PR to main
  7. CI runs: lint + unit tests + Molecule integration tests
  8. After merge to main — create tag and GitHub Release

CI/CD Pipelines

CI — Lint & Unit Tests (.github/workflows/ci.yml)

Triggers on push/PR to develop:

Job What it does
Lint ansible-lint . + flake8 library/
Syntax Check ansible-playbook --syntax-check
Unit Tests pytest tests/ -v

Integration (.github/workflows/integration.yml)

Triggers on PR to main:

Job What it does
Molecule Starts NPM in Docker, runs full role convergence, verifies via API

Running Tests Locally

Prerequisites

pip install -r requirements-dev.txt

Unit Tests

pytest tests/ -v --tb=short

Tests mock the requests library — no running NPM instance needed. Works on both Linux and Windows.

Linting

# Ansible lint
ansible-lint .

# Python lint
flake8 library/

Molecule (requires Docker)

molecule test

This will:

  1. Start NPM container (ports 3080/3081/3443)
  2. Wait for API readiness
  3. Run the role (create a test proxy host)
  4. Verify the proxy host exists via API
  5. Destroy the container

Test Structure

tests/
└── test_npm_proxy.py    # 22 unit tests
    ├── TestBuildUrl         — URL construction for each action
    ├── TestHttpRequest      — HTTP method dispatch, timeout, error handling
    ├── TestSearchProxyHost  — Search logic (found / not found)
    ├── TestCreateProxyHost  — Create logic (new / exists / ssl / error)
    └── TestDeleteProxyHost  — Delete logic (with cert / without / not found)

molecule/default/
├── molecule.yml    # Docker driver config
├── converge.yml    # Role execution
└── verify.yml      # API assertions

Code Style

  • Python: flake8 with max-line-length = 120, E402 ignored for Ansible modules (see .flake8)
  • Ansible: ansible-lint default rules
  • Commits: Conventional Commitsfeat(), fix(), docs(), test()

Secrets

  • Never commit api_secret.yml — it's in .gitignore
  • Use ansible-vault for encryption
  • Module parameter token has no_log: True in argument_spec

Creating Issues

Use labels for priority:

  • priority: P0 (red) — Critical, fix immediately
  • priority: P1 (orange) — Important, next sprint
  • priority: P2 (yellow) — Long-term improvements

Clone this wiki locally