diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml new file mode 100755 index 00000000000..bd63e2b5cf3 --- /dev/null +++ b/.github/workflows/lint.yaml @@ -0,0 +1,23 @@ +name: Lint YAML files + +on: + - push + - pull_request + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + + - name: Check YAML + run: make yamllint + diff --git a/Makefile b/Makefile old mode 100644 new mode 100755 index 6ae3bb75aa8..336c564eea2 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ HAS_LINT := $(shell command -v golangci-lint;) +HAS_YAMLLINT := $(shell command -v yamllint;) HAS_SHELLCHECK := $(shell command -v shellcheck;) HAS_SETUP_ENVTEST := $(shell command -v setup-envtest;) @@ -36,6 +37,13 @@ ifndef HAS_LINT endif hack/verify-golangci-lint.sh +yamllint: +ifndef HAS_YAMLLINT + pip install yamllint + @echo "yamllint has been installed" +endif + hack/verify-yamllint.sh + vet: go vet ./pkg/... ./cmd/... diff --git a/hack/verify-yamllint.sh b/hack/verify-yamllint.sh new file mode 100755 index 00000000000..0427af97905 --- /dev/null +++ b/hack/verify-yamllint.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# Copyright 2022 The Kubeflow Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -o errexit +set -o pipefail + +cd "$(dirname "$0")/.." + +if [ -z "$(command -v yamllint)" ]; then + echo 'Can not find yamllint, install with: make yamllint' + exit 1 +fi + +echo 'Running yamllint' +yamllint -d "{extends: default, rules: {line-length: disable}}" examples/* manifests/* \ No newline at end of file