From c6d897bbfad6279a4c768296f9711ad63cabff62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Skyler=20M=C3=A4ntysaari?= Date: Thu, 27 Oct 2022 12:28:30 +0300 Subject: [PATCH] Linting and go-task. --- .ci/ct/chart_schema.yaml | 37 +++++++++++++++++++++++++++++++++++ .ci/ct/ct.yaml | 14 ++++++++++++++ .ci/ct/lintconf.yaml | 42 ++++++++++++++++++++++++++++++++++++++++ .ci/repo-config.yaml | 3 +++ .taskfiles/charts.yaml | 32 ++++++++++++++++++++++++++++++ Taskfile.yml | 16 +++++++++++++++ 6 files changed, 144 insertions(+) create mode 100644 .ci/ct/chart_schema.yaml create mode 100644 .ci/ct/ct.yaml create mode 100644 .ci/ct/lintconf.yaml create mode 100644 .ci/repo-config.yaml create mode 100644 .taskfiles/charts.yaml create mode 100644 Taskfile.yml diff --git a/.ci/ct/chart_schema.yaml b/.ci/ct/chart_schema.yaml new file mode 100644 index 0000000..9235d10 --- /dev/null +++ b/.ci/ct/chart_schema.yaml @@ -0,0 +1,37 @@ +name: str() +home: str(required=False) +version: str() +apiVersion: str() +appVersion: any(str(), num(), required=False) +description: str(required=False) +keywords: list(str(), required=False) +sources: list(str(), required=False) +maintainers: list(include('maintainer'), required=False) +dependencies: list(include('dependency'), required=False) +icon: str(required=False) +engine: str(required=False) +condition: str(required=False) +tags: str(required=False) +deprecated: bool(required=False) +kubeVersion: str(required=False) +annotations: map(str(), str(), required=True) +type: str(required=False) +--- +maintainer: + name: str() + email: str(required=False) + url: str(required=False) +--- +dependency: + name: str() + version: str() + repository: str(required=False) + condition: str(required=False) + tags: list(str(), required=False) + enabled: bool(required=False) + import-values: any(list(str()), list(include('import-value')), required=False) + alias: str(required=False) +--- +import-value: + child: str() + parent: str() diff --git a/.ci/ct/ct.yaml b/.ci/ct/ct.yaml new file mode 100644 index 0000000..d66fac3 --- /dev/null +++ b/.ci/ct/ct.yaml @@ -0,0 +1,14 @@ + +chart-yaml-schema: .ci/ct/chart_schema.yaml +lint-conf: .ci/ct/lintconf.yaml + +remote: origin +target-branch: main + +helm-extra-args: --timeout 600s + +chart-dirs: + - charts + +chart-repos: + - bjw-s=https://bjw-s.github.io/helm-charts diff --git a/.ci/ct/lintconf.yaml b/.ci/ct/lintconf.yaml new file mode 100644 index 0000000..90f48c8 --- /dev/null +++ b/.ci/ct/lintconf.yaml @@ -0,0 +1,42 @@ +--- +rules: + braces: + min-spaces-inside: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: -1 + max-spaces-inside-empty: -1 + brackets: + min-spaces-inside: 0 + max-spaces-inside: 0 + min-spaces-inside-empty: -1 + max-spaces-inside-empty: -1 + colons: + max-spaces-before: 0 + max-spaces-after: 1 + commas: + max-spaces-before: 0 + min-spaces-after: 1 + max-spaces-after: 1 + comments: + require-starting-space: true + min-spaces-from-content: 2 + document-end: disable + document-start: disable # No --- to start a file + empty-lines: + max: 2 + max-start: 0 + max-end: 0 + hyphens: + max-spaces-after: 1 + indentation: + spaces: consistent + indent-sequences: whatever # - list indentation will handle both indentation and without + check-multi-line-strings: false + key-duplicates: enable + line-length: disable # Lines can be any length + new-line-at-end-of-file: enable + new-lines: + type: unix + trailing-spaces: enable + truthy: + level: warning diff --git a/.ci/repo-config.yaml b/.ci/repo-config.yaml new file mode 100644 index 0000000..64bc02e --- /dev/null +++ b/.ci/repo-config.yaml @@ -0,0 +1,3 @@ +excluded-charts-lint: [] + +excluded-charts-install: [] diff --git a/.taskfiles/charts.yaml b/.taskfiles/charts.yaml new file mode 100644 index 0000000..fe5d7de --- /dev/null +++ b/.taskfiles/charts.yaml @@ -0,0 +1,32 @@ +--- +version: "3" + +vars: + CT_IMAGE: quay.io/helmpack/chart-testing:v3.6.0 + REPO_CONFIG_FILE: .ci/repo-config.yaml + CT_CONFIG_FILE: .ci/ct/ct.yaml + CHARTS_EXCLUDED_FROM_LINT: + sh: yq eval '.excluded-charts-lint | join(",")' {{.REPO_CONFIG_FILE}} + CHARTS_EXCLUDED_FROM_INSTALL: + sh: yq eval '.excluded-charts-install | join(",")' {{.REPO_CONFIG_FILE}} + +tasks: + lint: + desc: Run ct-lint on charts + cmds: + - docker run --rm -it --workdir=/data --volume $(pwd):/data {{.CT_IMAGE}} ct lint --config {{.CT_CONFIG_FILE}} --excluded-charts "{{.CHARTS_EXCLUDED_FROM_LINT}}" + silent: true + + lint-all: + desc: Run ct-lint on all charts + cmds: + - docker run --rm -it --workdir=/data --volume $(pwd):/data {{.CT_IMAGE}} ct lint --config {{.CT_CONFIG_FILE}} --all --excluded-charts "{{.CHARTS_EXCLUDED_FROM_LINT}}" + silent: true + + dependency-cleanup: + desc: clean up chart dependencies + dir: "{{.PROJECT_DIR}}/charts" + cmds: + - find {{.PROJECT_DIR}}/charts/ -type f -name 'Chart.lock' -mindepth 1 -print0 | xargs -r -0 rm + - find {{.PROJECT_DIR}}/charts/ -type d -name 'charts' -mindepth 1 -print0 | xargs -r -0 rm -rf + silent: true diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 0000000..f4b9524 --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,16 @@ +--- +version: 3 + + +vars: + PROJECT_DIR: + sh: git rev-parse --show-toplevel + +includes: + charts: .taskfiles/charts.yaml + +tasks: + default: + silent: true + cmds: + - task -l