From ce835941e67f441164edf0e1a944f9096f279381 Mon Sep 17 00:00:00 2001 From: Jorge Fandinno Date: Wed, 11 Dec 2024 13:54:21 -0600 Subject: [PATCH] fix nox to work with github actions --- noxfile.py | 203 ++++++++++++++++++++++++++--------------------------- 1 file changed, 100 insertions(+), 103 deletions(-) diff --git a/noxfile.py b/noxfile.py index d43b23e..3c54971 100644 --- a/noxfile.py +++ b/noxfile.py @@ -12,8 +12,6 @@ IS_GITHUB = "GITHUB_ACTIONS" in os.environ -# print(f"True: {True}") - @nox.session def format(session: nox.Session): session.install("black", "isort", external=IS_GITHUB) @@ -22,105 +20,104 @@ def format(session: nox.Session): session.run("black", *args, external=IS_GITHUB) +@nox.session(python=None) +def typecheck(session: nox.Session): + session.install("mypy", external=IS_GITHUB) + session.install("-e", ".", external=IS_GITHUB) + session.run("mypy", "--implicit-optional", "src/eclingo", external=IS_GITHUB) + + +@nox.session(python=None) +def all_tests(session: nox.Session): + session.notify("tests") + session.notify("slow_tests") + session.notify("coverage") + + +@nox.session(python=None) +def tests(session: nox.Session): + session.install("coverage", external=IS_GITHUB) + session.install("-e", ".", external=IS_GITHUB) + session.run( + "coverage", + "run", + "--data-file", + ".coverage_fast", + "-m", + "unittest", + "tests/test_reification.py", + "tests/test_reification2.py", + "tests/test_reification3.py", + "tests/test_reification4.py", + "tests/test_reification5.py", + "tests/test_eclingo.py", + # "tests/test_grounder.py", + "tests/test_generator_reification.py", + "tests/test_literals.py", + "tests/test_parsing.py", + "tests/test_solver_reification.py", + "tests/test_worldview_builder_reification.py", + "tests/test_tester_reification.py", + "tests/test_theory_atom_parser.py", + "tests/test_transformers.py", + "tests/test_util.py", + "tests/test_preprocessor.py", + "tests/test_propagator.py", + "-v", + external=IS_GITHUB, + ) + + +@nox.session(python=None) +def slow_tests(session: nox.Session): + session.install("coverage", external=IS_GITHUB) + # session.install("-r", "requirements.txt", external=IS_GITHUB) + session.install("-e", ".", external=IS_GITHUB) + session.run( + "coverage", + "run", + "--data-file", + ".coverage_slow", + "-m", + "unittest", + "tests/test_app.py", + "tests/test_eclingo_examples.py", + "-v", + external=IS_GITHUB, + ) + + +@nox.session(python=None) +def coverage(session: nox.Session): + session.install("coverage", external=IS_GITHUB) + omit = ["src/eclingo/__main__.py", "tests/*", "helper_test/*"] + session.run( + "coverage", + "combine", + ".coverage_fast", + ".coverage_slow", + external=IS_GITHUB, + ) + session.run( + "coverage", + "report", + "--sort=cover", + "--fail-under=99", + "--omit", + ",".join(omit), + external=IS_GITHUB, + ) + + +@nox.session +def pylint(session: nox.Session): + session.install("-e", ".", external=IS_GITHUB) + session.install("pylint", external=IS_GITHUB) + # session.install("-r", "requirements.txt", "pylint", external=IS_GITHUB) + session.run("pylint", "src/eclingo", external=IS_GITHUB) + -# @nox.session(python=None) -# def typecheck(session: nox.Session): -# session.install("mypy", external=IS_GITHUB) -# session.install("-e", ".", external=IS_GITHUB) -# session.run("mypy", "--implicit-optional", "src/eclingo", external=IS_GITHUB) - - -# @nox.session(python=None) -# def all_tests(session: nox.Session): -# session.notify("tests") -# session.notify("slow_tests") -# session.notify("coverage") - - -# @nox.session(python=None) -# def tests(session: nox.Session): -# session.install("coverage", external=IS_GITHUB) -# session.install("-e", ".", external=IS_GITHUB) -# session.run( -# "coverage", -# "run", -# "--data-file", -# ".coverage_fast", -# "-m", -# "unittest", -# "tests/test_reification.py", -# "tests/test_reification2.py", -# "tests/test_reification3.py", -# "tests/test_reification4.py", -# "tests/test_reification5.py", -# "tests/test_eclingo.py", -# # "tests/test_grounder.py", -# "tests/test_generator_reification.py", -# "tests/test_literals.py", -# "tests/test_parsing.py", -# "tests/test_solver_reification.py", -# "tests/test_worldview_builder_reification.py", -# "tests/test_tester_reification.py", -# "tests/test_theory_atom_parser.py", -# "tests/test_transformers.py", -# "tests/test_util.py", -# "tests/test_preprocessor.py", -# "tests/test_propagator.py", -# "-v", -# external=IS_GITHUB, -# ) - - -# @nox.session(python=None) -# def slow_tests(session: nox.Session): -# session.install("coverage", external=IS_GITHUB) -# # session.install("-r", "requirements.txt", external=IS_GITHUB) -# session.install("-e", ".", external=IS_GITHUB) -# session.run( -# "coverage", -# "run", -# "--data-file", -# ".coverage_slow", -# "-m", -# "unittest", -# "tests/test_app.py", -# "tests/test_eclingo_examples.py", -# "-v", -# external=IS_GITHUB, -# ) - - -# @nox.session(python=None) -# def coverage(session: nox.Session): -# session.install("coverage", external=IS_GITHUB) -# omit = ["src/eclingo/__main__.py", "tests/*", "helper_test/*"] -# session.run( -# "coverage", -# "combine", -# ".coverage_fast", -# ".coverage_slow", -# external=IS_GITHUB, -# ) -# session.run( -# "coverage", -# "report", -# "--sort=cover", -# "--fail-under=99", -# "--omit", -# ",".join(omit), -# external=IS_GITHUB, -# ) - - -# @nox.session -# def pylint(session: nox.Session): -# session.install("-e", ".", external=IS_GITHUB) -# session.install("pylint", external=IS_GITHUB) -# # session.install("-r", "requirements.txt", "pylint", external=IS_GITHUB) -# session.run("pylint", "src/eclingo", external=IS_GITHUB) - - -# @nox.session -# def lint_flake8(session: nox.Session): -# session.install("flake8", "flake8-black", "flake8-isort", external=IS_GITHUB) -# session.run("flake8", "src/eclingo", external=IS_GITHUB) +@nox.session +def lint_flake8(session: nox.Session): + session.install("flake8", "flake8-black", "flake8-isort", external=IS_GITHUB) + session.run("flake8", "src/eclingo", external=IS_GITHUB)