Skip to content

Commit

Permalink
feat(makefile, workflows): add YAML linter to workflow and Makefile (#…
Browse files Browse the repository at this point in the history
…767)

- Add `lint-yaml` target in Makefile to lint YAML files, ignoring Helm template YAML files
- Update GitHub Actions workflow to include YAML lint step

Signed-off-by: am6737 <1359816810@qq.com>
  • Loading branch information
am6737 authored Oct 14, 2024
1 parent 93569d8 commit 112dadb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,7 @@ jobs:
run: npm install -g markdownlint-cli

- name: lint markdown
run: make lint-markdown
run: make lint-markdown

- name: lint yaml
run: make lint-yaml
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,23 @@ lint-markdown:
@# ignore markdown under 'external/istio'
markdownlint '{*.md,site/**/*.md}' --disable MD012 MD013 MD029 MD033 MD034 MD036 MD041

# We don’t use if ! command -v yamllint because some environments might have a pre-installed Python version.
# Checking the specific path ensures we're using the Node.js version to avoid conflicts.
.PHONY: lint-yaml
lint-yaml:
YAML_LINT="$$(npm config get prefix)/bin/yamllint"; \
if ! test -x "$${YAML_LINT}"; then \
npm install -g yaml-lint; \
fi; \
"$${YAML_LINT}" "**/*.(yaml|yml)" --ignore="manifests/charts/*/templates/**/*.(yaml|yml)" --ignore="manifests/charts/*/files/**/*.(yaml|yml)"

.PHONY: lint-remain
lint-remain:
grep '>>>>>>' $(shell git ls-files .) | grep -v 'Makefile:' && exit 1 || true
cd tools && go run cmd/linter/main.go

.PHONY: lint
lint: lint-go lint-proto lint-license lint-spell lint-editorconfig lint-cjk lint-remain lint-markdown
lint: lint-go lint-proto lint-license lint-spell lint-editorconfig lint-cjk lint-remain lint-markdown lint-yaml

.PHONY: fmt
fmt: fmt-go fmt-proto fix-spell fix-cjk
Expand Down

0 comments on commit 112dadb

Please sign in to comment.