From 5defe2c6427287e15513ff668762efa2a1ba9c8c Mon Sep 17 00:00:00 2001 From: Loong Dai Date: Mon, 20 Jan 2025 15:10:19 +0800 Subject: [PATCH] chore: enable yamllint check (#136) Fix #129 --------- Signed-off-by: Loong --- .github/workflows/commit.yaml | 16 +++--- .github/workflows/docker_builds_template.yaml | 4 +- .yamllint | 53 +++++++++++++++++++ Makefile | 7 ++- Makefile.tools.mk | 3 ++ .../testdata/aigatewayroutes/basic.yaml | 8 +-- .../aigatewayroutes/no_target_refs.yaml | 8 +-- .../aigatewayroutes/non_openai_schema.yaml | 8 +-- .../aigatewayroutes/unknown_schema.yaml | 8 +-- .../aigatewayroutes/unsupported_match.yaml | 8 +-- 10 files changed, 92 insertions(+), 31 deletions(-) create mode 100644 .yamllint diff --git a/.github/workflows/commit.yaml b/.github/workflows/commit.yaml index 4a487d08..4d037cb3 100644 --- a/.github/workflows/commit.yaml +++ b/.github/workflows/commit.yaml @@ -109,10 +109,10 @@ jobs: fail-fast: false matrix: include: - - name: v1.33.0 - envoy_version: envoyproxy/envoy:v1.33.0 - - name: latest - envoy_version: envoyproxy/envoy-dev:latest + - name: v1.33.0 + envoy_version: envoyproxy/envoy:v1.33.0 + - name: latest + envoy_version: envoyproxy/envoy-dev:latest runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -156,10 +156,10 @@ jobs: fail-fast: false matrix: include: - - name: v1.2.5 - envoy_gateway_version: v1.2.5 - - name: latest - envoy_gateway_version: v0.0.0-latest + - name: v1.2.5 + envoy_gateway_version: v1.2.5 + - name: latest + envoy_gateway_version: v0.0.0-latest steps: - uses: actions/checkout@v4 if: github.event_name != 'pull_request_target' diff --git a/.github/workflows/docker_builds_template.yaml b/.github/workflows/docker_builds_template.yaml index 45cf45ec..b1f32bda 100644 --- a/.github/workflows/docker_builds_template.yaml +++ b/.github/workflows/docker_builds_template.yaml @@ -30,11 +30,11 @@ jobs: - uses: docker/setup-buildx-action@v3 - name: Set up QEMU - uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 + uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 - name: Set up Docker buildx id: buildx - uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1 + uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1 - name: Login into GitHub Container Registry uses: docker/login-action@v3 diff --git a/.yamllint b/.yamllint new file mode 100644 index 00000000..29d43e83 --- /dev/null +++ b/.yamllint @@ -0,0 +1,53 @@ +--- + +ignore: | + manifests/charts/ai-gateway-helm + +rules: + braces: + min-spaces-inside: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: -1 + max-spaces-inside-empty: -1 + brackets: + min-spaces-inside: 0 + max-spaces-inside: 1 + min-spaces-inside-empty: -1 + max-spaces-inside-empty: -1 + colons: + max-spaces-before: 0 + max-spaces-after: 1 + commas: + max-spaces-before: 1 + min-spaces-after: 1 + max-spaces-after: 1 + comments: + level: error + require-starting-space: true + min-spaces-from-content: 2 + comments-indentation: + level: warning + document-end: disable + document-start: disable + empty-lines: + max: 2 + max-start: 0 + max-end: 1 + empty-values: + forbid-in-block-mappings: false + forbid-in-flow-mappings: true + hyphens: + max-spaces-after: 1 + indentation: + spaces: 2 + indent-sequences: consistent # be consistent: don't mix indentation styles in one file. + check-multi-line-strings: false + key-duplicates: enable + key-ordering: disable + new-line-at-end-of-file: enable + new-lines: + type: unix + trailing-spaces: enable + truthy: + check-keys: false # GitHub Actions uses "on:" as a key + level: warning diff --git a/Makefile b/Makefile index 0ca91ec7..43ef37d8 100644 --- a/Makefile +++ b/Makefile @@ -54,6 +54,11 @@ codespell: $(CODESPELL) @echo "spell => ./..." @$(CODESPELL) --skip $(CODESPELL_SKIP) --ignore-words $(CODESPELL_IGNORE_WORDS) +.PHONY: yamllint +yamllint: $(YAMLLINT) + @echo "yamllint => ./..." + @$(YAMLLINT) --config-file=.yamllint $$(git ls-files :*.yml :*.yaml | xargs -L1 dirname | sort -u) + # This runs the formatter on the codebase as well as goimports via gci. .PHONY: format format: gci gofumpt @@ -79,7 +84,7 @@ apigen: controller-gen # This runs all necessary steps to prepare for a commit. .PHONY: precommit -precommit: tidy codespell apigen format lint editorconfig helm-lint +precommit: tidy codespell apigen format lint editorconfig yamllint helm-lint # This runs precommit and checks for any differences in the codebase, failing if there are any. .PHONY: check diff --git a/Makefile.tools.mk b/Makefile.tools.mk index 81337fcb..8a8d997e 100644 --- a/Makefile.tools.mk +++ b/Makefile.tools.mk @@ -10,6 +10,7 @@ GO_FUMPT = $(LOCALBIN)/gofumpt GCI = $(LOCALBIN)/gci EDITORCONFIG_CHECKER = $(LOCALBIN)/editorconfig-checker CODESPELL = $(LOCALBIN)/.venv/codespell@v2.3.0/bin/codespell +YAMLLINT = $(LOCALBIN)/.venv/yamllint@1.35.1/bin/yamllint KIND ?= $(LOCALBIN)/kind ## Tool versions. @@ -63,6 +64,8 @@ $(KIND): $(LOCALBIN) $(CODESPELL): .bin/.venv/codespell@v2.3.0 +$(YAMLLINT): .bin/.venv/yamllint@1.35.1 + # go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist # $1 - target path with name of binary # $2 - package url which can be installed diff --git a/tests/cel-validation/testdata/aigatewayroutes/basic.yaml b/tests/cel-validation/testdata/aigatewayroutes/basic.yaml index 81b5be20..459d2d01 100644 --- a/tests/cel-validation/testdata/aigatewayroutes/basic.yaml +++ b/tests/cel-validation/testdata/aigatewayroutes/basic.yaml @@ -12,10 +12,10 @@ spec: group: gateway.networking.k8s.io rules: - matches: - - headers: - - type: Exact - name: x-envoy-ai-gateway-model - value: llama3-70b + - headers: + - type: Exact + name: x-envoy-ai-gateway-model + value: llama3-70b backendRefs: - name: kserve weight: 20 diff --git a/tests/cel-validation/testdata/aigatewayroutes/no_target_refs.yaml b/tests/cel-validation/testdata/aigatewayroutes/no_target_refs.yaml index f8d60b97..61f96b75 100644 --- a/tests/cel-validation/testdata/aigatewayroutes/no_target_refs.yaml +++ b/tests/cel-validation/testdata/aigatewayroutes/no_target_refs.yaml @@ -9,10 +9,10 @@ spec: name: OpenAI rules: - matches: - - headers: - - type: Exact - name: x-envoy-ai-gateway-model - value: llama3-70b + - headers: + - type: Exact + name: x-envoy-ai-gateway-model + value: llama3-70b backendRefs: - name: kserve weight: 20 diff --git a/tests/cel-validation/testdata/aigatewayroutes/non_openai_schema.yaml b/tests/cel-validation/testdata/aigatewayroutes/non_openai_schema.yaml index 224b6a3c..9a970551 100644 --- a/tests/cel-validation/testdata/aigatewayroutes/non_openai_schema.yaml +++ b/tests/cel-validation/testdata/aigatewayroutes/non_openai_schema.yaml @@ -13,10 +13,10 @@ spec: group: gateway.networking.k8s.io rules: - matches: - - headers: - - type: Exact - name: x-envoy-ai-gateway-model - value: llama3-70b + - headers: + - type: Exact + name: x-envoy-ai-gateway-model + value: llama3-70b backendRefs: - name: kserve weight: 20 diff --git a/tests/cel-validation/testdata/aigatewayroutes/unknown_schema.yaml b/tests/cel-validation/testdata/aigatewayroutes/unknown_schema.yaml index dfb30add..7cf4f0f1 100644 --- a/tests/cel-validation/testdata/aigatewayroutes/unknown_schema.yaml +++ b/tests/cel-validation/testdata/aigatewayroutes/unknown_schema.yaml @@ -13,10 +13,10 @@ spec: group: gateway.networking.k8s.io rules: - matches: - - headers: - - type: Exact - name: x-envoy-ai-gateway-model - value: llama3-70b + - headers: + - type: Exact + name: x-envoy-ai-gateway-model + value: llama3-70b backendRefs: - name: kserve weight: 20 diff --git a/tests/cel-validation/testdata/aigatewayroutes/unsupported_match.yaml b/tests/cel-validation/testdata/aigatewayroutes/unsupported_match.yaml index bf6881e5..32a0bb84 100644 --- a/tests/cel-validation/testdata/aigatewayroutes/unsupported_match.yaml +++ b/tests/cel-validation/testdata/aigatewayroutes/unsupported_match.yaml @@ -12,10 +12,10 @@ spec: group: gateway.networking.k8s.io rules: - matches: - - headers: - - type: RegularExpression - name: x-envoy-ai-gateway-model - value: llama3-70b + - headers: + - type: RegularExpression + name: x-envoy-ai-gateway-model + value: llama3-70b backendRefs: - name: kserve weight: 20