add noxfile to run tests and mockbuilds
This commit is contained in:
parent
145b7fc72a
commit
c3ee4d9f82
7 changed files with 132 additions and 7 deletions
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
image: fedora/rawhide
|
||||
packages:
|
||||
- pipx
|
||||
- nox
|
||||
- python3-pytest
|
||||
- python3-pyyaml
|
||||
- redhat-rpm-config
|
||||
|
|
@ -16,6 +16,6 @@ tasks:
|
|||
- pytest: |
|
||||
cd forge-srpm-macros
|
||||
pytest -vv
|
||||
- reuse: |
|
||||
- lint: |
|
||||
cd forge-srpm-macros
|
||||
pipx run reuse lint
|
||||
nox -e lint
|
||||
|
|
|
|||
5
.yamllint.yaml
Normal file
5
.yamllint.yaml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# Copyright (C) 2023 Maxwell G <maxwell@gtmx.me>
|
||||
# SPDX-License-Identifier: GPL-1.0-or-later
|
||||
line-length:
|
||||
max: 90
|
||||
level: warning
|
||||
83
noxfile.py
Normal file
83
noxfile.py
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
# Copyright (C) 2023 Maxwell G <maxwell@gtmx.me>
|
||||
# SPDX-License-Identifier: GPL-1.0-or-later
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Sequence
|
||||
from pathlib import Path
|
||||
|
||||
import nox
|
||||
|
||||
LINT_SESSIONS = ("static", "formatters", "typing")
|
||||
PY_FILES = ("tests", "noxfile.py")
|
||||
YAML_FILES = (".builds", "tests/vectors.yaml")
|
||||
|
||||
nox.options.sessions = (*LINT_SESSIONS, "test")
|
||||
|
||||
|
||||
@nox.session(venv_backend="none")
|
||||
def lint(session: nox.Session):
|
||||
"""
|
||||
Run python linters
|
||||
"""
|
||||
for notify in LINT_SESSIONS:
|
||||
session.notify(notify)
|
||||
|
||||
|
||||
@nox.session
|
||||
def static(session: nox.Session):
|
||||
session.install("ruff", "reuse", "yamllint")
|
||||
session.run("ruff", *session.posargs, *PY_FILES)
|
||||
session.run("yamllint", *YAML_FILES)
|
||||
session.run("reuse", "lint")
|
||||
|
||||
|
||||
@nox.session
|
||||
def formatters(session: nox.Session, posargs: Sequence[str] | None = None):
|
||||
if posargs is None:
|
||||
posargs = session.posargs
|
||||
session.install("black", "isort")
|
||||
session.run("black", *posargs, *PY_FILES)
|
||||
session.run("isort", *posargs, *PY_FILES)
|
||||
|
||||
|
||||
@nox.session
|
||||
def formatters_check(session: nox.Session):
|
||||
formatters(session, ["--check"])
|
||||
|
||||
|
||||
@nox.session
|
||||
def typing(session: nox.Session):
|
||||
session.install("mypy", "nox", "pytest", "pyyaml", "types-pyyaml")
|
||||
session.run("mypy", *session.posargs, *PY_FILES)
|
||||
|
||||
|
||||
@nox.session
|
||||
def test(session: nox.Session):
|
||||
session.install("pytest", "pyyaml")
|
||||
session.run("pytest", *session.posargs)
|
||||
|
||||
|
||||
@nox.session
|
||||
def srpm(session: nox.Session, posargs: Sequence[str] | None = None):
|
||||
session.install("fclogr")
|
||||
posargs = posargs or session.posargs
|
||||
session.run("fclogr", "--debug", "dev-srpm", *posargs)
|
||||
|
||||
|
||||
@nox.session
|
||||
def mockbuild(session: nox.Session):
|
||||
tmp = Path(session.create_tmp())
|
||||
srpm(session, ("-o", str(tmp), "--keep"))
|
||||
spec_path = tmp / "fedrq.spec"
|
||||
margs = [
|
||||
# fmt: off
|
||||
"mock",
|
||||
"--spec", str(spec_path),
|
||||
"--source", str(tmp),
|
||||
*session.posargs,
|
||||
# fmt: on
|
||||
]
|
||||
if not session.interactive:
|
||||
margs.append("--verbose")
|
||||
session.run(*margs, external=True)
|
||||
39
ruff.toml
Normal file
39
ruff.toml
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
# Copyright (C) 2023 Maxwell G <maxwell@gtmx.me>
|
||||
# SPDX-License-Identifier: GPL-1.0-or-later
|
||||
select = [
|
||||
# flake8-builtins
|
||||
"A",
|
||||
# flake8-bugbear
|
||||
"B",
|
||||
# pycodestyle
|
||||
"E",
|
||||
"W",
|
||||
# pyflakes
|
||||
"F",
|
||||
# unused-arguments
|
||||
"ARG",
|
||||
# flake8-simplify
|
||||
"SIM",
|
||||
# pylint
|
||||
"PL",
|
||||
]
|
||||
ignore = [
|
||||
# function-call-in-default-argument
|
||||
# There's nothing wrong with calling a function that returns an immutable
|
||||
# object
|
||||
"B008",
|
||||
# `zip()` without an explicit `strict=` parameter.
|
||||
# `zip()` only has that parameter in py310+
|
||||
"B905",
|
||||
# Allow overwriting loop variable
|
||||
"PLW2901",
|
||||
# Magic value used in comparison
|
||||
# This is a good rule, but the checker is a bit overzealous.
|
||||
"PLR2004",
|
||||
# Too many arguments to function call
|
||||
"PLR0913",
|
||||
]
|
||||
|
||||
[extend-per-file-ignores]
|
||||
"tests/*" = ["ARG"]
|
||||
|
||||
|
|
@ -2,8 +2,6 @@
|
|||
#
|
||||
# SPDX-License-Identifier: GPL-1.0-or-later
|
||||
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ SENTINEL = "*-*" * 20
|
|||
@dataclasses.dataclass()
|
||||
class _TestVector:
|
||||
# Test id
|
||||
id: str
|
||||
id: str # noqa: A003
|
||||
# Longer description
|
||||
description: str | None = None
|
||||
# Macros to %define
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
# This file contains a large set of test vectors for the forge macros.
|
||||
# Please use real projects and real versions so the resulting URLs can be
|
||||
# checked for accuracy.
|
||||
|
||||
---
|
||||
_anchors:
|
||||
zeroidx: &zeroidx
|
||||
- version
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue