Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GHA workflow to run lint and tests #27

Merged
merged 25 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a863690
add pyproject.toml
mfiedorowicz Aug 9, 2024
9821415
add docker-compose setup
mfiedorowicz Aug 9, 2024
8b1ee6b
add Makefile recipes for docker compose
mfiedorowicz Aug 9, 2024
c8a2e3d
add GHA workflow to run lint and test
mfiedorowicz Aug 9, 2024
bbc62c3
tidy up docker-compose.yaml
mfiedorowicz Aug 9, 2024
d911394
move workflow into correct directory
mfiedorowicz Aug 9, 2024
0a2f840
fix mounting of local_settings.py
mfiedorowicz Aug 9, 2024
d94c7b8
ignore missing docstrings checks
mfiedorowicz Aug 9, 2024
8404909
add step for building documentation
mfiedorowicz Aug 9, 2024
d3346aa
catch make docker-compose-test exit code (test)
mfiedorowicz Aug 9, 2024
e8ac7c8
catch make docker-compose-test exit code (test 2)
mfiedorowicz Aug 9, 2024
c2fadb6
tidy up make docker-compose-test
mfiedorowicz Aug 9, 2024
3134545
rename GHA job
mfiedorowicz Aug 9, 2024
31c6e87
ignore all missing docstrings
mfiedorowicz Aug 9, 2024
4751e8a
change workflow file ext
mfiedorowicz Aug 9, 2024
fecda42
Merge branch 'develop' into feat/gha-workflows-lint-test
mfiedorowicz Aug 12, 2024
b24b506
Merge branch 'develop' into feat/gha-workflows-lint-test
mfiedorowicz Aug 19, 2024
3b60250
run tests with more native way with matrix of python versions
mfiedorowicz Aug 19, 2024
111a641
fix matrix with python version
mfiedorowicz Aug 19, 2024
8632f4a
fix test command for plugin
mfiedorowicz Aug 19, 2024
114304f
list tests
mfiedorowicz Aug 19, 2024
ec39e30
comment out exclude-package-data from pyproject.toml
mfiedorowicz Aug 19, 2024
99c7a9a
tidy up
mfiedorowicz Aug 19, 2024
3c558a4
keep db when running tests
mfiedorowicz Aug 19, 2024
ee9bed5
Remove v4.1-beta1 tag
jeremystretch Sep 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions .github/workflows/lint-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Lint and tests
on:
workflow_dispatch:
pull_request:
push:
branches:
- "!release"

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

permissions:
contents: write
checks: write
pull-requests: write

jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
pip install .[dev]
pip install .[test]
- name: Build documentation
run: mkdocs build
- name: Lint with Ruff
run: |
ruff check --output-format=github netbox_branching/
continue-on-error: true
tests:
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
python-version: [ "3.10", "3.11", "3.12" ]
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: Checkout netbox-branching
uses: actions/checkout@v4
with:
path: netbox-branching
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Checkout netbox
uses: actions/checkout@v4
with:
repository: "netbox-community/netbox"
path: netbox
- name: Install netbox-branching
working-directory: netbox-branching
run: |
# Include tests directory for test
sed -i 's/exclude-package-data/#exclude-package-data/g' pyproject.toml
python -m pip install --upgrade pip
pip install .
pip install .[test]
- name: Install dependencies & configure plugin
working-directory: netbox
run: |
ln -s $(pwd)/../netbox-branching/testing/configuration.py netbox/netbox/configuration.py
ln -s $(pwd)/../netbox-branching/testing/local_settings.py netbox/netbox/local_settings.py

python -m pip install --upgrade pip
pip install -r requirements.txt -U
- name: Run tests
working-directory: netbox
run: |
python netbox/manage.py test netbox_branching.tests --keepdb
38 changes: 38 additions & 0 deletions testing/configuration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
###################################################################
# 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_branching",
]

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

SECRET_KEY = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
12 changes: 12 additions & 0 deletions testing/local_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from netbox_branching.utilities import DynamicSchemaDict
from .configuration import DATABASE

# Wrap DATABASES with DynamicSchemaDict for dynamic schema support
DATABASES = DynamicSchemaDict({
'default': DATABASE,
})

# Employ our custom database router
DATABASE_ROUTERS = [
'netbox_branching.database.BranchAwareRouter',
]
Loading