Compare commits
2 Commits
b48e787e43
...
36e89677ca
Author | SHA1 | Date | |
---|---|---|---|
36e89677ca
|
|||
69e4880946 |
@@ -1,39 +1,77 @@
|
|||||||
name: lint-and-test
|
name: Helm Lint
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- 'clusters/**'
|
||||||
|
- ! 'clusters/*/archive'
|
||||||
|
|
||||||
pull_request:
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- 'clusters/**'
|
||||||
|
- ! 'clusters/*/archive'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint-test:
|
helm-lint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Set up Helm
|
- name: Set up Helm
|
||||||
uses: azure/setup-helm@v4
|
uses: azure/setup-helm@v4
|
||||||
with:
|
with:
|
||||||
|
token: ${{ secrets.GITEA_TOKEN }}
|
||||||
version: latest
|
version: latest
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Lint Helm Chart
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: "3.13"
|
|
||||||
check-latest: true
|
|
||||||
|
|
||||||
- name: Set up Chart Testing
|
|
||||||
uses: helm/chart-testing-action@v2.7.0
|
|
||||||
|
|
||||||
- name: Run Chart Testing (list-changed)
|
|
||||||
id: list-changed
|
|
||||||
run: |
|
run: |
|
||||||
changed=$(ct list-changed --target-branch ${{ gitea.event.repository.default_branch }} --chart-dirs clusters/cl01tl/*/* )
|
find clusters -maxdepth 4 -name Chart.yaml -exec dirname {} \; | while read -r chart_path; do
|
||||||
if [[ -n "$changed" ]]; then
|
echo "Building chart dependency in $chart_path"
|
||||||
echo "changed=true" >> $GITHUB_OUTPUT
|
helm dependency build "$chart_path"
|
||||||
|
echo "Linting chart in $chart_path"
|
||||||
|
helm lint "$chart_path"
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Lint Helm Chart
|
||||||
|
run: |
|
||||||
|
set -e # Exit immediately if a command exits with a non-zero status.
|
||||||
|
|
||||||
|
TARGET_BRANCH="origin/${{ gitea.base_ref }}"
|
||||||
|
echo "Target branch for diff is: $TARGET_BRANCH"
|
||||||
|
|
||||||
|
CHANGED_FILES=$(git diff --name-only "$TARGET_BRANCH" -- 'clusters/**')
|
||||||
|
|
||||||
|
echo "Found changed files:"
|
||||||
|
echo "$CHANGED_FILES"
|
||||||
|
|
||||||
|
# For each changed file, find its parent chart directory (the one with Chart.yaml).
|
||||||
|
# Then, create a unique list of those directories.
|
||||||
|
CHANGED_CHARTS=$(echo "$CHANGED_FILES" | while read -r file; do
|
||||||
|
dir=$(dirname "$file")
|
||||||
|
while [[ "$dir" != "." && ! -f "$dir/Chart.yaml" ]]; do
|
||||||
|
dir=$(dirname "$dir")
|
||||||
|
done
|
||||||
|
if [[ "$dir" != "." ]]; then
|
||||||
|
echo "$dir"
|
||||||
|
fi
|
||||||
|
done | sort -u)
|
||||||
|
|
||||||
|
if [[ -z "$CHANGED_CHARTS" ]]; then
|
||||||
|
echo "Could not determine changed charts. This could happen if only files outside a chart were changed."
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Run Chart Testing (lint)
|
echo "Running helm lint on changed charts:"
|
||||||
if: steps.list-changed.outputs.changed == 'true'
|
echo "$CHANGED_CHARTS"
|
||||||
run: ct lint --validate-maintainers=false --target-branch ${{ gitea.event.repository.default_branch }} --chart-dirs clusters/cl01tl/*/*
|
|
||||||
|
echo "$CHANGED_CHARTS" | while read -r chart; do
|
||||||
|
echo "Building dependency for "$chart" ..."
|
||||||
|
helm dependency build "$chart"
|
||||||
|
echo "Linting $chart..."
|
||||||
|
helm lint "$chart"
|
||||||
|
done
|
||||||
|
Reference in New Issue
Block a user