Skip to content

Commit 232b15c

Browse files
authored
Merge pull request #113 from olehermanse/next
Miscellaneous improvements
2 parents b04e091 + f2cdafb commit 232b15c

4 files changed

Lines changed: 11 additions & 55 deletions

File tree

.github/workflows/lint-policy-in-other-repos.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ jobs:
2424
with:
2525
repository: cfengine/masterfiles
2626
path: masterfiles
27+
- name: Checkout documentation
28+
uses: actions/checkout@v4
29+
with:
30+
repository: cfengine/documentation
31+
path: documentation
2732
- name: Checkout modules
2833
uses: actions/checkout@v4
2934
with:
@@ -44,4 +49,7 @@ jobs:
4449
run: |
4550
uv run cfengine lint --strict no ../masterfiles
4651
uv run cfengine lint --strict no ../modules
47-
# TODO: Add documentation and core when ready
52+
uv run cfengine lint --strict no ../documentation
53+
# TODO: Add core when ready
54+
# TODO: Do all of them together, with strict, when ready;
55+
# uv run cfengine lint ../core ../masterfiles ../documentation ../modules

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ lint: venv
1515
uv tool run flake8 src/ --ignore=E203,W503,E722,E731 --max-complexity=100 --max-line-length=160
1616
uv tool run pyflakes src/
1717
uv tool run pyright src/
18+
uv run cfengine lint --strict=no ./
1819

1920
install:
2021
pipx install --force --editable .

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
55
[project]
66
name = "cfengine"
77
dynamic = ["version"]
8-
description = "Human-oriented CLI for interacting with CFEngine tools"
8+
description = "Human-oriented CLI for interacting with CFEngine policy language, projects, and other CFEngine tools"
99
readme = "README.md"
1010
license = {file = "LICENSE"}
1111
requires-python = ">=3.10"

src/cfengine_cli/lint.py

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
from tree_sitter import Language, Node, Parser, Tree
4040
from cfbs.validate import validate_config
4141
from cfbs.cfbs_config import CFBSConfig
42-
from cfbs.utils import find
4342
from cfengine_cli.lint_csv import check_csv_file
4443
from cfengine_cli.lint_yml import check_yml_file
4544
from cfengine_cli.utils import UserError
@@ -1016,58 +1015,6 @@ def _lint(policy_file: PolicyFile, state: State, syntax_data: SyntaxData) -> int
10161015
return errors
10171016

10181017

1019-
def _find_policy_files(args: Iterable[str]) -> Iterable[str]:
1020-
"""Takes an iterator of paths to files / folders
1021-
1022-
Returns an iterator of CFEngine policy file paths (strings).
1023-
"""
1024-
for arg in args:
1025-
if os.path.isdir(arg):
1026-
while arg.endswith(("/.", "/")):
1027-
arg = arg[0:-1]
1028-
for result in find(arg, extension=".cf"):
1029-
yield result
1030-
elif arg.endswith(".cf"):
1031-
yield arg
1032-
1033-
1034-
def _find_json_files(args: Iterable[str]) -> Iterable[str]:
1035-
"""Takes an iterator of paths to files / folders
1036-
1037-
Returns an iterator of JSON file paths (strings).
1038-
"""
1039-
for arg in args:
1040-
if os.path.isdir(arg):
1041-
for result in find(arg, extension=".json"):
1042-
yield result
1043-
elif arg.endswith(".json"):
1044-
yield arg
1045-
1046-
1047-
def filter_filenames(filenames: Iterable[str], args: list[str]) -> Iterable[str]:
1048-
"""Filter filenames to avoid linting cfbs generated files and hidden files.
1049-
1050-
TODO: We should better respect the user's args if they do:
1051-
cfengine lint ./out/masterfies/
1052-
cfengine lint ./somepath/.somehidden/policy.cf
1053-
"""
1054-
1055-
for filename in filenames:
1056-
if filename in args:
1057-
# The filename was actually one of the args, include it regardless:
1058-
yield filename
1059-
continue
1060-
# Skip cfbs generated files by default:
1061-
if "/out/" in filename or "/." in filename:
1062-
continue
1063-
if filename.startswith("out/"):
1064-
continue
1065-
# Skip
1066-
if filename.startswith(".") and not filename.startswith("./"):
1067-
continue
1068-
yield filename
1069-
1070-
10711018
def _lint_check_args(args: list[str]):
10721019
"""Validate user-supplied paths exist, are file/folder, and have a supported extension.
10731020

0 commit comments

Comments
 (0)