-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge CI workflow improvements into dev
With these changes, - the CI badge is now a link to the GitHub workflow details, - the CI badge's alt text is no longer specific to GitHub, - the list of `cleaned` files is now a module global variable in "noxfile.py", - the CI checks are done in multiple small steps instead of one monolithic one, - packaging is checked on multiple Python versions, - package installation is now checked, too, and on multiple versions, - the workflow job names are shorter, - the workflow jobs are ordered alphabetically in GitHub's UI (this means Linux comes first, yay ;) ), but most importantly - the CI checks pass again, because the `cleaned` files have been reformatted with the most recent version of `black`.
- Loading branch information
Showing
5 changed files
with
79 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,69 @@ | ||
from pathlib import Path | ||
from pprint import pformat | ||
|
||
import nox | ||
|
||
cleaned = [ | ||
"etrago/cluster/disaggregation.py", | ||
"etrago/tools/network.py", | ||
"etrago/tools/utilities.py", | ||
"noxfile.py", | ||
"setup.py", | ||
] | ||
|
||
|
||
def setdefaults(session): | ||
session.env["PYTHONUNBUFFERED"] = "yes" | ||
|
||
|
||
@nox.session(python="3") | ||
def check(session): | ||
"""Run custom checks.""" | ||
setdefaults(session) | ||
packages = ["Flake8-pyproject"] | ||
packages.extend(["black", "flake8", "isort >= 5", "twine"]) | ||
session.install(*packages) | ||
cleaned = [ | ||
"etrago/cluster/disaggregation.py", | ||
"etrago/tools/network.py", | ||
"etrago/tools/utilities.py", | ||
"noxfile.py", | ||
"setup.py", | ||
] | ||
assert cleaned == sorted(set(cleaned)), ( | ||
"The list of cleaned files contains duplicates and/or isn't sorted" | ||
" alphabetically." | ||
f"\nExpected:\n{pformat(sorted(set(cleaned)))}" | ||
f"\nGot:\n{pformat(cleaned)}" | ||
) | ||
|
||
|
||
@nox.session(python="3") | ||
def black(session): | ||
"""Check for happy little style accidents with `black`.""" | ||
setdefaults(session) | ||
session.install("black") | ||
session.run("black", "--check", "--diff", *cleaned) | ||
|
||
|
||
@nox.session(python="3") | ||
def isort(session): | ||
"""Check import ordering with `isort`.""" | ||
setdefaults(session) | ||
session.install("isort >= 5") | ||
session.run("isort", "--check-only", "--diff", *cleaned) | ||
|
||
|
||
@nox.session(python="3") | ||
def flake8(session): | ||
"""Check for happy little style accidents with `flake8`.""" | ||
setdefaults(session) | ||
session.install("Flake8-pyproject", "flake8") | ||
session.run("flake8", *cleaned) | ||
|
||
|
||
@nox.session(python=["3", "3.8", "3.9", "3.10", "3.11"]) | ||
def build(session): | ||
"""Build the package and check for packaging errors.""" | ||
setdefaults(session) | ||
session.install("twine") | ||
session.run("python", "setup.py", "bdist", "bdist_wheel") | ||
session.run("twine", "check", "dist/eTraGo*") | ||
|
||
|
||
@nox.session(python=["3", "3.8", "3.9", "3.10", "3.11"]) | ||
def install(session): | ||
"""Install the package.""" | ||
setdefaults(session) | ||
session.run("python", "-mpip", "install", "--upgrade", "pip") | ||
session.run("python", "-mpip", "install", *Path("dist").glob("*.whl")) |