Skip to content

Commit 4a9121f

Browse files
committed
chore: align the project with the salt-extension copier template
Generated with salt-extension-copier 0.10.0 (answers in .copier-answers.yml) so `copier update` keeps the project in step with the template. Adopted the template's pre-commit hooks (CLI example and autodoc checks, salt-rewrite, bandit, pylint via nox, actionlint), noxfile sessions, Sphinx setup (saltdomain, sitevars, linkcheck and docs coverage), coverage settings, NOTICE and the developer helpers. The extension code, tests, guides and the GitHub workflows stay project-specific. Also fixes the LICENSE copyright line, documents the utils package in the API reference, and silences unused-argument warnings in the test fakes. Signed-off-by: NodeRings <17057583+shaygun@users.noreply.github.com>
1 parent a521b6d commit 4a9121f

46 files changed

Lines changed: 2246 additions & 92 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.copier-answers.yml‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Autogenerated. Do not edit this by hand, use `copier update`.
2+
---
3+
_commit: 0.10.0
4+
_src_path: gh:salt-extensions/salt-extension-copier
5+
author: NodeRings
6+
author_email: partners@noderings.com
7+
coc_contact: partners@noderings.com
8+
copyright_begin: 2026
9+
deploy_docs: rolling
10+
docs_url: https://noderings.github.io/saltext-noderings/
11+
integration_name: NodeRings
12+
license: apache
13+
loaders:
14+
- cloud
15+
- module
16+
- state
17+
max_salt_version: '3008'
18+
no_saltext_namespace: false
19+
os_support:
20+
- Linux
21+
package_name: noderings
22+
project_name: noderings
23+
python_requires: '3.11'
24+
relax_pylint: false
25+
salt_version: '3006'
26+
source_url: https://github.com/noderings/saltext-noderings
27+
ssh_fixtures: false
28+
summary: Salt Extension for ordering servers and managing DNS, firewalls and SSH keys
29+
on the NodeRings cloud marketplace
30+
test_containers: false
31+
tracker_url: https://github.com/noderings/saltext-noderings/issues
32+
url: https://github.com/noderings/saltext-noderings

‎.coveragerc‎

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
[run]
2+
branch = True
3+
cover_pylib = False
4+
relative_files = True
5+
parallel = True
6+
concurrency = multiprocessing
7+
8+
omit =
9+
.nox/*
10+
setup.py
11+
12+
[report]
13+
# Regexes for lines to exclude from consideration
14+
exclude_also =
15+
# Don't complain about missing debug-only code:
16+
def __repr__
17+
18+
# Don't complain if tests don't hit defensive assertion code:
19+
raise AssertionError
20+
raise NotImplementedError
21+
22+
# Don't complain if non-runnable code isn't run:
23+
if 0:
24+
if False:
25+
if __name__ == .__main__.:
26+
if TYPE_CHECKING:
27+
@(abc\.)?abstractmethod
28+
29+
# Add markers which exclude statements in between.
30+
# Requires coverage>=7.6.0.
31+
no cover: start(?s:.)*?no cover: stop
32+
33+
omit =
34+
.nox/*
35+
setup.py
36+
37+
ignore_errors = True
38+
39+
[paths]
40+
source =
41+
saltext/noderings
42+
src/saltext/noderings
43+
testsuite =
44+
tests/

‎.github/ISSUE_TEMPLATE/docs.md‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: Docs
3+
about: Issue related to Salt Documentation
4+
title: "[DOCS]"
5+
labels: documentation, needs-triage
6+
assignees: ''
7+
8+
---
9+
10+
**Description**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Suggested Fix**
14+
What did you expect to see in the documentation that is missing or needs updating?
15+
16+
**Type of documentation**
17+
This could be module documentation or a guide.
18+
19+
**Location or format of documentation**
20+
Insert page URL if applicable.
21+
22+
**Additional context**
23+
Add any other context or screenshots here.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
name: Tech Debt
3+
about: Issue is related to tech debt. This includes compatibility changes for newer versions of software and OSes that salt interacts with.
4+
title: "[TECH DEBT]"
5+
labels: tech-debt
6+
assignees: ''
7+
8+
---
9+
10+
### Description of the tech debt to be addressed, include links and screenshots
11+
12+
### Versions Report
13+
(Provided by running `salt --versions-report`. Please also mention any differences in master/minion versions.)

‎.gitignore‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ dmypy.json
130130
.pyre/
131131

132132
# Ignore the setuptools_scm auto-generated version module
133+
src/saltext/noderings/version.py
133134

134135
# Ignore CI generated artifacts
135136
artifacts/
136137

137138
# local test runs
138139
.salt-cloud-test/
139-
src/saltext/noderings/version.py

‎.pre-commit-config.yaml‎

100644100755
Lines changed: 122 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,146 @@
1-
# Formatting and checks, as in the salt-extension copier template.
2-
# Install with: pre-commit install
1+
---
2+
minimum_pre_commit_version: 2.4.0
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v5.0.0
5+
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # v6.0.0
66
hooks:
7-
- id: check-merge-conflict
8-
- id: trailing-whitespace
7+
- id: check-merge-conflict # Check for files that contain merge conflict strings.
8+
args: [--assume-in-merge]
9+
- id: trailing-whitespace # Trim trailing whitespace.
910
args: [--markdown-linebreak-ext=md]
10-
- id: end-of-file-fixer
11-
- id: check-yaml
12-
- id: check-toml
13-
- id: debug-statements
11+
- id: mixed-line-ending # Ensure files use UNIX-style newlines only.
12+
args: [--fix=lf]
13+
- id: end-of-file-fixer # Ensure files end with a newline.
14+
- id: check-ast # Check whether files parse as valid Python.
15+
16+
# ----- Formatting ---------------------------------------------------------------------------->
17+
- repo: https://github.com/saltstack/pre-commit-remove-import-headers
18+
rev: e79f595c0df31b8cb152c53993ce7c3c64f07cd4 # 1.1.0
19+
hooks:
20+
- id: remove-import-headers
21+
22+
- repo: local
23+
hooks:
24+
- id: check-cli-examples
25+
name: Check CLI examples on execution modules
26+
entry: python .pre-commit-hooks/check-cli-examples.py
27+
language: python
28+
files: ^src/saltext/noderings/modules/.*\.py$
29+
30+
- repo: local
31+
hooks:
32+
- id: check-docs
33+
name: Check rST doc files exist for modules/states
34+
entry: python .pre-commit-hooks/make-autodocs.py
35+
language: python
36+
pass_filenames: false
37+
38+
- repo: https://github.com/saltstack/salt-rewrite
39+
# Automatically rewrite code with known rules
40+
rev: 2401c0faef69b6b846c719d611bcfe358234d5d1 # 2.5.2
41+
hooks:
42+
- id: salt-rewrite
43+
alias: rewrite-docstrings
44+
name: Salt extensions docstrings auto-fixes
45+
files: ^src/saltext/noderings/.*\.py$
46+
args: [--silent]
47+
48+
- repo: https://github.com/saltstack/salt-rewrite
49+
# Automatically rewrite code with known rules
50+
rev: 2401c0faef69b6b846c719d611bcfe358234d5d1 # 2.5.2
51+
hooks:
52+
- id: salt-rewrite
53+
alias: rewrite-tests
54+
name: Rewrite the test suite
55+
files: ^tests/.*\.py$
56+
args: [--silent, -E, fix_docstrings]
1457

1558
- repo: https://github.com/asottile/pyupgrade
16-
rev: v3.20.0
59+
rev: 75992aaa40730136014f34227e0135f63fc951b4 # v3.21.2
1760
hooks:
1861
- id: pyupgrade
19-
args: [--py311-plus]
62+
name: Rewrite Code to be Py3.11+
63+
args: [
64+
--py311-plus,
65+
]
2066
exclude: src/saltext/noderings/version.py
2167

2268
- repo: https://github.com/PyCQA/isort
23-
rev: 8.0.1
69+
rev: a333737ed43df02b18e6c95477ea1b285b3de15a # 8.0.1
2470
hooks:
2571
- id: isort
26-
args: [--py, "311"]
72+
args: [
73+
--py 311,
74+
]
2775
exclude: src/saltext/noderings/(__init__|version).py
2876

2977
- repo: https://github.com/psf/black
30-
rev: 26.5.1
78+
rev: 87928e6d6761a4a6d22250e1fee5601b3998086e # 26.5.1
3179
hooks:
3280
- id: black
33-
args: [-l, "100"]
81+
args: [-l 100]
82+
exclude: src/saltext/noderings/version.py
83+
84+
- repo: https://github.com/adamchainz/blacken-docs
85+
rev: fda77690955e9b63c6687d8806bafd56a526e45f # 1.20.0
86+
hooks:
87+
- id: blacken-docs
88+
args: [--skip-errors]
89+
files: ^(docs/.*\.rst|src/saltext/noderings/.*\.py)$
90+
additional_dependencies:
91+
- black==26.5.1
92+
# <---- Formatting -----------------------------------------------------------------------------
93+
94+
# ----- Security ------------------------------------------------------------------------------>
95+
- repo: https://github.com/PyCQA/bandit
96+
rev: 92ae8b82fb422a639f0ed8d99e96cea769594e08 # 1.9.4
97+
hooks:
98+
- id: bandit
99+
alias: bandit-salt
100+
name: Run bandit against the code base
101+
args: [--silent, -lll, --skip, B701]
34102
exclude: src/saltext/noderings/version.py
35103

36104
- repo: https://github.com/PyCQA/bandit
37-
rev: 1.8.3
105+
rev: 92ae8b82fb422a639f0ed8d99e96cea769594e08 # 1.9.4
38106
hooks:
39107
- id: bandit
108+
alias: bandit-tests
109+
name: Run bandit against the test suite
40110
args: [--silent, -lll, --skip, B701]
41-
exclude: ^tests/
111+
files: ^tests/.*
112+
# <---- Security -------------------------------------------------------------------------------
113+
114+
# ----- Code Analysis ------------------------------------------------------------------------->
115+
116+
- repo: local
117+
hooks:
118+
- id: nox
119+
alias: lint-src
120+
name: Lint Source Code
121+
language: python
122+
entry: nox -e lint-code-pre-commit --
123+
files: ^((setup|noxfile)|src/.*)\.py$
124+
require_serial: true
125+
additional_dependencies:
126+
- nox==2026.4.10
127+
- uv==0.11.26 # Makes this hook much faster
128+
129+
- id: nox
130+
alias: lint-tests
131+
name: Lint Tests
132+
language: python
133+
entry: nox -e lint-tests-pre-commit --
134+
files: ^tests/.*\.py$
135+
require_serial: true
136+
additional_dependencies:
137+
- nox==2026.4.10
138+
- uv==0.11.26 # Makes this hook much faster
139+
140+
- repo: https://github.com/Mateusz-Grzelinski/actionlint-py
141+
rev: 694e2c0dfb4253d51f3c6c54b8f9fec0a16764dc # v1.7.11.24
142+
hooks:
143+
- id: actionlint
144+
additional_dependencies:
145+
- shellcheck-py==0.11.0.1
146+
# <---- Code Analysis --------------------------------------------------------------------------
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import ast
2+
import pathlib
3+
import re
4+
import sys
5+
6+
CODE_ROOT = pathlib.Path(__file__).resolve().parent.parent
7+
EXECUTION_MODULES_PATH = CODE_ROOT / "src" / "saltext" / "noderings" / "modules"
8+
9+
10+
def check_cli_examples(files):
11+
"""
12+
Check that every function on every execution module provides a CLI example
13+
"""
14+
errors = 0
15+
for file in files:
16+
path = pathlib.Path(file).resolve()
17+
try:
18+
relpath = path.relative_to(EXECUTION_MODULES_PATH)
19+
if str(relpath.parent) != ".":
20+
# We don't want to check nested packages
21+
continue
22+
except ValueError:
23+
# We're only interested in execution modules
24+
continue
25+
module = ast.parse(path.read_text(), filename=str(path))
26+
for funcdef in [node for node in module.body if isinstance(node, ast.FunctionDef)]:
27+
if funcdef.name.startswith("_"):
28+
# We're not interested in internal functions
29+
continue
30+
31+
docstring = ast.get_docstring(funcdef, clean=False)
32+
if not docstring:
33+
errors += 1
34+
print(
35+
"The function {!r} on '{}' does not have a docstring".format(
36+
funcdef.name,
37+
path.relative_to(CODE_ROOT),
38+
),
39+
file=sys.stderr,
40+
)
41+
continue
42+
43+
if _check_cli_example_present(docstring) is False:
44+
errors += 1
45+
print(
46+
"The function {!r} on '{}' does not have a 'CLI Example:' in it's docstring".format(
47+
funcdef.name,
48+
path.relative_to(CODE_ROOT),
49+
),
50+
file=sys.stderr,
51+
)
52+
continue
53+
sys.exit(errors)
54+
55+
56+
CLI_EXAMPLE_PRESENT_RE = re.compile(r"CLI Example(?:s)?:")
57+
58+
59+
def _check_cli_example_present(docstring):
60+
return CLI_EXAMPLE_PRESENT_RE.search(docstring) is not None
61+
62+
63+
if __name__ == "__main__":
64+
check_cli_examples(sys.argv[1:])

0 commit comments

Comments
 (0)