mirror of
https://github.com/saltstack/salt.git
synced 2025-04-15 17:20:19 +00:00
Use https://github.com/saltstack/invoke-pre-commit for invoke pre-commit steps
This commit is contained in:
parent
fb0a971730
commit
11c7242826
2 changed files with 29 additions and 75 deletions
|
@ -1185,6 +1185,33 @@ repos:
|
|||
# <---- Security ---------------------------------------------------------------------------------------------------
|
||||
|
||||
# ----- Pre-Commit ------------------------------------------------------------------------------------------------>
|
||||
- repo: https://github.com/saltstack/invoke-pre-commit
|
||||
rev: v1.5.0
|
||||
hooks:
|
||||
- id: invoke
|
||||
alias: check-docs
|
||||
name: Check Docs
|
||||
files: ^(salt/.*\.py|doc/ref/.*\.rst)$
|
||||
args:
|
||||
- docs.check
|
||||
additional_dependencies:
|
||||
- blessings
|
||||
- pyyaml
|
||||
|
||||
- repo: https://github.com/saltstack/invoke-pre-commit
|
||||
rev: v1.5.0
|
||||
hooks:
|
||||
- id: invoke
|
||||
alias: check-filemap
|
||||
name: Check Filename Map Change Matching
|
||||
files: ^tests/(filename_map\.yml|.*\.py)$
|
||||
pass_filenames: false
|
||||
args:
|
||||
- filemap.check
|
||||
additional_dependencies:
|
||||
- blessings
|
||||
- pyyaml
|
||||
|
||||
- repo: https://github.com/saltstack/mirrors-nox
|
||||
rev: v2020.8.22
|
||||
hooks:
|
||||
|
@ -1213,31 +1240,4 @@ repos:
|
|||
- -e
|
||||
- lint-tests-pre-commit
|
||||
- --
|
||||
|
||||
- repo: https://github.com/saltstack/mirrors-nox
|
||||
rev: v2020.8.22
|
||||
hooks:
|
||||
- id: nox
|
||||
alias: check-docs
|
||||
name: Check Docs
|
||||
files: ^(salt/.*\.py|doc/ref/.*\.rst)$
|
||||
args:
|
||||
- -e
|
||||
- invoke-pre-commit
|
||||
- --
|
||||
- docs.check
|
||||
|
||||
- repo: https://github.com/saltstack/mirrors-nox
|
||||
rev: v2020.8.22
|
||||
hooks:
|
||||
- id: nox
|
||||
alias: check-filemap
|
||||
name: Check Filename Map Change Matching
|
||||
files: ^tests/(filename_map\.yml|.*\.py)$
|
||||
pass_filenames: false
|
||||
args:
|
||||
- -e
|
||||
- invoke-pre-commit
|
||||
- --
|
||||
- filemap.check
|
||||
# <---- Pre-Commit -------------------------------------------------------------------------------------------------
|
||||
|
|
50
noxfile.py
50
noxfile.py
|
@ -1042,7 +1042,8 @@ def docs_man(session, compress, update, clean):
|
|||
os.chdir("..")
|
||||
|
||||
|
||||
def _invoke(session):
|
||||
@nox.session(name="invoke", python="3")
|
||||
def invoke(session):
|
||||
"""
|
||||
Run invoke tasks
|
||||
"""
|
||||
|
@ -1069,53 +1070,6 @@ def _invoke(session):
|
|||
session.run(*cmd)
|
||||
|
||||
|
||||
@nox.session(name="invoke", python="3")
|
||||
def invoke(session):
|
||||
"""
|
||||
Run an invoke target
|
||||
"""
|
||||
_invoke(session)
|
||||
|
||||
|
||||
@nox.session(name="invoke-pre-commit", python=False)
|
||||
def invoke_pre_commit(session):
|
||||
"""
|
||||
DO NOT CALL THIS NOX SESSION DIRECTLY
|
||||
|
||||
This session is called from a pre-commit hook
|
||||
"""
|
||||
if "VIRTUAL_ENV" not in os.environ:
|
||||
session.error(
|
||||
"This should be running from within a virtualenv and "
|
||||
"'VIRTUAL_ENV' was not found as an environment variable."
|
||||
)
|
||||
if "pre-commit" not in os.environ["VIRTUAL_ENV"]:
|
||||
session.error(
|
||||
"This should be running from within a pre-commit virtualenv and "
|
||||
"'VIRTUAL_ENV'({}) does not appear to be a pre-commit virtualenv.".format(
|
||||
os.environ["VIRTUAL_ENV"]
|
||||
)
|
||||
)
|
||||
from nox.virtualenv import VirtualEnv
|
||||
|
||||
# Let's patch nox to make it run inside the pre-commit virtualenv
|
||||
try:
|
||||
session._runner.venv = VirtualEnv( # pylint: disable=unexpected-keyword-arg
|
||||
os.environ["VIRTUAL_ENV"],
|
||||
interpreter=session._runner.func.python,
|
||||
reuse_existing=True,
|
||||
venv=True,
|
||||
)
|
||||
except TypeError:
|
||||
# This is still nox-py2
|
||||
session._runner.venv = VirtualEnv(
|
||||
os.environ["VIRTUAL_ENV"],
|
||||
interpreter=session._runner.func.python,
|
||||
reuse_existing=True,
|
||||
)
|
||||
_invoke(session)
|
||||
|
||||
|
||||
@nox.session(name="changelog", python="3")
|
||||
@nox.parametrize("draft", [False, True])
|
||||
def changelog(session, draft):
|
||||
|
|
Loading…
Add table
Reference in a new issue