Skip to content

[Housekeeping]: Move CI off NetBox Docker images; install NetBox during workflow (generic runner) #285

@pheus

Description

@pheus

Proposed Changes

  1. Replace the Docker-based test step with an explicit test job on ubuntu-latest:
    • Check out the plugin and NetBox source.
    • actions/setup-python for a Python matrix (3.10/3.11/3.12).
    • pip install -r requirements.txt for NetBox deps.
    • pip install -e . for the plugin.
    • Provide Postgres and Redis via workflow services.
    • Use a small CI config file to register the plugin & point NetBox at Postgres/Redis.
    • Run manage.py check and manage.py test for netbox_acls.
  2. Add .ci/configuration.testing.py to this repo.
  3. Keep Dockerfile/docker-compose.yml for local dev; CI no longer depends on them.
  4. (Optional) Remove or simplify test.sh if no longer needed.

Justification

  1. Reliability & control – Pin NetBox versions in CI without relying on external container tags.
  2. Clarity & debuggability – Replace ./test.sh with explicit steps (install deps, configure NetBox, run tests).
  3. Consistency – Mirrors the cookiecutter approach used across the ecosystem.
  4. Version matrix – Test multiple Python/NetBox versions with a simple matrix.

Acceptance criteria

  • CI runs on ubuntu-latest with Postgres & Redis services (no NetBox Docker image dependency).
  • NetBox is installed during the workflow and wired to those services.
  • The plugin is installed and discoverable by NetBox.
  • python netbox/manage.py check succeeds; python netbox/manage.py test netbox_acls.tests runs (OK even if 0 tests).
  • Matrix includes at least:
    • Python: 3.10, 3.11, 3.12
    • NetBox: a 4.3.x ref, a 4.4.x ref, and main

Implementation plan (checklist)

  • Add .ci/configuration.testing.py (example below).
  • Update .github/workflows/ci.yml test job (example below).
  • Decide whether to keep or remove test.sh.
  • Add a short note in CONTRIBUTING.md describing the CI strategy.

Example: .github/workflows/ci.yml (test job excerpt)

name: CI

on:
  push:
  pull_request:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  run-lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with: { fetch-depth: 0 }
      - name: Lint Code Base
        uses: github/super-linter/slim@v7
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          DEFAULT_BRANCH: dev
          SUPPRESS_POSSUM: true
          LINTER_RULES_PATH: /
          VALIDATE_ALL_CODEBASE: false
          VALIDATE_DOCKERFILE: false
          VALIDATE_JSCPD: true
          FILTER_REGEX_EXCLUDE: (.*/)?(configuration/.*)

  test:
    name: Run tests [NB ${{ matrix.netbox-version }} | Py ${{ matrix.python-version }}]
    runs-on: ubuntu-latest
    needs: run-lint
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.10", "3.11", "3.12"]
        netbox-version: ["v4.3.0", "v4.4.0", "main"]
    services:
      postgres:
        image: postgres:16
        env:
          POSTGRES_USER: netbox
          POSTGRES_PASSWORD: netbox
          POSTGRES_DB: netbox
        options: >-
          --health-cmd "pg_isready -U netbox"
          --health-interval 10s --health-timeout 5s --health-retries 5
        ports: ["5432:5432"]
      redis:
        image: redis:7
        ports: ["6379:6379"]

    steps:
      - name: Checkout plugin
        uses: actions/checkout@v4
        with:
          path: netbox_acls

      - name: Checkout NetBox ${{ matrix.netbox-version }}
        uses: actions/checkout@v4
        with:
          repository: netbox-community/netbox
          ref: ${{ matrix.netbox-version }}
          path: netbox

      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
          cache: pip

      - name: Install NetBox dependencies
        working-directory: netbox
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt -U

      - name: Install plugin (editable)
        working-directory: netbox_acls
        run: |
          pip install -e ".[test]" || pip install -e .

      - name: Configure NetBox for tests
        working-directory: netbox
        run: |
          ln -sf "$PWD/../netbox_acls/.ci/configuration.testing.py" netbox/netbox/configuration.py

      - name: Django checks & tests
        working-directory: netbox
        run: |
          python netbox/manage.py check
          python netbox/manage.py test netbox_acls.tests --parallel -v 2

Example: .ci/configuration.testing.py

# Minimal NetBox configuration for CI tests
SECRET_KEY = "testing"
ALLOWED_HOSTS = ["*"]

# Register the plugin under test
PLUGINS = ["netbox_acls"]
PLUGINS_CONFIG = {"netbox_acls": {}}

# Database (matches the postgres service in CI)
DATABASE = {
    "NAME": "netbox",
    "USER": "netbox",
    "PASSWORD": "netbox",
    "HOST": "localhost",
    "PORT": 5432,
    "CONN_MAX_AGE": 300,
    "ENGINE": "django.db.backends.postgresql",
}

# Redis (matches the redis service in CI)
REDIS = {
    "tasks": {"HOST": "localhost", "PORT": 6379, "DATABASE": 0, "SSL": False},
    "caching": {"HOST": "localhost", "PORT": 6379, "DATABASE": 1, "SSL": False},
}

# Keep logging minimal in CI
LOGGING = {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    housekeepingChanges to the application which do not directly impact the end user

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions