Skip to content

Commit

Permalink
Move linter rule files to separate folder to see if this fixes issue
Browse files Browse the repository at this point in the history
  • Loading branch information
johannaengland committed Jul 4, 2024
1 parent 206c090 commit a0190f6
Show file tree
Hide file tree
Showing 3 changed files with 271 additions and 1 deletion.
131 changes: 131 additions & 0 deletions .github/linters/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
[build-system]
requires = ["setuptools>=61.0", "wheel", "setuptools_scm[toml]>=6.2", "libsass==0.15.1"]
build-backend = "setuptools.build_meta"

[project]
name = "nav"
description = "Network Administration Visualized - A comprehensive, free Network Management System"
authors = [{name="Sikt - Norwegian agency for shared services in education and research", email="[email protected]"}]
readme = "README.rst"
requires-python = ">=3.9"
license = {text = "GPLv3"}
keywords = ["nms", "snmp"]
classifiers = [
"Development Status :: 6 - Mature",
"Topic :: System :: Networking :: Monitoring",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
]
dynamic = ["version"]


[project.urls]
Homepage = "https://nav.uninett.no/"

[project.scripts]
alertengine = "nav.bin.alertengine:main"
autoenable = "nav.bin.autoenable:main"
collect_active_ip = "nav.bin.collect_active_ip:main"
emailreports = "nav.bin.emailreports:main"
eventengine = "nav.bin.eventengine:main"
ipdevpolld = "nav.bin.ipdevpolld:main"
logengine = "nav.bin.logengine:main"
macwatch = "nav.bin.macwatch:main"
mailin = "nav.bin.mailin:main"
maintengine = "nav.bin.maintengine:main"
nav = "nav.bin.navmain:main"
navcheckservice = "nav.bin.navcheckservice:main"
navclean = "nav.bin.navclean:main"
navdf = "nav.bin.navdf:main"
navdump = "nav.bin.navdump:main"
naventity = "nav.bin.naventity:main"
navoidverify = "nav.bin.navoidverify:main"
navpgdump = "nav.pgdump:main"
navsnmp = "nav.bin.navsnmp:main"
navstats = "nav.bin.navstats:main"
navsyncdb = "nav.pgsync:main"
navsynctypes = "nav.bin.navsynctypes:main"
navtopology = "nav.bin.navtopology:main"
navuser = "nav.bin.navuser:main"
netbiostracker = "nav.bin.netbiostracker:main"
pping = "nav.bin.pping:main"
radiusparser = "nav.bin.radiusparser:main"
servicemon = "nav.bin.servicemon:main"
smsd = "nav.bin.smsd:main"
snmptrapd = "nav.bin.snmptrapd:main"
sortedstats_cacher = "nav.bin.sortedstats_cacher:main"
start_arnold = "nav.bin.start_arnold:main"
t1000 = "nav.bin.t1000:main"
thresholdmon = "nav.bin.thresholdmon:main"

[tool.setuptools]
include-package-data = true
zip-safe = false
platforms = ["any"]

[tool.setuptools_scm]

[tool.setuptools.packages.find]
where = ["python"]


[tool.black]
skip-string-normalization=true
line-length = 88
exclude = '''
(
/(
\.eggs # exclude a few common directories in the
| \.git # root of the project
| \.hg
| \.mypy_cache
| \.nox
| \.tox
| \.venv
| _build
| build
| dist
)/
| python/nav/enterprise/ids\.py # Autogenerated list of constants
| python/nav/smidumps/.*\.py # Autogenerated MIB dumps
| python/nav/etc/geomap/config\.py # Not actually a Python file
)
'''

[tool.towncrier]
directory = "changelog.d"
filename = "CHANGELOG.md"
start_string = "<!-- towncrier release notes start -->\n"
underlines = ["", "", ""]
title_format = "## [{version}] - {project_date}"
issue_format = "[#{issue}](https://github.com/Uninett/nav/issues/{issue})"
wrap = true

[[tool.towncrier.type]]
directory = "security"
name = "Security"
showcontent = true

[[tool.towncrier.type]]
directory = "removed"
name = "Removed"
showcontent = true

[[tool.towncrier.type]]
directory = "deprecated"
name = "Deprecated"
showcontent = true

[[tool.towncrier.type]]
directory = "added"
name = "Added"
showcontent = true

[[tool.towncrier.type]]
directory = "changed"
name = "Changed"
showcontent = true

[[tool.towncrier.type]]
directory = "fixed"
name = "Fixed"
showcontent = true
140 changes: 140 additions & 0 deletions .github/linters/tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# -*- indent-tabs-mode: nil; -*-
#
# This tox configuration is mainly meant for running inside a Docker container,
# based on tests/docker/Dockerfile

# When changing the python or django version also change it in the tox example
# of the documentation in hacking.rst
[tox]
envlist =
{unit,integration,functional}-py{39,310}-django{32}
javascript
docs
skipsdist = True
basepython = python3.9

[pytest]
addopts = --failed-first
markers =
twisted: marks tests as needing twisted async to run

[gh-actions]
python =
3.9: py39
3.10: py310

[testenv]
# Baseline test environment
deps =
pip
-r tests/requirements.txt
-r requirements/base.txt
-r requirements/optional.txt
-r requirements/django{env:DJANGO_VER}.txt
-c constraints.txt

setenv =
LC_ALL=C.UTF-8
LANG=C.UTF-8
PYTHONPATH = {toxinidir}/tests
VIRTUALENV_PIP=23.1.0
BUILDDIR = {envdir}
CHROME_BIN = /usr/bin/google-chrome
DJANGO_SETTINGS_MODULE = nav.django.settings
COVERAGE_FILE = {toxinidir}/reports/coverage/.coverage
PYTHONFAULTHANDLER=1
django32: DJANGO_VER=32
django40: DJANGO_VER=40
passenv =
GITHUB_ACTIONS
GITHUB_RUN_ID
USER
PGHOST
PGPORT
PGDATABASE
PGUSER
PGPASSWORD
WORKSPACE
DISPLAY
allowlist_externals =
sh
sed
mkdir
chmod

usedevelop = true
commands_pre =
mkdir -p {toxinidir}/reports/coverage
chmod 777 {toxinidir}/reports/coverage

commands =
unit: pytest -o junit_suite_name="{envname} unit tests" --cov-config {toxinidir}/tests/.coveragerc --cov={toxinidir}/python --cov-report=xml:reports/{envname}/coverage.xml --junitxml=reports/{envname}/unit-results.xml --verbose {posargs:tests/unittests}

{integration,functional}: python setup.py build_sass

integration: python -m nav.django.manage check
{integration,functional}: nav config install {envdir}/etc
{integration,functional}: mkdir -p {envdir}/uploads
{integration,functional}: sed -i 's,^#\?UPLOAD_DIR.*.,UPLOAD_DIR={envdir}/uploads,' {envdir}/etc/nav.conf
integration: sed -i 's/^#DJANGO_DEBUG.*/DJANGO_DEBUG=True/' {envdir}/etc/nav.conf
integration: sed -i 's/^NAV_USER.*/NAV_USER={env:USER}/' {envdir}/etc/nav.conf
integration: sed -i 's,^#base.*,base=http://localhost:9000,' {envdir}/etc/graphite.conf
integration: django-admin collectstatic --noinput
integration: pytest -o junit_suite_name="{envname} integration tests" --cov-config {toxinidir}/tests/.coveragerc --cov={toxinidir}/python --cov-report=xml:reports/{envname}/coverage.xml --html reports/{envname}/integration-report.html --junitxml=reports/{envname}/integration-results.xml --verbose --showlocals {posargs:tests/integration}

functional: sed -i 's/^nav.*=.*INFO/root=DEBUG/' {envdir}/etc/logging.conf
functional: /sbin/start-stop-daemon -o --stop --quiet --pidfile /var/tmp/xvfb.pid
functional: /sbin/start-stop-daemon --start --quiet --pidfile /var/tmp/xvfb.pid --make-pidfile --background --exec /usr/bin/Xvfb -- {env:DISPLAY} -screen 0 1024x768x24 -fbdir /var/tmp -ac
functional: django-admin collectstatic --noinput
functional: pytest -o junit_suite_name="{envname} functional tests" --junitxml=reports/{envname}/functional-results.xml --verbose --driver Chrome --driver-path=/usr/local/bin/chromedriver --sensitive-url "nothing to see here" --html reports/{envname}/functional-report.html {posargs:tests/functional}
functional: /sbin/start-stop-daemon --stop --quiet --pidfile /var/tmp/xvfb.pid


[testenv:javascript]
usedevelop=True
deps = libsass==0.15.1
commands_pre =
commands =
/sbin/start-stop-daemon -o --stop --quiet --pidfile /var/tmp/xvfb.pid
/sbin/start-stop-daemon --start --quiet --pidfile /var/tmp/xvfb.pid --make-pidfile --background --exec /usr/bin/Xvfb -- {env:DISPLAY} -screen 0 1024x768x24 -fbdir /var/tmp -ac
{toxinidir}/tests/javascript-test.sh "{toxinidir}"
/sbin/start-stop-daemon --stop --quiet --pidfile /var/tmp/xvfb.pid

[testenv:pylint]
deps = pip-tools
description = PyLint run on default environment
setenv =
PYLINTHOME = {toxinidir}
LC_ALL=C.UTF-8
LANG=C.UTF-8
VIRTUALENV_PIP=23.1.0
commands_pre =
pip-compile --resolver=backtracking --output-file {envdir}/requirements.txt tests/requirements.txt requirements/base.txt requirements/django32.txt
pip-sync {envdir}/requirements.txt
commands =
{toxinidir}/tests/docker/scripts/pylint.sh python/nav --jobs=4 --rcfile=python/pylint.rc --disable=I,similarities --load-plugins pylint_django --output-format=parseable

[testenv:docs]
description = Just build the Sphinx documentation
deps =
-r doc/requirements.txt

usedevelop = true
setenv =
PYTHONPATH = {toxinidir}/python:{toxinidir}/tests
DJANGO_SETTINGS_MODULE = nav.django.settings
LC_ALL=C.UTF-8
LANG=C.UTF-8
VIRTUALENV_PIP=23.1.0
allowlist_externals = sh
commands_pre =
commands =
sphinx-build doc/ doc/_build/
sh -c "cd doc; python -c 'import conf; print(conf.version)' > {toxinidir}/reports/doc_version"

# The flake8 setup should mirror the setup in pre-commit
[flake8]
statistics = True
count = True
# Only check for critical problems that will prevent testing/running
select = E9,F63,F7,F82
1 change: 0 additions & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ jobs:
# Validate whole codebase on pushes and only changes on pull requests
VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push' }}
# Tell the linter the location of the configuration file (pyproject.toml)
LINTER_RULES_PATH: /
PYTHON_BLACK_CONFIG_FILE: pyproject.toml
PYTHON_FLAKE8_CONFIG_FILE: tox.ini
FILTER_REGEX_EXCLUDE: .*python/nav/smidumps/.*
Expand Down

0 comments on commit a0190f6

Please sign in to comment.