diff --git a/.github/workflows/lint-policy-in-other-repos.yml b/.github/workflows/lint-policy-in-other-repos.yml index 1d659b0..3e15449 100644 --- a/.github/workflows/lint-policy-in-other-repos.yml +++ b/.github/workflows/lint-policy-in-other-repos.yml @@ -24,6 +24,11 @@ jobs: with: repository: cfengine/masterfiles path: masterfiles + - name: Checkout documentation + uses: actions/checkout@v4 + with: + repository: cfengine/documentation + path: documentation - name: Checkout modules uses: actions/checkout@v4 with: @@ -44,4 +49,7 @@ jobs: run: | uv run cfengine lint --strict no ../masterfiles uv run cfengine lint --strict no ../modules - # TODO: Add documentation and core when ready + uv run cfengine lint --strict no ../documentation + # TODO: Add core when ready + # TODO: Do all of them together, with strict, when ready; + # uv run cfengine lint ../core ../masterfiles ../documentation ../modules diff --git a/Makefile b/Makefile index 7ddc776..b015429 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,7 @@ lint: venv uv tool run flake8 src/ --ignore=E203,W503,E722,E731 --max-complexity=100 --max-line-length=160 uv tool run pyflakes src/ uv tool run pyright src/ + uv run cfengine lint --strict=no ./ install: pipx install --force --editable . diff --git a/pyproject.toml b/pyproject.toml index 519d271..b501a35 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta" [project] name = "cfengine" dynamic = ["version"] -description = "Human-oriented CLI for interacting with CFEngine tools" +description = "Human-oriented CLI for interacting with CFEngine policy language, projects, and other CFEngine tools" readme = "README.md" license = {file = "LICENSE"} requires-python = ">=3.10" diff --git a/src/cfengine_cli/lint.py b/src/cfengine_cli/lint.py index 9115773..79da7dc 100644 --- a/src/cfengine_cli/lint.py +++ b/src/cfengine_cli/lint.py @@ -39,7 +39,6 @@ from tree_sitter import Language, Node, Parser, Tree from cfbs.validate import validate_config from cfbs.cfbs_config import CFBSConfig -from cfbs.utils import find from cfengine_cli.lint_csv import check_csv_file from cfengine_cli.lint_yml import check_yml_file from cfengine_cli.utils import UserError @@ -1016,58 +1015,6 @@ def _lint(policy_file: PolicyFile, state: State, syntax_data: SyntaxData) -> int return errors -def _find_policy_files(args: Iterable[str]) -> Iterable[str]: - """Takes an iterator of paths to files / folders - - Returns an iterator of CFEngine policy file paths (strings). - """ - for arg in args: - if os.path.isdir(arg): - while arg.endswith(("/.", "/")): - arg = arg[0:-1] - for result in find(arg, extension=".cf"): - yield result - elif arg.endswith(".cf"): - yield arg - - -def _find_json_files(args: Iterable[str]) -> Iterable[str]: - """Takes an iterator of paths to files / folders - - Returns an iterator of JSON file paths (strings). - """ - for arg in args: - if os.path.isdir(arg): - for result in find(arg, extension=".json"): - yield result - elif arg.endswith(".json"): - yield arg - - -def filter_filenames(filenames: Iterable[str], args: list[str]) -> Iterable[str]: - """Filter filenames to avoid linting cfbs generated files and hidden files. - - TODO: We should better respect the user's args if they do: - cfengine lint ./out/masterfies/ - cfengine lint ./somepath/.somehidden/policy.cf - """ - - for filename in filenames: - if filename in args: - # The filename was actually one of the args, include it regardless: - yield filename - continue - # Skip cfbs generated files by default: - if "/out/" in filename or "/." in filename: - continue - if filename.startswith("out/"): - continue - # Skip - if filename.startswith(".") and not filename.startswith("./"): - continue - yield filename - - def _lint_check_args(args: list[str]): """Validate user-supplied paths exist, are file/folder, and have a supported extension.