Skip to content

Commit

Permalink
ci: improvements
Browse files Browse the repository at this point in the history
Signed-off-by: Marc 'risson' Schmitt <[email protected]>
  • Loading branch information
rissson committed Jan 5, 2024
1 parent 4c1c763 commit 008bd0c
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 15 deletions.
13 changes: 13 additions & 0 deletions .github/configs/ct-install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
remote: origin
target-branch: main
chart-dirs:
- charts
chart-repos:
- authentik=https://charts.goauthentik.io
helm-extra-args: --timeout 180s
check-version-increment: false
validate-maintainers: false
validate-yaml: true
exclude-deprecated: true
excluded-charts: []
6 changes: 5 additions & 1 deletion ct.yaml → .github/configs/ct-lint.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
---
remote: origin
target-branch: main
chart-dirs:
- charts
chart-repos:
- authentik=https://charts.goauthentik.io
helm-extra-args: --timeout 180s
check-version-increment: false
validate-maintainers: false
exclude-deprecated: true
excluded-charts: []
42 changes: 42 additions & 0 deletions .github/configs/lintconf.yaml
Original file line number Diff line number Diff line change
@@ -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: 1
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
64 changes: 50 additions & 14 deletions .github/workflows/lint-test.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
name: "Lint and Test Chart"

on:
Expand All @@ -7,36 +8,71 @@ on:
pull_request:

jobs:
lint-and-test:
runs-on: ubuntu-20.04
linter-artifacthub:
runs-on: ubuntu-latest
container:
image: public.ecr.aws/artifacthub/ah:v1.14.0
options: --user 1001
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run ah lint
working-directory: ./charts
run: ah lint

chart-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: "0"
fetch-depth: 0

- name: Set up Helm
uses: azure/[email protected]
- uses: actions/setup-python@v5
uses: azure/setup-helm@v3

- name: Set up python
uses: actions/setup-python@v5
with:
python-version: 3.9.2
- name: Set up chart-testing
uses: helm/[email protected]
- name: Run chart-testing (list-changed)
python-version: "3.9"

- name: Setup Chart Linting
id: lint
uses: helm/chart-testing-action@v2

- name: List changed charts
id: list-changed
run: |
changed=$(ct list-changed --config ct.yaml)
changed=$(ct --config ./.github/configs/ct-lint.yaml list-changed)
charts=$(echo "$changed" | tr '\n' ' ' | xargs)
if [[ -n "$changed" ]]; then
echo "changed=true" >> $GITHUB_OUTPUT
echo "changed_charts=$charts" >> $GITHUB_OUTPUT
fi
- name: Run chart-testing (lint)
run: ct lint --config ct.yaml
run: ct lint --debug --config ./.github/configs/ct-lint.yaml --lint-conf ./.github/configs/lintconf.yaml

- name: Run docs-testing (helm-docs)
id: helm-docs
run: |
./scripts/helm-docs.sh
if [[ $(git diff --stat) != '' ]]; then
echo -e '\033[0;31mDocumentation outdated!\033[0m ❌'
git diff --color
exit 1
else
echo -e '\033[0;32mDocumentation up to date\033[0m ✔'
fi
- name: Create kind cluster
uses: helm/kind-action@v1.8.0
uses: helm/kind-action@v1
if: steps.list-changed.outputs.changed == 'true'

- name: Run chart-testing (install)
if: steps.list-changed.outputs.changed == 'true'
run: |
namespace=authentik-$(uuidgen)
kubectl create ns $namespace
kubectl apply -n $namespace -f charts/authentik/ci/manifests/
ct install --namespace=$namespace --config ct.yaml
ct install --namespace=$namespace --config ./.github/configs/ct-install.yaml
if: steps.list-changed.outputs.changed == 'true'
12 changes: 12 additions & 0 deletions scripts/helm-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
## Reference: https://github.com/norwoodj/helm-docs
set -eux
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
echo "$REPO_ROOT"

echo "Running Helm-Docs"
docker run \
--rm \
-v "$REPO_ROOT:/helm-docs" \
-u $(id -u) \
jnorwood/helm-docs:v1.12.0
17 changes: 17 additions & 0 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
# Reference: https://github.com/helm/chart-testing
set -eux

SRCROOT="$(cd "$(dirname "$0")/.." && pwd)"

echo -e "\n-- Linting all Helm Charts --\n"
docker run \
--rm \
-v "$SRCROOT:/workdir" \
--entrypoint /bin/sh \
quay.io/helmpack/chart-testing:v3.10.1 \
-c cd /workdir \
ct lint \
--config .github/configs/ct-lint.yaml \
--lint-conf .github/configs/lintconf.yaml \
--debug

0 comments on commit 008bd0c

Please sign in to comment.