Add linting actions (#2)

* add ruff linting gh action

* fix ruff linting errors

* add filtering to gh action
This commit is contained in:
Laura Batalha
2025-05-29 17:36:57 +01:00
committed by GitHub
parent 0e4f31e7dc
commit eea15e9e7f
4 changed files with 28 additions and 5 deletions

23
.github/workflows/linting.yml vendored Normal file
View File

@@ -0,0 +1,23 @@
name: Linting
on:
push:
branches:
- '*'
tags:
- "[0-9]+.[0-9]+.[0-9]+*"
pull_request:
branches:
- master
paths-ignore:
- .gitignore
- LICENSE
- '*.example'
- '**.example'
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/ruff-action@v3
with:
src: "./src"

View File

@@ -19,6 +19,8 @@ keywords = ["reticulum", "monitoring", "influx", "exporter"]
[project.scripts]
rnmon = "rnmon.rnmon:main"
[tool.ruff.lint]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

View File

@@ -1,7 +1,6 @@
import time
import requests
from random import randrange
from collections import deque
import RNS
from . import MP
@@ -29,9 +28,9 @@ class InfluxWriter:
pass
if data:
RNS.log(f"[RNMon] Pushing metrics - Count: {len(data)} Time: {int(time.time() - last_push)}s", RNS.LOG_DEBUG)
r = requests.post(self.address, headers=self.http_headers, data="\n".join(data))
requests.post(self.address, headers=self.http_headers, data="\n".join(data))
last_push = time.time()
jitter = randrange(-self.flush_jitter, self.flush_jitter+1)
time.sleep(0.2)
RNS.log(f"[RNMon] Stopped InfluxWriter", RNS.LOG_INFO)
RNS.log("[RNMon] Stopped InfluxWriter", RNS.LOG_INFO)

View File

@@ -2,7 +2,6 @@ import os
import time
import RNS
from . import MP
path_request_timeout = 30
link_est_timeout = 30
@@ -51,7 +50,7 @@ def on_link_closed(link: RNS.Link) -> None:
def ensure_path(dest_hash: bytes) -> None:
if not RNS.Transport.has_path(dest_hash):
RNS.log(f"[RNMon] No path to destination known. Requesting path and waiting for announce to arrive...")
RNS.log("[RNMon] No path to destination known. Requesting path and waiting for announce to arrive...")
RNS.Transport.request_path(dest_hash)
start = time.time()
while not RNS.Transport.has_path(dest_hash):