Skip to content

Commit

Permalink
Clean up of directory structure and linting of code
Browse files Browse the repository at this point in the history
  • Loading branch information
jryburn committed Feb 28, 2024
1 parent 1eda061 commit a3ea9d2
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 12 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/eda-test-template.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
on: []
name: Linters
jobs:
linters:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt-get update -y
sudo apt-get install jq libyaml-dev git build-essential findutils libsystemd-dev -y
sudo python3 -m pip install tox
sudo python3 -m pip install --upgrade --ignore-installed PyYAML
sudo python3 -m pip install --upgrade pip
sudo python3 -m pip install --upgrade virtualenv
sudo python3 -m pip install --upgrade setuptools
- name: Run tox
run: |
tox
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import asyncio
import json
import logging
# from collections.abc import Callable
from typing import Any

from aiohttp import web
Expand All @@ -35,7 +34,7 @@ def _initialize_logger_config() -> None:
# Process incoming webhook alert notifications from Kentik
@routes.post("/alert")
async def webhook(request: web.Request) -> web.Response:
"""Process incoming webhook alert notifications from Kentik
"""Process incoming webhook alert notifications from Kentik.
Parameters
----------
Expand All @@ -57,7 +56,7 @@ async def webhook(request: web.Request) -> web.Response:
payload = await request.json()
except json.JSONDecodeError as exc:
logger.warning(
"Wrong body request: failed to decode JSON payload: %s", exc
"Wrong body request: failed to decode JSON payload: %s", exc,
)
raise web.HTTPBadRequest(text="Invalid JSON payload") from None
headers = dict(request.headers)
Expand All @@ -73,7 +72,7 @@ async def webhook(request: web.Request) -> web.Response:

# Set app_attr settings in a dictionary
def set_app_attr(args: dict[str, Any]) -> dict[str, Any]:
"""Set app_attr settings in a dictionary
"""Set app_attr settings in a dictionary.
Parameters
----------
Expand All @@ -86,11 +85,6 @@ def set_app_attr(args: dict[str, Any]) -> dict[str, Any]:
Args containing the host and port
"""
# Not really used since the values are fed in from the main.
# if "host" not in args:
# host = "0.0.0.0"
# if "port" not in args:
# port = 5000
app_attrs = {}
app_attrs["host"] = args.get("host")
app_attrs["port"] = args.get("port")
Expand Down Expand Up @@ -152,7 +146,7 @@ async def put(self: "MockQueue", event: dict) -> None:
main(
MockQueue(),
{
"host": "0.0.0.0",
"host": "127.0.0.1",
"port": 5000,
},
),
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
namespace: kentik
name: ansible_eda
version: 1.0.0
version: 1.0.1
readme: README.md
authors:
- Kentik <[email protected]>
Expand Down Expand Up @@ -31,4 +31,4 @@ issues: https://github.com/kentik/ansible_eda/issues
# artifact. A pattern is matched from the relative path of the file or directory of the collection directory. This
# uses 'fnmatch' to match the files or directories. Some directories and files like 'galaxy.yml', '*.pyc', '*.retry',
# and '.git' are always filtered. Mutually exclusive with 'manifest'
build_ignore: []
build_ignore: [.github/, tox.ini]
Binary file not shown.
27 changes: 27 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[tox]
envlist = ruff, darglint, pylint
skipsdist = true
requires =
ruff
darglint
pylint

[testenv]
allowlist_externals=*
commands =
{envpython} --version

[testenv:ruff]
deps = ruff
commands =
bash -c 'ruff check --exclude .tox --select ALL --ignore INP001,FA102,UP001,UP010,I001,FA100,PLR0913,E501 -q extensions/eda/plugins'

[testenv:darglint]
deps = darglint
commands =
bash -c 'darglint -s numpy -z full extensions/eda/plugins'

[testenv:pylint]
deps = pylint
commands =
bash -c 'find ./extensions/eda/plugins -name "*.py" -print0 | xargs -0 pylint --output-format=parseable -sn --disable R0801,E0401,C0103,R0913,R0902,R0903'

0 comments on commit a3ea9d2

Please sign in to comment.