From 657bba28abcec916977eddc1952dfd801ebaaf46 Mon Sep 17 00:00:00 2001 From: Bird Date: Thu, 1 Dec 2022 16:59:23 +0800 Subject: [PATCH 1/2] ci: yaml lint Signed-off-by: Bird --- .github/workflows/lint-yaml.yml | 23 ++++++++++++++++++++++ .yamllint.yml | 34 +++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 .github/workflows/lint-yaml.yml create mode 100644 .yamllint.yml diff --git a/.github/workflows/lint-yaml.yml b/.github/workflows/lint-yaml.yml new file mode 100644 index 000000000..2542f135e --- /dev/null +++ b/.github/workflows/lint-yaml.yml @@ -0,0 +1,23 @@ +name: Yaml Lint + +on: + pull_request: + branches: [ main ] + paths: + - '**.yaml' + - '**.yml' + +jobs: + yamlLint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Remove All Strings In Square Brackets + run: | + # remove strings in "[[]]" in .yml or .yaml files, or yaml lint will fail + sed -i "s/\[\[.*\]\]//g" `grep "\[\[.*\]\]" -rl --include="*.yml" --include="*.yaml" .` + - name: Yaml Lint + uses: ibiqlik/action-yamllint@v3 + with: + file_or_dir: . + config_file: .yamllint.yml diff --git a/.yamllint.yml b/.yamllint.yml new file mode 100644 index 000000000..c2e5a64ec --- /dev/null +++ b/.yamllint.yml @@ -0,0 +1,34 @@ +extends: default +rules: + brackets: disable # do not check brackets + comments: + require-starting-space: true + min-spaces-from-content: 1 # at leaset 1 space between comment and content + document-start: disable # whether the document must start with '---' is optional + indentation: + spaces: 2 + # block sequences should not be indented + # e.g.: + # OK: + # key: + # - value1 + # - value2 + # NOT OK: + # key: + # - value1 + # - value2 + indent-sequences: false + line-length: disable + new-line-at-end-of-file: enable # must have a new line at the end of file + trailing-spaces: disable # do not check trailing spaces + truthy: disable # do not check truthy +ignore: | + *.tpl.yaml + *.tpl.yml + *tmpl.yaml + *tmpl.yml + *template.yml + *template.yaml + **/.github/** + **/githubactions/** + **/workflows/** From d365f0415308c956e2a78c7483cdafedcf10e789 Mon Sep 17 00:00:00 2001 From: Bird Date: Thu, 1 Dec 2022 18:14:33 +0800 Subject: [PATCH 2/2] chore: format yaml files Signed-off-by: Bird --- hack/e2e/kind.yaml | 12 ++++++------ internal/pkg/show/config/plugins/ci-generic.yaml | 2 +- internal/pkg/show/config/plugins/gitlabci-java.yaml | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/hack/e2e/kind.yaml b/hack/e2e/kind.yaml index 8ce72f350..6c7e1e769 100644 --- a/hack/e2e/kind.yaml +++ b/hack/e2e/kind.yaml @@ -1,9 +1,9 @@ kind: Cluster apiVersion: kind.x-k8s.io/v1alpha4 nodes: - - role: control-plane - extraPortMappings: - - containerPort: 8080 - hostPort: 8080 - listenAddress: "0.0.0.0" - protocol: tcp +- role: control-plane + extraPortMappings: + - containerPort: 8080 + hostPort: 8080 + listenAddress: "0.0.0.0" + protocol: tcp diff --git a/internal/pkg/show/config/plugins/ci-generic.yaml b/internal/pkg/show/config/plugins/ci-generic.yaml index cb843f592..92c9c01d6 100644 --- a/internal/pkg/show/config/plugins/ci-generic.yaml +++ b/internal/pkg/show/config/plugins/ci-generic.yaml @@ -8,7 +8,7 @@ tools: # options for the plugin options: ci: - configLocation : Jenkinsfile + configLocation: Jenkinsfile # support jenkins/gitlab/github for now type: jenkins projectRepo: diff --git a/internal/pkg/show/config/plugins/gitlabci-java.yaml b/internal/pkg/show/config/plugins/gitlabci-java.yaml index 366735a59..84b5f5688 100644 --- a/internal/pkg/show/config/plugins/gitlabci-java.yaml +++ b/internal/pkg/show/config/plugins/gitlabci-java.yaml @@ -23,11 +23,11 @@ tools: tags: "YOUR_GITLAB_RUNNER_TAG" # Package step will run on the specified branchs, default use "main" allowedBranch: - - "main" - - "test" - # Customized pipeline scripts. Leave it blank to use default value. + - "main" + - "test" + # Customized pipeline scripts. Leave it blank to use default value. scriptCommand: - - "YOUR_PACKAGE_SCRIPTS" + - "YOUR_PACKAGE_SCRIPTS" build: # Same as above baseOption: