diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..9ba2f5a --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,12 @@ +FROM mcr.microsoft.com/devcontainers/python:3 + +RUN python -m pip install --upgrade pip \ + && python -m pip install 'flit>=3.8.0' + +ENV FLIT_ROOT_INSTALL=1 + +COPY pyproject.toml . +RUN touch README.md \ + && mkdir -p src/python_package \ + && python -m flit install --only-deps --deps develop \ + && rm -r pyproject.toml README.md src diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..c4cf1ea --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,44 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: +// https://github.com/microsoft/vscode-dev-containers/tree/v0.222.0/containers/python-3-miniconda +{ + "name": "Python Environment", + "build": { + "dockerfile": "Dockerfile", + "context": ".." + }, + "customizations": { + "vscode": { + "extensions": [ + "editorconfig.editorconfig", + "github.vscode-pull-request-github", + "ms-azuretools.vscode-docker", + "ms-python.python", + "ms-python.vscode-pylance", + "ms-python.pylint", + "ms-python.isort", + "ms-python.flake8", + "ms-python.black-formatter", + "ms-vsliveshare.vsliveshare", + "ryanluker.vscode-coverage-gutters", + "bungcip.better-toml", + "GitHub.copilot" + ], + "settings": { + "python.defaultInterpreterPath": "/usr/local/bin/python", + "black-formatter.path": [ + "/usr/local/py-utils/bin/black" + ], + "pylint.path": [ + "/usr/local/py-utils/bin/pylint" + ], + "flake8.path": [ + "/usr/local/py-utils/bin/flake8" + ], + "isort.path": [ + "/usr/local/py-utils/bin/isort" + ] + } + } + }, + "onCreateCommand": "pre-commit install-hooks" +} diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..6deafc2 --- /dev/null +++ b/.flake8 @@ -0,0 +1,2 @@ +[flake8] +max-line-length = 120 diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 668b9aa..0000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: bug -assignees: '' - ---- - -**NetBox version** -What version of NetBox are you currently running? - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Screenshots** -If applicable, add screenshots to help explain your problem. - -**Additional context** -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index a25ea21..208d244 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -2,10 +2,10 @@ blank_issues_enabled: false contact_links: - name: 📖 Contributing Policy - url: https://github.com/netbox_community/netbox_healthcheck_plugin/blob/main/CONTRIBUTING.md + url: https://github.com/netbox-community/netbox-healthcheck-plugin/blob/main/CONTRIBUTING.md about: "Please read through our contributing policy before opening an issue or pull request." - name: ❓ Discussion - url: https://github.com/netbox_community/netbox_healthcheck_plugin/discussions + url: https://github.com/netbox-community/netbox-healthcheck-plugin/discussions about: "If you're just looking for help, try starting a discussion instead." - name: 💬 Community Slack url: https://netdev.chat diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 11fc491..0000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: enhancement -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index 16b7f20..6a9e8ea 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -1,31 +1,51 @@ -# This workflows will upload a Python Package using Twine when a release is created -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries +# see: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ +name: Publish Python 🐍 distribution 📦 to PyPI -name: Upload Python Package - -on: - release: - types: [created] +on: push jobs: - deploy: - + build: + name: Build distribution 📦 runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5.1.0 + with: + python-version: "3.x" + - name: Install pypa/build + run: >- + python3 -m + pip install + build + --user + - name: Build a binary wheel and a source tarball + run: python3 -m build + - name: Store the distribution packages + uses: actions/upload-artifact@v4 + with: + name: python-package-distributions + path: dist/ + + publish-to-pypi: + name: >- + Publish Python 🐍 distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + needs: + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/netbox-healthcheck-plugin + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - python setup.py sdist bdist_wheel - twine upload dist/* + name: python-package-distributions + path: dist/ + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 47d6177..da4e9c6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,62 +3,20 @@ ci: autofix_commit_msg: "style: pre-commit fixes" repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.1.0 +- repo: https://github.com/psf/black + rev: 24.3.0 hooks: - - id: check-added-large-files - - id: check-case-conflict - - id: check-merge-conflict - - id: check-symlinks - - id: debug-statements - - id: end-of-file-fixer - - id: mixed-line-ending - - id: requirements-txt-fixer - - id: trailing-whitespace + - id: black + args: [--line-length=120] + language_version: python3.11 - - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.9.1 +- repo: https://github.com/PyCQA/flake8 + rev: 7.0.0 hooks: - - id: black - # It is recommended to specify the latest version of Python - # supported by your project here, or alternatively use - # pre-commit's default_language_version, see - # https://pre-commit.com/#top_level-default_language_version - language_version: python3.11 + - id: flake8 - - repo: https://github.com/PyCQA/isort - rev: 5.12.0 - hooks: - - id: isort - - - repo: https://github.com/pycqa/flake8 - rev: '6.1.0' - hooks: - - id: flake8 - additional_dependencies: [ - 'flake8-bugbear==23.9.16', - 'flake8-pyproject==1.2.3', - ] - - - repo: https://github.com/pre-commit/pygrep-hooks - rev: v1.9.0 - hooks: - - id: python-check-blanket-noqa - - id: python-check-blanket-type-ignore - - id: python-no-log-warn - - id: python-no-eval - - id: python-use-type-annotations - - id: rst-backticks - - id: rst-directive-colons - - id: rst-inline-touching-normal - - - repo: https://github.com/mgedmin/check-manifest - rev: "0.47" +- repo: https://github.com/mgedmin/check-manifest + rev: "0.49" hooks: - id: check-manifest stages: [manual] - - - repo: https://github.com/PyCQA/bandit - rev: '1.7.5' - hooks: - - id: bandit diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b2548b..9f2e954 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 0.1.2 (2024-04-08) + +* Fix django-health-check dependency in pyproject.toml + +## 0.1.2 (2024-04-05) + +* General cleanup + ## 0.1.0 (2023-01-18) * First release on PyPI. + diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index 9c41a18..0000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,133 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We as members, contributors, and leaders pledge to make participation in our -community a harassment-free experience for everyone, regardless of age, body -size, visible or invisible disability, ethnicity, sex characteristics, gender -identity and expression, level of experience, education, socio-economic status, -nationality, personal appearance, race, caste, color, religion, or sexual -identity and orientation. - -We pledge to act and interact in ways that contribute to an open, welcoming, -diverse, inclusive, and healthy community. - -## Our Standards - -Examples of behavior that contributes to a positive environment for our -community include: - -* Demonstrating empathy and kindness toward other people -* Being respectful of differing opinions, viewpoints, and experiences -* Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, - and learning from the experience -* Focusing on what is best not just for us as individuals, but for the overall - community - -Examples of unacceptable behavior include: - -* The use of sexualized language or imagery, and sexual attention or advances of - any kind -* Trolling, insulting or derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or email address, - without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Enforcement Responsibilities - -Community leaders are responsible for clarifying and enforcing our standards of -acceptable behavior and will take appropriate and fair corrective action in -response to any behavior that they deem inappropriate, threatening, offensive, -or harmful. - -Community leaders have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions that are -not aligned to this Code of Conduct, and will communicate reasons for moderation -decisions when appropriate. - -## Scope - -This Code of Conduct applies within all community spaces, and also applies when -an individual is officially representing the community in public spaces. -Examples of representing our community include using an official e-mail address, -posting via an official social media account, or acting as an appointed -representative at an online or offline event. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the community leaders responsible for enforcement at -[ahanson@netboxlabs.com](mailto:ahanson@netboxlabs.com). -All complaints will be reviewed and investigated promptly and fairly. - -All community leaders are obligated to respect the privacy and security of the -reporter of any incident. - -## Enforcement Guidelines - -Community leaders will follow these Community Impact Guidelines in determining -the consequences for any action they deem in violation of this Code of Conduct: - -### 1. Correction - -**Community Impact**: Use of inappropriate language or other behavior deemed -unprofessional or unwelcome in the community. - -**Consequence**: A private, written warning from community leaders, providing -clarity around the nature of the violation and an explanation of why the -behavior was inappropriate. A public apology may be requested. - -### 2. Warning - -**Community Impact**: A violation through a single incident or series of -actions. - -**Consequence**: A warning with consequences for continued behavior. No -interaction with the people involved, including unsolicited interaction with -those enforcing the Code of Conduct, for a specified period of time. This -includes avoiding interactions in community spaces as well as external channels -like social media. Violating these terms may lead to a temporary or permanent -ban. - -### 3. Temporary Ban - -**Community Impact**: A serious violation of community standards, including -sustained inappropriate behavior. - -**Consequence**: A temporary ban from any sort of interaction or public -communication with the community for a specified period of time. No public or -private interaction with the people involved, including unsolicited interaction -with those enforcing the Code of Conduct, is allowed during this period. -Violating these terms may lead to a permanent ban. - -### 4. Permanent Ban - -**Community Impact**: Demonstrating a pattern of violation of community -standards, including sustained inappropriate behavior, harassment of an -individual, or aggression toward or disparagement of classes of individuals. - -**Consequence**: A permanent ban from any sort of public interaction within the -community. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], -version 2.1, available at -[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. - -Community Impact Guidelines were inspired by -[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. - -For answers to common questions about this code of conduct, see the FAQ at -[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at -[https://www.contributor-covenant.org/translations][translations]. - -[homepage]: https://www.contributor-covenant.org -[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html -[Mozilla CoC]: https://github.com/mozilla/diversity -[FAQ]: https://www.contributor-covenant.org/faq -[translations]: https://www.contributor-covenant.org/translations diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4c39794..272e5a0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -60,7 +60,7 @@ If you are proposing a feature: ## Get Started! -Ready to contribute? Here's how to set up `netbox_healthcheck_plugin` for local development. +Ready to contribute? Here's how to set up `netbox-healthcheck-plugin` for local development. 1. Fork the `netbox-healthcheck-plugin` repo on GitHub. 2. Clone your fork locally diff --git a/MANIFEST.in b/MANIFEST.in index ca948a2..fc5d3a7 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -7,3 +7,5 @@ recursive-exclude * __pycache__ recursive-exclude * *.py[co] recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif + +graft templates diff --git a/README.md b/README.md index 8bcf783..20701b1 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,13 @@ # NetBox HealthCheck Plugin +NetBox plugin for HealthCheck. + NetBox provides health check monitors that can be queried to make sure that the service is running in good condition. -NetBox exposes metrics at the `/healthcheck` HTTP endpoint, e.g. `https://netbox.local/healthcheck`. It allows monitor conditions via HTTP(S), with responses available in HTML and JSON formats. +NetBox exposes metrics at the `/healthcheck` HTTP endpoint under the plugin, e.g. `https://netbox.local/plugins/netbox_healthcheck_plugin/healthcheck/`. It allows monitor conditions via HTTP(S), with responses available in HTML and JSON formats. * Free software: Apache-2.0 -* Documentation: https://netbox-community.github.io/netbox-healthcheck-plugin/. +* Documentation: https://netbox-community.github.io/netbox-healthcheck-plugin/ ## Features @@ -16,7 +18,9 @@ The features the plugin provides should be listed here. | NetBox Version | Plugin Version | |----------------|----------------| -| 3.4 - 3.6 | 0.1.0 | +| 3.4 - 3.7 | 0.1.0 | +| 3.4 - 3.7 | 0.1.2 | +| 3.4 - 3.7 | 0.1.3 | ## Installing @@ -40,7 +44,7 @@ Enable the plugin in `/opt/netbox/netbox/netbox/configuration.py`, ```python PLUGINS = [ - "netbox_healthcheck_plugin", + 'netbox_healthcheck_plugin' ] PLUGINS_CONFIG = { diff --git a/mkdocs.yml b/mkdocs.yml index b3b9e05..9c18618 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,7 +1,7 @@ site_name: NetBox HealthCheck Plugin -site_url: https://arthanson.github.io/netbox_healthcheck_plugin -repo_url: https://github.com/arthanson/netbox_healthcheck_plugin -repo_name: arthanson/netbox_healthcheck_plugin +site_url: https://netbox-community.github.io/netbox-healthcheck-plugin +repo_url: https://github.com/netbox-community/netbox-healthcheck-plugin +repo_name: netbox-community/netbox-healthcheck-plugin #strict: true nav: - Home: index.md @@ -20,9 +20,10 @@ theme: - navigation.instant - navigation.tabs.sticky markdown_extensions: + - attr_list - pymdownx.emoji: - emoji_index: !!python/name:materialx.emoji.twemoji - emoji_generator: !!python/name:materialx.emoji.to_svg + emoji_index: !!python/name:material.extensions.emoji.twemoji + emoji_generator: !!python/name:material.extensions.emoji.to_svg - pymdownx.critic - pymdownx.caret - pymdownx.mark @@ -48,7 +49,7 @@ plugins: lang: en - mkdocstrings: watch: - - netbox_healthcheck_plugin + - netbox-healthcheck-plugin extra: social: - icon: fontawesome/brands/twitter @@ -60,7 +61,7 @@ extra: link: https://github.com/netbox-community/cookiecutter-netbox-plugin name: Facebook - icon: fontawesome/brands/github - link: https://github.com/arthanson/netbox_healthcheck_plugin + link: https://github.com/netbox-community/netbox_healthcheck_plugin name: Github - icon: material/email link: "mailto:ahanson@netboxlabs.com" diff --git a/netbox_healthcheck_plugin/__init__.py b/netbox_healthcheck_plugin/__init__.py index fff25d7..0dc435f 100644 --- a/netbox_healthcheck_plugin/__init__.py +++ b/netbox_healthcheck_plugin/__init__.py @@ -2,7 +2,7 @@ __author__ = """Arthur Hanson""" __email__ = 'ahanson@netboxlabs.com' -__version__ = '0.1.0' +__version__ = '0.1.4' from netbox.plugins import PluginConfig diff --git a/pyproject.toml b/pyproject.toml index b62897d..36b8fcd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,11 +2,12 @@ # https://www.python.org/dev/peps/pep-0518/ [build-system] -requires = ["setuptools>=63.2.0", "wheel"] +requires = ["setuptools"] build-backend = "setuptools.build_meta" [project] name = "netbox-healthcheck-plugin" +version = "0.1.4" authors = [ {name = "Arthur Hanson", email = "ahanson@netboxlabs.com"}, ] @@ -18,15 +19,13 @@ classifiers=[ 'Intended Audience :: Developers', 'Natural Language :: English', "Programming Language :: Python :: 3 :: Only", - 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', ] requires-python = ">=3.8.1" -# dynamic = ["version"] -version = "0.1.1" dependencies = [ 'django-health-check >= 3,<4' @@ -34,19 +33,12 @@ dependencies = [ [project.optional-dependencies] test = [ - "bandit[toml]==1.7.5", - "black==23.3.0", + "black==24.3.0", "check-manifest==0.49", - "flake8-bugbear==23.5.9", "flake8", "flake8-pyproject", - "pre-commit==3.3.1", - "pylint==2.17.4", - "pytest-mock<3.10.1", - "pytest-runner", - "pytest==7.3.1", - "pytest-github-actions-annotate-failures", - "shellcheck-py==0.9.0.2" + "pre-commit==3.7.0", + "pytest==8.1.1", ] [project.urls] @@ -54,54 +46,9 @@ Documentation = "https://github.com/netbox-community/netbox-healthcheck-plugin/b Source = "https://github.com/netbox-community/netbox-healthcheck-plugin" Tracker = "https://github.com/netbox-community/netbox-healthcheck-plugin/issues" -[tool.setuptools] -packages = ["netbox_healthcheck_plugin"] - -[tool.setuptools.package-data] -netbox_healthcheck_plugin = ["templates/**"] - -[tool.bandit] -exclude_dirs = ["build","dist","tests","scripts","docs"] -number = 4 -recursive = true -targets = "netbox_healthcheck_plugin" - [tool.black] line-length = 120 -target_version = ['py38', 'py39', 'py310', 'py311'] - -[tool.isort] -profile = "black" +target_version = ['py39', 'py310', 'py311', 'py312'] -[tool.pylint] -max-line-length = 120 - -[tool.flake8] -max-line-length = 120 -exclude = [ - ".eggs", - ".venv", - ".tox", - ".mypy_cache", - ".pytest_cache", - ".vscode", - ".github", - ".git", - "dist", - "docs", - "tests", -] -ignore = [ - "E722", - "B001", - "W503", - "E203", - "D100", # These are all for ignoring missing docstring - "D101", - "D102", - "D103", - "D104", - "D105", - "D106", - "F401" # unused import -] +[tool.setuptools.package-data] +netbox_healthcheck_plugin = ["templates/**"] diff --git a/requirements_dev.txt b/requirements_dev.txt index f5e7766..24f595e 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,6 +1,4 @@ -black==23.9.1 -bump2version==1.0.1 -flake8==6.1.0 -flit==3.9.0 -isort==5.12.0 -pip==22.2.1 +black==24.3.0 +flake8==7.0.0 +pip==24.0 +check-manifest==0.49 diff --git a/tests/test_netbox_healthcheck_plugin.py b/tests/test_netbox_healthcheck_plugin.py index 8cfc3f6..ae60cf5 100644 --- a/tests/test_netbox_healthcheck_plugin.py +++ b/tests/test_netbox_healthcheck_plugin.py @@ -3,4 +3,3 @@ """Tests for `netbox_healthcheck_plugin` package.""" from netbox_healthcheck_plugin import netbox_healthcheck_plugin -