Linting and go-task.

This commit is contained in:
Skyler Mäntysaari 2022-10-27 12:28:30 +03:00
parent 6aa5551f2d
commit c6d897bbfa
6 changed files with 144 additions and 0 deletions

37
.ci/ct/chart_schema.yaml Normal file
View file

@ -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()

14
.ci/ct/ct.yaml Normal file
View file

@ -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

42
.ci/ct/lintconf.yaml Normal file
View file

@ -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

3
.ci/repo-config.yaml Normal file
View file

@ -0,0 +1,3 @@
excluded-charts-lint: []
excluded-charts-install: []

32
.taskfiles/charts.yaml Normal file
View file

@ -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

16
Taskfile.yml Normal file
View file

@ -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