Skip to content

Commit

Permalink
Add Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DanSheps committed Mar 20, 2024
1 parent 4bf88a1 commit c551332
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 0 deletions.
75 changes: 75 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: CI
on: [push, pull_request]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
env:
NETBOX_CONFIGURATION: netbox.configuration_lifecycle
strategy:
matrix:
python-version: ['3.11'] # '3.8', '3.9', '3.10',
node-version: ['14.x']
services:
redis:
image: redis
ports:
- 6379:6379
postgres:
image: postgres
env:
POSTGRES_USER: netbox
POSTGRES_PASSWORD: netbox
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

steps:
- name: Check out NetBox
uses: actions/checkout@v4
with:
repository: 'netbox-community/netbox'
ref: 'master'
path: 'netbox'


- name: Check out repo
uses: actions/checkout@v4
with:
path: 'netbox-lifecycle'

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

- name: Install dependencies & set up configuration
run: |
python -m pip install --upgrade pip
pip install -r netbox/requirements.txt
pip install pycodestyle coverage tblib
pip install -e netbox-lifecycle
- name: Copy configuration
run: |
cp netbox-lifecycle/contrib/configuration_lifecycle.py netbox/netbox/netbox/configuration_lifecycle.py
- name: Collect static files
run: python netbox/netbox/manage.py collectstatic --no-input

- name: Check for missing migrations
run: python netbox/netbox/manage.py makemigrations --check

- name: Check PEP8 compliance
run: pycodestyle --ignore=W504,E501 netbox-lifecycle/netbox_lifecycle

- name: Run tests
run: coverage run --source="netbox-lifecycle/netbox_lifecycle/" netbox/manage.py test netbox-lifecycle/netbox_lifecycle/ --parallel

- name: Show coverage report
run: coverage report --skip-covered --omit '*/migrations/*,*/tests/*'
47 changes: 47 additions & 0 deletions contrib/configuration_lifecycle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
###################################################################
# This file serves as a base configuration for testing purposes #
# only. It is not intended for production use. #
###################################################################

ALLOWED_HOSTS = ['*']

DATABASE = {
'NAME': 'netbox',
'USER': 'netbox',
'PASSWORD': 'netbox',
'HOST': 'localhost',
'PORT': '',
'CONN_MAX_AGE': 300,
}

PLUGINS = [
'netbox_lifecycle',
]

REDIS = {
'tasks': {
'HOST': 'localhost',
'PORT': 6379,
'USERNAME': '',
'PASSWORD': '',
'DATABASE': 0,
'SSL': False,
},
'caching': {
'HOST': 'localhost',
'PORT': 6379,
'USERNAME': '',
'PASSWORD': '',
'DATABASE': 1,
'SSL': False,
}
}

SECRET_KEY = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'

DEFAULT_PERMISSIONS = {}

LOGGING = {
'version': 1,
'disable_existing_loggers': True
}

0 comments on commit c551332

Please sign in to comment.