From dae2fda64e5d1278b65ccac54ed5c712a78138b6 Mon Sep 17 00:00:00 2001 From: Raven Daugherty Date: Mon, 9 Dec 2019 19:41:28 -0600 Subject: [PATCH] Added YAML file linting to maas Change-Id: I4711ad587d903e25bd59cd5cae75841166340a84 --- .zuul.yaml | 11 +++++++++++ tools/gate/install-yaml-lint.sh | 16 ++++++++++++++++ tools/gate/lint-yaml.sh | 13 +++++++++++++ tools/gate/playbooks/helm-linter.yaml | 1 - tools/gate/playbooks/lint-yaml.yaml | 21 +++++++++++++++++++++ tools/gate/playbooks/yamllint-config.yaml | 20 ++++++++++++++++++++ 6 files changed, 81 insertions(+), 1 deletion(-) create mode 100755 tools/gate/install-yaml-lint.sh create mode 100755 tools/gate/lint-yaml.sh create mode 100644 tools/gate/playbooks/lint-yaml.yaml create mode 100644 tools/gate/playbooks/yamllint-config.yaml diff --git a/.zuul.yaml b/.zuul.yaml index 3d5cc5d..b39f4f6 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -17,11 +17,13 @@ - airship-maas-chart-build-gate - airship-maas-chart-build-latest-htk - airship-maas-docker-build-gate + - airship-maas-lint-yaml gate: jobs: - airship-maas-lint-ws - airship-maas-chart-build-gate - airship-maas-docker-build-gate + - airship-maas-lint-yaml post: jobs: - airship-maas-docker-publish @@ -71,6 +73,15 @@ dynamic: patch_set: true +- job: + name: airship-maas-lint-yaml + voting: true + timeout: 900 + run: tools/gate/playbooks/lint-yaml.yaml + nodeset: ubuntu-bionic + irrelevant-files: + - '^charts/maas/templates/.*' + - job: name: airship-maas-docker-publish timeout: 1800 diff --git a/tools/gate/install-yaml-lint.sh b/tools/gate/install-yaml-lint.sh new file mode 100755 index 0000000..cf7dceb --- /dev/null +++ b/tools/gate/install-yaml-lint.sh @@ -0,0 +1,16 @@ +# 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 -xe + +sudo apt-get update +sudo apt-get install --no-install-recommends -y yamllint diff --git a/tools/gate/lint-yaml.sh b/tools/gate/lint-yaml.sh new file mode 100755 index 0000000..bf97e94 --- /dev/null +++ b/tools/gate/lint-yaml.sh @@ -0,0 +1,13 @@ +# 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. + +yamllint -c ./tools/gate/playbooks/yamllint-config.yaml . diff --git a/tools/gate/playbooks/helm-linter.yaml b/tools/gate/playbooks/helm-linter.yaml index 9e449ac..7677817 100644 --- a/tools/gate/playbooks/helm-linter.yaml +++ b/tools/gate/playbooks/helm-linter.yaml @@ -1,4 +1,3 @@ - # 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 diff --git a/tools/gate/playbooks/lint-yaml.yaml b/tools/gate/playbooks/lint-yaml.yaml new file mode 100644 index 0000000..2d5bebe --- /dev/null +++ b/tools/gate/playbooks/lint-yaml.yaml @@ -0,0 +1,21 @@ +# 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. + +- hosts: ubuntu-bionic + tasks: + - name: lint-yaml + shell: | + set -xe; + ./tools/gate/install-yaml-lint.sh + ./tools/gate/lint-yaml.sh + args: + chdir: "{{ zuul.project.src_dir }}" diff --git a/tools/gate/playbooks/yamllint-config.yaml b/tools/gate/playbooks/yamllint-config.yaml new file mode 100644 index 0000000..5b4c653 --- /dev/null +++ b/tools/gate/playbooks/yamllint-config.yaml @@ -0,0 +1,20 @@ +# 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. +--- +extends: default + +ignore: + /charts/maas/templates/ +rules: + line-length: + max: 80 + level: warning