Skip to content

Commit 9ee8fda

Browse files
authored
Linting for K8s YAML files (#1901)
* Add yamllint checking * Update yamllint command * Revert changes to charmed * Create new workflow for yamllint * Create a script to verify installation and run yamllint * Add `make yamllint` * Update lint workflow
1 parent 7bf3922 commit 9ee8fda

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

.github/workflows/lint.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Lint YAML files
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
lint:
9+
name: Lint
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Check out code
14+
uses: actions/checkout@v2
15+
16+
- name: Setup Python
17+
uses: actions/setup-python@v2
18+
with:
19+
python-version: 3.9
20+
21+
- name: Check YAML
22+
run: make yamllint
23+

Makefile

100644100755
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
HAS_LINT := $(shell command -v golangci-lint;)
2+
HAS_YAMLLINT := $(shell command -v yamllint;)
23
HAS_SHELLCHECK := $(shell command -v shellcheck;)
34
HAS_SETUP_ENVTEST := $(shell command -v setup-envtest;)
45

@@ -36,6 +37,13 @@ ifndef HAS_LINT
3637
endif
3738
hack/verify-golangci-lint.sh
3839

40+
yamllint:
41+
ifndef HAS_YAMLLINT
42+
pip install yamllint
43+
@echo "yamllint has been installed"
44+
endif
45+
hack/verify-yamllint.sh
46+
3947
vet:
4048
go vet ./pkg/... ./cmd/...
4149

hack/verify-yamllint.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2022 The Kubeflow Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o pipefail
19+
20+
cd "$(dirname "$0")/.."
21+
22+
if [ -z "$(command -v yamllint)" ]; then
23+
echo 'Can not find yamllint, install with: make yamllint'
24+
exit 1
25+
fi
26+
27+
echo 'Running yamllint'
28+
yamllint -d "{extends: default, rules: {line-length: disable}}" examples/* manifests/*

0 commit comments

Comments
 (0)