Skip to content

Commit

Permalink
Merge pull request #104 from tobiasge/prepare-nb-4.1
Browse files Browse the repository at this point in the history
Prepare for Netbox 4.1
  • Loading branch information
tobiasge authored Sep 3, 2024
2 parents b3fb7c7 + 501c9ab commit 642a5e2
Show file tree
Hide file tree
Showing 70 changed files with 511 additions and 299 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ name: "CodeQL"

on:
push:
branches: [ "main" ]
branches: ["main"]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "main" ]
branches: ["main"]
schedule:
- cron: '38 4 * * 2'
- cron: "38 4 * * 2"

jobs:
analyze:
Expand All @@ -20,15 +20,15 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'python' ]
language: ["python"]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
- name: Checkout repository
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
10 changes: 7 additions & 3 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@ jobs:
# list of changed files within `super-linter`
fetch-depth: 0
- name: Lint Code Base
uses: github/super-linter@v5
uses: github/super-linter@v7
env:
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SUPPRESS_POSSUM: true
VALIDATE_ALL_CODEBASE: false
VALIDATE_CHECKOV: false
VALIDATE_JSCPD: false
VALIDATE_PYTHON_BLACK: false
VALIDATE_PYTHON_ISORT: false
VALIDATE_PYTHON_MYPY: false
VALIDATE_PYTHON_PYINK: false
VALIDATE_PYTHON_PYLINT: false
LINTER_RULES_PATH: /
PYTHON_BLACK_CONFIG_FILE: pyproject.toml
FILTER_REGEX_EXCLUDE: (.*/)?(LICENSE)
YAML_CONFIG_FILE: .yamllint.yaml
PYTHON_FLAKE8_CONFIG_FILE: .flake8
PYTHON_ISORT_CONFIG_FILE: pyproject.toml
15 changes: 12 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,17 @@ jobs:
- id: git-checkout
name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install uv
run: pip install uv
- id: build-and-publish
name: Build and publish to pypi
uses: JRubics/poetry-publish@v2.0
with:
pypi_token: ${{ secrets.PYPI_TOKEN }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
TWINE_NON_INTERACTIVE: "true"
run: |
uvx --from build pyproject-build
uvx twine upload dist/*
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ Load data from YAML files into Netbox
## Installation

First activate your virtual environment where Netbox is installed, the install the plugin version correspondig to your Netbox version.

```bash
pip install "netbox-initializers==4.0.*"
pip install "netbox-initializers==4.1.*"
```

Then you need to add the plugin to the `PLUGINS` array in the Netbox configuration.

```python
PLUGINS = [
'netbox_initializers',
Expand All @@ -29,13 +32,12 @@ After you filled in the data you want to import, the import can be started with
./manage.py load_initializer_data --path /path/for/example/files
```


## Netbox Docker image

The initializers where a part of the Docker image and where then extracted into a Netbox plugin. This was done to split the release cycle of the initializers and the image.
To use the new plugin in a the Netbox Docker image, it musst be installad into the image. To this, the following example can be used as a starting point:

```dockerfile
FROM netboxcommunity/netbox:v4.0
RUN /opt/netbox/venv/bin/pip install "netbox-initializers==4.0.*"
FROM netboxcommunity/netbox:v4.1
RUN /opt/netbox/venv/bin/pip install "netbox-initializers==4.1.*"
```
8 changes: 4 additions & 4 deletions docs/dev/Release.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Checkout the branch for which the release is to be build. If no branch exists fo

### Set version number

For patch releases the version number in `pyproject.toml` and the `NetBoxInitializersConfig` needs to be updated. If the release is for a new Netbox version additional changes need to be made in `README.md` and `Dockerfile` (for tests).
For patch releases the version number in `src/netbox_initializers/version.py` needs to be updated. If the release is for a new Netbox version additional changes need to be made in `README.md` and `Dockerfile` (for tests).

### Build the release automatically

Expand All @@ -25,17 +25,17 @@ After changing the version numbers and committing them create a new release with
Install the needed Python packages for the build:

```bash
pip install --upgrade poetry
pip install --upgrade uv
```

Then run the build for the wheel and source distributions:

```bash
poetry build
uvx --from build pyproject-build --installer uv
```

#### Upload packages to PyPi

```bash
poetry publish
uvx twine upload dist/*
```
55 changes: 35 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,34 +1,49 @@
[tool.poetry]
authors = ["Tobias Genannt <tobias.genannt@gmail.com>"]
[project]
name = "netbox-initializers"
authors = [{ name = "Tobias Genannt", email = "tobias.genannt@gmail.com" }]
classifiers = [
"Framework :: Django",
"Environment :: Plugins",
"Topic :: System :: Networking",
"Topic :: System :: Systems Administration"
"Topic :: System :: Systems Administration",
]
description = "Load initial data into Netbox"
license = "Apache-2.0"
name = "netbox-initializers"
readme = "README.md"
repository = "https://github.com/tobiasge/netbox-initializers"
version = "4.0.0"
license = "Apache-2.0"
dynamic = ["version"]

[tool.poetry.dependencies]
python = "^3.8"
"ruamel.yaml" = "0.18.6"
requires-python = ">=3.10"
dependencies = ["ruamel-yaml>=0.18.6"]

[build-system]
build-backend = "poetry.core.masonry.api"
requires = ["poetry-core"]
requires = ["hatchling"]
build-backend = "hatchling.build"


[tool.black]
line_length = 100
target-version = ['py310']
[tool.hatch.version]
path = "src/netbox_initializers/version.py"

[tool.isort]
line_length = 100
multi_line_output = 3
profile = "black"
[tool.uv]
dev-dependencies = ["ruff==0.6.3"]

[tool.ruff]
line-length = 100
target-version = "py311"

[tool.ruff.lint]
extend-select = ["I", "PL", "W191", "W291", "W292", "W293"]
ignore = ["PLR0912", "PLR0915"]

[tool.ruff.lint.isort]
section-order = [
"future",
"standard-library",
"third-party",
"first-party",
"local-folder",
]

[tool.pylint.format]
max-line-length = "100"
[tool.ruff.format]
docstring-code-format = true
docstring-code-line-length = "dynamic"
8 changes: 5 additions & 3 deletions src/netbox_initializers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
from netbox.plugins import PluginConfig

from netbox_initializers.version import VERSION


class NetBoxInitializersConfig(PluginConfig):
name = "netbox_initializers"
verbose_name = "NetBox Initializers"
description = "Load initial data into Netbox"
version = "4.0.0"
version = VERSION
base_url = "initializers"
min_version = "4.0-beta1"
max_version = "4.0.99"
min_version = "4.1-beta1"
max_version = "4.1.99"


config = NetBoxInitializersConfig
Loading

0 comments on commit 642a5e2

Please sign in to comment.