Skip to content

Commit

Permalink
Add Nox sessions for running pre-commit and checking MANIFEST.in (#…
Browse files Browse the repository at this point in the history
…2695)

* Add Nox sessions: manifest and lint

* Add config for check-manifest in pyproject.toml

* Update MANIFEST.in

* Add docstring for manifest session

* Update pre-commit command

* Update check-manifest command

* Update cffconvert command

* Update cff docstring

* Updates files/paths for check-manifest to ignore

* Edit changelog: 2695.internal.rst

* Add -> None

* Add check-manifest to CI

* Simplify check-manifest ignore list
  • Loading branch information
namurphy committed May 18, 2024
1 parent 9340245 commit a933be3
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ jobs:
python: '3.12'
nox_session: cff

- name: Check MANIFEST.in
os: ubuntu-latest
python: '3.12'
nox_session: manifest

steps:

- name: Checkout code
Expand Down
26 changes: 14 additions & 12 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
graft changelog
graft ci_requirements
graft docs
graft licenses
graft src
graft tests
graft tools
graft type_stubs

include *.ini
include *.ini *.toml *.yaml *.yml
include *.md
include *.py
include *.pyi
include *.rst
include *.txt
include *.yaml
include *.yml
include changelog/README.rst
include .editorconfig
include .git-blame-ignore-revs
include .jupyter/*.py
include binder/requirements.txt
include CITATION.cff
include noxfile.py
include pyproject.toml
include tox.ini
include CODEOWNERS

global-exclude _build build _version.py

global-exclude *.o
global-exclude *.py[cod]

prune docs/api
global-exclude _build build _authors.rst _version.py
global-exclude *.o *.py[cod]

# Only for editable installs
prune docs/api
prune src/plasmapy/_dev
2 changes: 2 additions & 0 deletions changelog/2695.internal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Added the ``lint`` and ``manifest`` sessions for |Nox| to run |pre-commit| on all files
and verify :file:`MANIFEST.in` with ``check-manifest``, respectively.
33 changes: 30 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,34 @@ def build(session: nox.Session):


@nox.session
def cff(session: nox.Session):
"""Validate CITATION.cff."""
def cff(session: nox.Session) -> None:
"""Validate CITATION.cff against the metadata standard."""
session.install("cffconvert")
session.run("cffconvert", "--validate")
session.run("cffconvert", "--validate", *session.posargs)


@nox.session
def manifest(session: nox.Session) -> None:
"""
Check contents of MANIFEST.in.
When run outside of CI, this check may report files that were
locally created but not included in version control. These false
positives can be ignored by adding file patterns and paths to
`ignore` under `[tool.check-manifest]` in `pyproject.toml`.
"""
session.install("check-manifest")
session.run("check-manifest", *session.posargs)


@nox.session
def lint(session: nox.Session) -> None:
"""Run all pre-commit hooks on all files."""
session.install("pre-commit")
session.run(
"pre-commit",
"run",
"--all-files",
"--show-diff-on-failure",
*session.posargs,
)
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,15 @@ showcontent = true
directory = "trivial"
name = "Additional Changes"
showcontent = true

[tool.check-manifest]
ignore = [
"#*",
"*#",
"*checkpoint*",
"*TEMP*",
"*~",
".mailmap",
"docs/*build/**",
"Untitled*",
]

0 comments on commit a933be3

Please sign in to comment.