Skip to content

Commit

Permalink
test: GH action for linting
Browse files Browse the repository at this point in the history
Break linting out into a separate tox environment. Add a GitHub action
config to run it, to make it more obvious that it's linting that's
causing the build to fail.

Also, do a little more clean up to bump the pylint score.
  • Loading branch information
apotterri committed May 18, 2024
1 parent 2c077da commit f75e303
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 11 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build
on:
pull_request:
schedule:
- cron: "0 0 * * 0"

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
python: ["3.12"]
include:
- python: "3.12"
tox_env: "lint"
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Install tox
run: |
python -m pip install --upgrade pip setuptools
pip install tox
- name: Test
run: |
tox -e ${{ matrix.tox_env }}
1 change: 1 addition & 0 deletions _appmap/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def to_dict(self, value):


class CallEvent(Event):
# pylint: disable=method-cache-max-size-none
__slots__ = ["_fn", "_fqfn", "static", "receiver", "parameters", "labels"]

@staticmethod
Expand Down
8 changes: 4 additions & 4 deletions _appmap/test/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def test_created_if_missing_and_enabled(self, git, data_dir, monkeypatch, tmpdir
# pylint: disable=protected-access
_appmap.initialize(cwd=repo_root)

Config.current # write the file as a side-effect
Config.current # pylint: disable=pointless-statement
assert path.is_file()
with open(path, encoding="utf-8") as cfg:
actual_config = yaml.safe_load(cfg)
Expand All @@ -228,7 +228,7 @@ def test_not_created_if_missing_and_not_enabled(self, git, data_dir, monkeypatch
# pylint: disable=protected-access
_appmap.initialize(cwd=repo_root, env={"_APPMAP": "false"})

Config.current
Config.current # pylint: disable=pointless-statemen
assert not path.is_file()


Expand All @@ -241,7 +241,7 @@ def setup_config(self, data_dir, monkeypatch, tmpdir):
@contextmanager
def incomplete_config(self):
# pylint: disable=protected-access
with open("appmap-incomplete.yml", mode="w", buffering=1) as f:
with open("appmap-incomplete.yml", mode="w", buffering=1, encoding="utf-8") as f:
print("# Incomplete file", file=f)
yield f

Expand Down Expand Up @@ -319,6 +319,6 @@ def test_config_not_found_in_path_hierarchy(self, data_dir, tmpdir, monkeypatch)
cwd=wd,
env={"APPMAP_CONFIG": "notfound.yml"},
)
Config.current
Config.current # pylint: disable=pointless-statemen
# No default config since we specified APPMAP_CONFIG
assert not Env.current.enabled
2 changes: 1 addition & 1 deletion _appmap/test/test_describe_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class WithOverloadedClass:
# pylint: disable=missing-class-docstring,too-few-public-methods
@property
def __class__(self):
raise Exception("__class__ called")
raise RuntimeError("__class__ called")

describe_value(None, WithOverloadedClass())

Expand Down
4 changes: 2 additions & 2 deletions _appmap/test/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def test_disable_temporarily():
try:
with env.disabled("requests"):
assert not env.enables("requests")
raise 'hell'
except:
raise RuntimeError("hell")
except Exception:
...
assert env.enables("requests")
3 changes: 1 addition & 2 deletions _appmap/test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
Test util functionality
"""

import os
from pathlib import Path
import uuid
from pathlib import Path

from _appmap.utils import locate_file_up, scenario_filename

Expand Down
2 changes: 1 addition & 1 deletion pylintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[MAIN]
# Specify a score threshold under which the program will exit with error.
fail-under=9.85
fail-under=9.87


# Analyse import fallback blocks. This can be used to support both Python 2 and
Expand Down
7 changes: 6 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@ deps=

commands =
poetry install -v
py310-web: poetry run pylint -j 0 appmap _appmap
web: poetry run {posargs:pytest}
django3: poetry run pytest _appmap/test/test_django.py
flask2: poetry run pytest _appmap/test/test_flask.py
sqlalchemy1: poetry run pytest _appmap/test/test_sqlalchemy.py

[testenv:lint]
skip_install = True
deps = poetry
commands =
{posargs:poetry run pylint -j 0 appmap _appmap}

[testenv:vendoring]
skip_install = True
deps = vendoring
Expand Down

0 comments on commit f75e303

Please sign in to comment.