Skip to content

Commit

Permalink
Merge pull request #394 from Zhuzhenghao/yamllint
Browse files Browse the repository at this point in the history
Add scripts for yamllint
  • Loading branch information
k8s-ci-robot authored Mar 21, 2023
2 parents 75aa83c + f73830d commit 64d08be
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug-report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ body:
label: OS version
value: |
<details>
```console
```console
# On Linux:
$ cat /etc/os-release
# paste output here
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ linters-settings:
stylecheck:
go: "1.19"
# STxxxx checks in https://staticcheck.io/docs/configuration/options/#checks
checks: [ "all", "-ST1000", "-ST1003" ]
checks: ["all", "-ST1000", "-ST1003"]
depguard:
include-go-root: true
packages:
Expand Down
14 changes: 14 additions & 0 deletions .yamllint.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# configuration file rules
# https://yamllint.readthedocs.io/en/stable/rules.html

extends: default

ignore-from-file: .gitignore

rules:
indentation: disable
document-start: disable
comments: disable
line-length: disable
truthy:
check-keys: false
5 changes: 5 additions & 0 deletions hack/verify-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ if [[ "${VERIFY_CMD_DOCS:-true}" == "true" ]]; then
"${ROOT_DIR}"/hack/verify-cmd-docs.sh || failed+=(cmd-docs)
fi

if [[ "${VERIFY_YAMLLINT:-true}" == "true" ]]; then
echo "[*] Verifying YAML lint..."
"${ROOT_DIR}"/hack/verify-yamllint.sh || failed+=(yamllint)
fi

# exit based on verify scripts
if [[ "${#failed[@]}" != 0 ]]; then
echo "Verify failed for: ${failed[*]}"
Expand Down
42 changes: 42 additions & 0 deletions hack/verify-yamllint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash
# Copyright 2023 The Kubernetes 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 nounset
set -o pipefail

ROOT_DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")"/..)"
COMMAND=()
if command -v yamllint; then
COMMAND=(yamllint)
elif command -v python3; then
if ! python3 -m yamllint --help >/dev/null; then
python3 -m pip install --user yamllint
fi
COMMAND=(python3 -m yamllint)
elif command -v docker; then
COMMAND=(
docker run
--rm -i
-v "${ROOT_DIR}:/workdir"
-w "/workdir"
--security-opt="label=disable"
"docker.io/cytopia/yamllint:1.26@sha256:1bf8270a671a2e5f2fea8ac2e80164d627e0c5fa083759862bbde80628f942b2"
)
else
echo "WARNING: yamllint, python3 or docker not installed" >&2
exit 1
fi
cd "${ROOT_DIR}" && "${COMMAND[@]}" -s -c .yamllint.conf .
2 changes: 1 addition & 1 deletion test/lifecycle/fake-pod-stages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ spec:
apiVersion: batch/v1
kind: Job
metadata:
name: test-pod-for-job
name: test-pod-for-job
spec:
template:
spec:
Expand Down

0 comments on commit 64d08be

Please sign in to comment.