Skip to content

Commit

Permalink
ci: add yamllint rules (apache#1666)
Browse files Browse the repository at this point in the history
* ci: add yamllint rules for yaml files

* ci: github action use official yamllint install

* fix: remove redundancy comment

* fix: enable indentation and empty value options
  • Loading branch information
sakulali authored Mar 3, 2023
1 parent 4091ea0 commit 9df7af6
Show file tree
Hide file tree
Showing 13 changed files with 13,908 additions and 13,555 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/yamllint-checker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

name: yamllint-checker

on:
push:
branches:
- master
pull_request:
branches:
- master
- v1.6.0
type: [review_requested, ready_for_review]
jobs:
changes:
runs-on: ubuntu-latest
outputs:
yaml: ${{ steps.filter.outputs.yaml }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- uses: ./.github/actions/paths-filter
id: filter
with:
token: ${{ secrets.GITHUB_TOKEN }}
# focus on `samples/deploy` yaml files directory
filters: |
yaml:
- 'samples/deploy/**/*'
yamllint-checker:
needs: changes
if: |
(needs.changes.outputs.yaml == 'true')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- run: pip install yamllint==1.29.0
- name: 🚀 Run yamllint
run: yamllint samples/deploy # focus on `samples/deploy` yaml files directory
49 changes: 49 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

---

yaml-files:
- '*.yaml'
- '*.yml'
- '.yamllint'

rules:
braces: disable # default: enable
brackets: disable # default: enable
colons: enable
commas: disable # default: enable
comments: disable # default: {level: warning}
comments-indentation: disable # default: {level: warning}
document-end: disable
document-start: disable # default: {level: warning}
empty-lines: enable
empty-values: enable
float-values: disable
hyphens: enable
indentation: enable
key-duplicates: enable
key-ordering: disable
line-length: disable # default: enable
new-line-at-end-of-file: disable # default: enable
new-lines: enable
octal-values: disable
quoted-strings: disable
trailing-spaces: enable
truthy:
level: warning
12 changes: 11 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,19 @@ verify-license:
verify-mdlint:
docker run -it --rm -v $(PWD):/work tmknom/markdownlint '**/*.md' --ignore node_modules --ignore CHANGELOG.md

### verify-yamllint: Verify yaml files lint rules for `samples/deploy` directory.
.PHONY: verify-yamllint
verify-yamllint:
docker run -it --rm -v $(PWD):/yaml peterdavehello/yamllint yamllint samples/deploy

### verify-all: Verify all verify- rules.
.PHONY: verify-all
verify-all: verify-codegen verify-license verify-mdlint
verify-all: verify-codegen verify-license verify-mdlint verify-yamllint

### update-yamlfmt: Update yaml files format for `samples/deploy` directory.
.PHONY: update-yamlfmt
update-yamlfmt:
go install github.com/google/yamlfmt/cmd/yamlfmt@latest && yamlfmt samples/deploy

### update-codegen: Update the generated codes (clientset, informer, deepcopy, etc).
.PHONY: update-codegen
Expand Down
2 changes: 1 addition & 1 deletion samples/deploy/admission/webhook-registration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ webhooks:
path: "/validation/apisixroutes/plugin"
caBundle: ${CA_BUNDLE}
rules:
- operations: [ "CREATE", "UPDATE" ]
- operations: ["CREATE", "UPDATE"]
apiGroups: ["apisix.apache.org"]
apiVersions: ["*"]
resources: ["apisixroutes"]
Expand Down
58 changes: 29 additions & 29 deletions samples/deploy/configmap/apisix-ingress-cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,37 @@
apiVersion: v1
data:
config.yaml: |
# log options
log_level: "info" # the error log level, default is info, optional values are:
# debug
# info
# warn
# error
# panic
# fatal
log_output: "stderr" # the output file path of error log, default is stderr, when
# the file path is "stderr" or "stdout", logs are marshalled
# plainly, which is more readable for human; otherwise logs
# are marshalled in JSON format, which can be parsed by
# programs easily.
# log options
log_level: "info" # the error log level, default is info, optional values are:
# debug
# info
# warn
# error
# panic
# fatal
log_output: "stderr" # the output file path of error log, default is stderr, when
# the file path is "stderr" or "stdout", logs are marshalled
# plainly, which is more readable for human; otherwise logs
# are marshalled in JSON format, which can be parsed by
# programs easily.
http_listen: ":8080" # the HTTP Server listen address, default is ":8080"
enable_profiling: true # enable profiling via web interfaces
# host:port/debug/pprof, default is true.
apisix-resource-sync-interval: 300s # Default interval for synchronizing Kubernetes resources to APISIX
# Kubernetes related configurations.
kubernetes:
kubeconfig: "" # the Kubernetes configuration file path, default is
# "", so the in-cluster configuration will be used.
resync_interval: "6h" # how long should apisix-ingress-controller
# re-synchronizes with Kubernetes, default is 6h,
# and the minimal resync interval is 30s.
http_listen: ":8080" # the HTTP Server listen address, default is ":8080"
enable_profiling: true # enable profiling via web interfaces
# host:port/debug/pprof, default is true.
apisix-resource-sync-interval: 300s # Default interval for synchronizing Kubernetes resources to APISIX
# Kubernetes related configurations.
kubernetes:
kubeconfig: "" # the Kubernetes configuration file path, default is
# "", so the in-cluster configuration will be used.
resync_interval: "6h" # how long should apisix-ingress-controller
# re-synchronizes with Kubernetes, default is 6h,
# and the minimal resync interval is 30s.
# APISIX related configurations.
apisix:
base_url: "http://apisix-admin:9180/apisix/admin" # the APISIX admin api / manager api
# base url, it's required.
admin_key: "edd1c9f034335f136f87ad84b625c8f1"
# APISIX related configurations.
apisix:
base_url: "http://apisix-admin:9180/apisix/admin" # the APISIX admin api / manager api
# base url, it's required.
admin_key: "edd1c9f034335f136f87ad84b625c8f1"
kind: ConfigMap
metadata:
name: apisix-ingress-cm
2 changes: 1 addition & 1 deletion samples/deploy/crd/v1/ApisixConsumer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -386,4 +386,4 @@ spec:
name:
type: string
minLength: 1
required:
required: null
19 changes: 10 additions & 9 deletions samples/deploy/crd/v1/ApisixRoute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ spec:
minLength: 1
servicePort:
anyOf:
- type: integer
- type: string
- type: integer
- type: string
x-kubernetes-int-or-string: true
resolveGranularity:
type: string
Expand Down Expand Up @@ -275,8 +275,8 @@ spec:
minLength: 1
servicePort:
anyOf:
- type: integer
- type: string
- type: integer
- type: string
x-kubernetes-int-or-string: true
resolveGranularity:
type: string
Expand Down Expand Up @@ -461,7 +461,8 @@ spec:
description: Upstreams refer to ApisixUpstream CRD
type: array
items:
description: ApisixRouteUpstreamReference contains a ApisixUpstream CRD reference
description: ApisixRouteUpstreamReference contains a ApisixUpstream
CRD reference
type: object
properties:
name:
Expand All @@ -479,8 +480,8 @@ spec:
minLength: 1
servicePort:
anyOf:
- type: integer
- type: string
- type: integer
- type: string
x-kubernetes-int-or-string: true
resolveGranularity:
type: string
Expand Down Expand Up @@ -584,8 +585,8 @@ spec:
minLength: 1
servicePort:
anyOf:
- type: integer
- type: string
- type: integer
- type: string
x-kubernetes-int-or-string: true
resolveGranularity:
type: string
Expand Down
Loading

0 comments on commit 9df7af6

Please sign in to comment.