Skip to content

Commit 7904e13

Browse files
committed
tools: do not hardcode yamllint path
Allows user to get `yamlllint` from other source than Pip (e.g. Nix). Signed-off-by: Antoine du Hamel <duhamelantoine1995@gmail.com> PR-URL: #65747 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent 2c30916 commit 7904e13

3 files changed

Lines changed: 18 additions & 7 deletions

File tree

Makefile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
BUILDTYPE ?= Release
44
PYTHON ?= python3
55
RUFF ?= tools/pip/site-packages/bin/ruff
6+
YAMLLINT ?= tools/pip/site-packages/bin/yamllint
67
DESTDIR ?=
78
SIGN ?=
89
PREFIX ?= /usr/local
@@ -1726,14 +1727,15 @@ lint-yaml-build: ## Build resources needed to lint YAML files.
17261727
$(PYTHON) -m pip install --upgrade --system -t tools/pip/site-packages yamllint
17271728

17281729
.PHONY: lint-yaml
1730+
ifneq ("","$(wildcard $(YAMLLINT))")
17291731
lint-yaml: ## Lint the YAML files with yamllint.
1730-
@if [ -d "tools/pip/site-packages/yamllint" ]; then \
1731-
$(info Running YAML linter...) \
1732-
PYTHONPATH=tools/pip $(PYTHON) -m yamllint .; \
1733-
else \
1734-
echo 'YAML linting with yamllint is not available'; \
1735-
echo "Run 'make lint-yaml-build'"; \
1736-
fi
1732+
$(info Running YAML linter...)
1733+
PYTHONPATH=tools/pip $(YAMLLINT) .
1734+
else
1735+
lint-yaml:
1736+
$(warning YAML linting with yamllint is not available)
1737+
$(warning Run 'make lint-yaml-build')
1738+
endif
17371739

17381740
.PHONY: lint
17391741
.PHONY: lint-ci

shell.nix

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ pkgs.mkShell {
155155
RUFF = pkgs.lib.getExe ruff;
156156
}
157157
)
158+
// (
159+
let
160+
yamllint = pkgs.lib.lists.findFirst (p: p.meta.mainProgram == "yamllint") null devTools;
161+
in
162+
pkgs.lib.optionalAttrs (yamllint != null) {
163+
YAMLLINT = pkgs.lib.getExe yamllint;
164+
}
165+
)
158166
// pkgs.lib.optionalAttrs (!withSQLite) {
159167
NOSQLITE = "1";
160168
}

tools/nix/devTools.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
pkgs.jq
1010
pkgs.ruff
1111
pkgs.shellcheck
12+
pkgs.yamllint
1213
]
1314
++ (
1415
if (ncu-path == null) then

0 commit comments

Comments
 (0)