8000 chore: Move data to pyproject.toml by gmuloc · Pull Request #137 · aristanetworks/anta · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chore: Move data to pyproject.toml #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension 8000


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: install requirements
run: |
python setup.py install
pip install .
- name: install dev requirements
run: pip install -r requirements-dev.txt
run: pip install .[dev]
- name: validate the syntax of python scripts
run: python -m py_compile $(git ls-files '*.py')
linting:
yaml-linting:
name: Run linting for yaml files
runs-on: ubuntu-20.04
needs: [compiling]
Expand All @@ -39,7 +39,7 @@ jobs:
linting-testing:
name: Run flake8, pylint and pytest for supported Python versions
runs-on: ubuntu-20.04
needs: [linting]
needs: [yaml-linting]
strategy:
matrix:
python: ["3.8", "3.9", "3.10"]
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repos:
- id: check-merge-conflict

- repo: https://github.com/pycqa/flake8
rev: 4.0.1
rev: 6.0.0
hooks:
- id: flake8
name: Check for PEP8 error on Python files
Expand Down
66 changes: 61 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,71 @@ Please open an issue and submit a PR.

## Requirements

The file [requirements-dev.txt](requirements-dev.txt) has the requiriments.
To contribute, you can install `dev` packages with following command:

## To use yamllint
```bash
# Install anta in editable mode (optional)
pip install -e .

# Install dev packages
pip install 'anta[dev]'
```

Then, tox is configued with few environment to run CI locally:

```bash
tox list
default environments:
clean -> run the test driver with /home/tom/.pyenv/versions/3.9.9/envs/arista-anta/bin/python3.9
py38 -> run the test driver with py38
py39 -> run the test driver with py39
py310 -> run the test driver with py310
lint -> check the code style
type -> check typing
report -> run the test driver with /home/tom/.pyenv/versions/3.9.9/envs/arista-anta/bin/python3.9

additional environments:
3.8 -> run the test driver with 3.8
3.9 -> run the test driver with 3.9
3.10 -> run the test driver with 3.10
```

## Code linting

Run the command `yamllint -c .yamllint.yml .`
```bash
tox -e lint
[...]
lint: commands[0]> flake8 --max-line-length=165 --config=/dev/null anta
lint: commands[1]> flake8 --max-line-length=165 --config=/dev/null scripts
lint: commands[2]> flake8 --max-line-length=165 --config=/dev/null tests
lint: commands[3]> pylint anta

--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

lint: commands[4]> pylint scripts

## To use pylint
-------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 7.15/10, +2.85)

.pkg: _exit> python /home/tom/.pyenv/versions/3.9.9/envs/arista-anta/lib/python3.9/site-packages/pyproject_api/_backend.py True setuptools.build_meta
lint: OK (28.37=setup[7.03]+cmd[0.38,0.23,0.25,11.07,9.41] seconds)
congratulations :) (28.45 seconds)
```

Run the command `pylint $(git ls-files '-.py')`
## Code Typing

```bash
tox -e type

type: commands[0]> mypy --config-file=pyproject.toml anta
Success: no issues found in 38 source files
type: commands[1]> mypy --config-file=pyproject.toml scripts
Success: no issues found in 6 source files
.pkg: _exit> python /home/tom/.pyenv/versions/3.9.9/envs/arista-anta/lib/python3.9/site-packages/pyproject_api/_backend.py True setuptools.build_meta
type: OK (28.80=setup[24.54]+cmd[3.35,0.90] seconds)
congratulations :) (28.89 seconds)
```

## Git Pre-commit hook

Expand Down
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
include requirements.txt
include scripts/*.py
include toto
9 changes: 3 additions & 6 deletions anta/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
"""
anta init
"""
import importlib.metadata

__version__ = "0.3.0"
__author__ = "Khelil Sator"
__email__ = "ksator@arista.com"
__maintainer__ = "Khelil Sator"
__version__ = importlib.metadata.version("anta")
__credits__ = [
"Angélique Phillipps",
"Colin MacGiollaEáin",
Expand All @@ -14,10 +12,9 @@
"Onur Gashi",
"Paul Lavelle",
"Guillaume Mulocher",
"Thomas Grimonet"
"Thomas Grimonet",
]
__copyright__ = "Copyright 2022, Arista EMEA AS"
__license__ = "Apache"


# Source: https://rich.readthedocs.io/en/stable/appendix/colors.html
Expand Down
131 changes: 117 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,97 @@
# content of pyproject.toml

[build-system]
requires = ["setuptools>=64.0.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "anta"
version = "v0.4.0"
readme = "README.md"
authors = [{ name = "Khelil Sator", email = "ksator@arista.com" }]
maintainers = [
{ name = "Khelil Sator", email = "ksator@arista.com" },
{ name = "Matthieu Tâche", email = "mtache@arista.com" },
{ name = "Khelil Sator", email = "ksator@arista.com" },
{ name = "Guillaume Mulocher", email = "gmulocher@arista.com" },
]
description = "Arista Network Test Automation (ANTA) Framework"
license = { file = "LICENSE" }
dependencies = [
"aio-eapi==0.3.0",
"click==8.1.3",
"click-help-colors==0.9.1",
"cvprac>=1.2.0",
"netaddr>=0.8.0",
"paramiko",
"pydantic>=1.9.1",
"PyYAML>=6.0",
"requests",
"rich>=12.5.1",
"scp",
]
keywords = ["test", "anta", "Arista", "network", "automation", "networking", "devops", "netdevops"]
classifiers = [
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: System Administrators",
"Intended Audience :: Information Technology",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Testing",
"Topic :: System :: Networking",
]
requires-python = ">=3.8"

[project.optional-dependencies]
dev = [
"bump2version==1.0.1",
"flake8==6.0.0",
"isort==5.10.1",
"mypy==0.991",
"mypy-extensions>=0.4.3",
"pre-commit>=2.20.0",
"pylint>=2.16.1",
"pytest>=7.1.2",
"pytest-cov>=2.11.1",
"pytest-dependency",
"pytest-html>=3.1.1",
"pytest-metadata>=1.11.0",
"pylint-pydantic>=0.1.4",
"tox==4.0.11",
"types-PyYAML",
"types-paramiko",
"types-requests",
"typing-extensions",
"yamllint",
]

[project.urls]
Homepage = "https://arista-netdevops-community.github.io/network-test-automation/"
"Bug Tracker" = "https://github.com/arista-netdevops-community/network-test-automation/issues"
Contributing = "https://github.com/arista-netdevops-community/network-test-automation/blob/master/CONTRIBUTING.md"

[project.scripts]
anta = "anta.cli.cli:cli"

[tool.setuptools]
packages=[
"anta",
"anta.cli",
"anta.inventory",
"anta.reporter",
"anta.result_manager",
"anta.tests",
"scripts"
]

# mypy as per https://pydantic-docs.helpmanual.io/mypy_plugin/#enabling-the-plugin
[tool.mypy]
plugins = [
Expand Down Expand Up @@ -31,29 +123,40 @@ warn_untyped_fields = true
[tool.tox]
legacy_tox_ini = """
[tox]
envlist = clean,py{38,39,310}-{lint,type,test},report
min_version = 4.0
envlist =
clean,
py{38,39,310},
lint,
type,
report

[gh-actions]
python =
3.8: py38
3.9: py39
3.10: py310, coverage
3.10: py310, lint, type, coverage

[testenv]
deps =
test: pytest
test: pytest-cov
lint: flake8
lint: pylint>=2.16.1
lint,type: -r requirements-dev.txt
description = run the test driver with {basepython}
extras = dev
commands =
pytest {tty:--color=yes}

[testenv:lint]
description = check the code style
commands =
flake8 --max-line-length=165 --config=/dev/null anta
flake8 --max-line-length=165 --config=/dev/null scripts
flake8 --max-line-length=165 --config=/dev/null tests
pylint anta
pylint scripts

[testenv:type]
description = check typing
commands =
lint: flake8 --max-line-length=165 --config=/dev/null anta
lint: flake8 --max-line-length=165 --config=/dev/null scripts
lint: flake8 --max-line-length=165 --config=/dev/null tests
lint: pylint anta
lint: pylint scripts
type: mypy --config-file=pyproject.toml anta
type: mypy --config-file=pyproject.toml scripts
test: pytest {tty:--color=yes}

[testenv:clean]
deps = coverage[toml]
Expand Down
18 changes: 0 additions & 18 deletions requirements-dev.txt

This file was deleted.

11 changes: 0 additions & 11 deletions requirements.txt

This file was deleted.

15 changes: 11 additions & 4 deletions scripts/check-devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from anta.loader import parse_catalog
from anta.reporter import ReportTable
from anta.result_manager import ResultManager
from anta.runner import main
from anta.runner import main as runner_main

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -232,7 +232,8 @@ def cli_manager() -> argparse.Namespace:
return parser.parse_args()


if __name__ == "__main__":
def main() -> None:
"""main"""
console = Console()
cli_options = cli_manager()
setup_logging(level=cli_options.loglevel)
Expand All @@ -251,7 +252,7 @@ def cli_manager() -> argparse.Namespace:
username=cli_options.username,
password=cli_options.password,
enable_password=cli_options.enable_password,
timeout=cli_options.timeout
timeout=cli_options.timeout,
)
logger.info(f"Inventory {cli_options.inventory} loaded")

Expand All @@ -275,7 +276,9 @@ def cli_manager() -> argparse.Namespace:
)

results = ResultManager()
asyncio.run(main(results, inventory_anta, tests_catalog, tags=tags), debug=False)
asyncio.run(
runner_main(results, inventory_anta, tests_catalog, tags=tags), debug=False
)

############################################################################
# Test Reporting
Expand Down Expand Up @@ -326,3 +329,7 @@ def cli_manager() -> argparse.Namespace:
)

sys.exit(0)


if __name__ == "__main__":
main()
Loading
0