noxfile.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # noxfile.py/Open GoPro, Version 2.0 (C) Copyright 2021 GoPro, Inc. (http://gopro.com/OpenGoPro).
  2. # This copyright was auto-generated on Fri Feb 4 21:36:17 UTC 2022
  3. """Nox sessions."""
  4. import nox
  5. from nox_poetry import session
  6. # Don't run docs by default since it needs graphviz.
  7. nox.options.sessions = "format", "lint", "tests", "docstrings", "docs"
  8. SUPPORTED_VERSIONS = [
  9. "3.11",
  10. "3.12",
  11. "3.13",
  12. ]
  13. @session(python=SUPPORTED_VERSIONS[-1])
  14. def format(session) -> None:
  15. """Run black code formatter."""
  16. session.install("black")
  17. session.run("black", "--check", "open_gopro", "tests", "noxfile.py", "docs/conf.py")
  18. # Mypy is changing too much between versions. Let's only lint on the latest version
  19. @session(python=SUPPORTED_VERSIONS[-1])
  20. def lint(session) -> None:
  21. """Lint using pylint and check types with mypy."""
  22. session.install(".[gui]")
  23. session.install(
  24. "pylint",
  25. "mypy",
  26. "construct-typing",
  27. "mypy-protobuf",
  28. "types-requests",
  29. "types-attrs",
  30. "types-pytz",
  31. "types-tzlocal",
  32. )
  33. session.run("mypy", "open_gopro")
  34. session.run("pylint", "--no-docstring-rgx=__|main|parse_arguments|entrypoint", "open_gopro")
  35. @session(python=SUPPORTED_VERSIONS)
  36. def tests(session) -> None:
  37. """Run the test suite."""
  38. session.install(".")
  39. session.install(
  40. "pytest",
  41. "pytest-cov",
  42. "pytest-asyncio",
  43. "pytest-timeout",
  44. "pytest-mock",
  45. "pytest-html",
  46. "coverage[toml]",
  47. "requests-mock",
  48. )
  49. session.run("pytest", "tests/unit", "--cov-fail-under=70")
  50. @session(python=SUPPORTED_VERSIONS[-1])
  51. def docstrings(session) -> None:
  52. """Validate docstrings."""
  53. session.install("pydoclint")
  54. session.install("pydocstyle[toml]")
  55. session.run("pydocstyle", "open_gopro")
  56. session.run("pydoclint", "open_gopro")
  57. @session(python=SUPPORTED_VERSIONS[-1])
  58. def docs(session) -> None:
  59. """Build the documentation."""
  60. session.install(".")
  61. session.install(
  62. "sphinx",
  63. "sphinx-autodoc-typehints",
  64. "sphinx-rtd-theme",
  65. "sphinxcontrib-napoleon",
  66. "autodoc-pydantic",
  67. "pydoclint",
  68. )
  69. session.run("sphinx-build", "-W", "docs", "docs/build")
  70. # Clean up for Jekyll consumption
  71. session.run("rm", "-rf", "docs/build/.doctrees", "/docs/build/_sources", "/docs/build/_static/fonts", external=True)