Skip to content

Commit

Permalink
modernize (#174)
Browse files Browse the repository at this point in the history
* drop py3.7, lock

* update dev tools, format

* rename to codeql

* install extras in container
  • Loading branch information
grizz authored Aug 29, 2023
1 parent 7f45755 commit be5975a
Show file tree
Hide file tree
Showing 17 changed files with 837 additions and 910 deletions.
File renamed without changes.
22 changes: 5 additions & 17 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,24 @@ jobs:
linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install requirements
run: sudo apt-get install rrdtool librrd-dev
- uses: actions/checkout@v3
- name: Install virtualenv from poetry
uses: 20c/workflows/poetry@v1
# poetry run pre-commit run --all-files
- name: Run linters
run: |
poetry run isort src/
poetry run black --check src/
poetry run pre-commit run --all-files
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: python
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

poetry run pre-commit run --all-files
test:
needs: linting
strategy:
fail-fast: false
matrix:
os: [ "ubuntu-latest" ]
python-version: [ "3.7", "3.8", "3.9", "3.10" ]
python-version: [ "3.8", "3.9", "3.10", "3.11" ]
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install requirements
run: sudo apt-get install rrdtool librrd-dev fping traceroute
- name: Install virtualenv from poetry
Expand All @@ -61,6 +49,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: run tests against tester
run: ./Ctl/ci/run.sh vaping pytest -vv tests/
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exclude: |
)$
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
rev: v4.4.0
hooks:
- id: check-toml
- id: check-yaml
Expand Down
6 changes: 4 additions & 2 deletions CHANGELOG.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
Unreleased:
added: []
added:
- py3.11 support
fixed: []
changed: []
deprecated: []
removed: []
removed:
- py3.7 support
security: []
1.5.3:
fixed:
Expand Down
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,8 @@ COPY src src
# Need to upgrade pip and wheel within Poetry for all its installs
RUN poetry run pip install --upgrade pip wheel
# poetry installs a pth for root
RUN poetry install --no-dev --no-root
RUN poetry build -f wheel
RUN pip install "$(ls dist/vaping-*.whl)[all]"
RUN pip install "$(ls dist/vaping-*.whl)[${vaping_extras}]"

# TODO testing stage in container for package deps, etc

Expand Down Expand Up @@ -94,7 +93,7 @@ RUN env
# install dev
RUN apk --update add $build_packages
RUN pip install "poetry$poetry_pin"
RUN poetry install --no-root
RUN poetry install --no-root --extras ${vaping_extras}


# execute from final image
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![PyPI](https://img.shields.io/pypi/v/vaping.svg?maxAge=60)](https://pypi.python.org/pypi/vaping)
[![PyPI](https://img.shields.io/pypi/pyversions/vaping.svg?maxAge=600)](https://pypi.python.org/pypi/vaping)
[![Tests](https://github.com/20c/vaping/workflows/tests/badge.svg)](https://github.com/20c/vaping)
[![LGTM Grade](https://img.shields.io/lgtm/grade/python/github/20c/vaping)](https://lgtm.com/projects/g/20c/vaping/alerts/)
[![CodeQL](https://github.com/20c/vaping/actions/workflows/codeql.yml/badge.svg)](https://github.com/20c/vaping/actions/workflows/codeql.yml)
[![Codecov](https://img.shields.io/codecov/c/github/20c/vaping/master.svg)](https://codecov.io/github/20c/vaping)


Expand Down
1,661 changes: 807 additions & 854 deletions poetry.lock

Large diffs are not rendered by default.

21 changes: 10 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ classifiers = [
'Intended Audience :: System Administrators',
'Intended Audience :: Telecommunications Industry',
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Topic :: Internet',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: System :: Monitoring',
Expand All @@ -30,7 +30,7 @@ vaping = "vaping.cli:cli"


[tool.poetry.dependencies]
python = "^3.7"
python = "^3.8"
pid = "^3"
pluginmgr = "^1"
python-daemon = "^2"
Expand Down Expand Up @@ -64,21 +64,20 @@ pyzmq = { version = ">=15.3.0", optional = true }

[tool.poetry.dev-dependencies]
# tests
codecov = "^2.1.10"
coverage = "^5.3"
pytest = "^6.1.2"
pytest-cov = "^2.10.1"
coverage = ">=5.3"
pytest = ">=6.1.2"
pytest-cov = ">=2.10.1"
pytest-filedata = "^0.4.0"
tox = "^3.20.1"

# linting
# bandit = "^1.6.2"
black = ">=20"
isort = "^5.7.0"
flake8 = "^3.8.4"
pre-commit = "^2.13"
pyupgrade = "^2.19.4"
mypy = "^0.812"
isort = ">=5.7.0"
flake8 = ">=3.8.4"
pre-commit = ">=2.13"
pyupgrade = ">=2.19.4"
mypy = ">=0.812"

# ctl
ctl = "^1"
Expand Down
3 changes: 0 additions & 3 deletions src/vaping/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class PluginBase(vaping.io.Thread):

@property
def groups(self):

"""
`dict` - group configurations keyed by name
"""
Expand Down Expand Up @@ -274,7 +273,6 @@ def __init__(self, config, ctx, emit=None):
async def _run(self):
self.run_level = 1
while self.run_level:

start = datetime.datetime.now()

# since the TimedProbe will sleep between cycles
Expand Down Expand Up @@ -575,7 +573,6 @@ def emit(self, message):
# handle vaping data that arrives in a list
if isinstance(message.get("data"), list):
for row in message.get("data"):

if row is None:
self.log.debug(
"Ignoring empty row from {}/{}".format(
Expand Down
1 change: 0 additions & 1 deletion src/vaping/plugins/graphite.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def create(self, filename):
return

def update(self, filename, time, value):

if value is None:
return

Expand Down
2 changes: 0 additions & 2 deletions src/vaping/plugins/logparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ def validate_interval(self, value):
return vaping.config.parse_interval(value)

def aggregate(self, messages):

"""
Takes a list of messages and aggregates them
according to aggration config
Expand Down Expand Up @@ -247,7 +246,6 @@ def aggregate(self, messages):
# while stack is bigger than the aggregation count
# pop messages off the stack and aggregate
while len(self.stack) >= self.aggregate_count:

# pop first message in stack
message = self.stack[0]
self.stack.remove(self.stack[0])
Expand Down
1 change: 0 additions & 1 deletion src/vaping/plugins/prometheus.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def emit(self, data):

self.log.debug("data: " + str(raw_data))
for host_data in raw_data:

if host_data is None:
continue

Expand Down
1 change: 0 additions & 1 deletion src/vaping/plugins/vodka.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def init(self):
self._is_started = False

def start(self):

if self._is_started:
return

Expand Down
2 changes: 0 additions & 2 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ def test_probe_plugin_name(config_dir):


def test_plugin_legacy_groups():

"""
test legacy plugin groups
TODO: remove with vaping 2.0
Expand All @@ -58,7 +57,6 @@ def test_plugin_legacy_groups():


def test_plugin_groups():

"""
test plugin groups as per #44 implementation
"""
Expand Down
1 change: 0 additions & 1 deletion tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ def test_plugin_instance():


def test_emission_queuing():

loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)

Expand Down
1 change: 0 additions & 1 deletion tests/test_vodka.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def test_init(this_dir):


def test_probe_to_graphsrv():

loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)

Expand Down
16 changes: 7 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ max-line-length = 80
max-complexity = 18
select = B,C,E,F,W,T4,B9

# ignore unused import in __init__, used to pull into namespace
per-file-ignores =
src/ctl/plugins/__init__.py:F401
src/ctl/plugins/all.py:F401
src/ctl/plugins/all.py:F403


[gh-actions]
python =
3.8: py38
3.9: py39
3.10: py310
3.11: py311

[tox]
envlist = py{37,38,39,310}
envlist = py{38,39,310,311}
isolated_build = True

[tox:.package]
Expand All @@ -38,8 +38,6 @@ commands =
pip install pip -U
poetry install -v --extras all
poetry run pytest tests/ --cov="{envsitepackagesdir}/vaping" --cov-report=xml
codecov -e TOXENV


[pytest]
norecursedirs = .Ctl .tox data gen

0 comments on commit be5975a

Please sign in to comment.