From 83930d998e791a95faf61ddb25d1f75ccd8fc6a8 Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Mon, 25 Nov 2024 16:26:34 +0100 Subject: [PATCH] Automate ignoring deprecated charts --- .github/workflows/helm-charts-test.yaml | 71 ++++++++++++++++++------- 1 file changed, 52 insertions(+), 19 deletions(-) diff --git a/.github/workflows/helm-charts-test.yaml b/.github/workflows/helm-charts-test.yaml index 0f2db42..97cf17a 100644 --- a/.github/workflows/helm-charts-test.yaml +++ b/.github/workflows/helm-charts-test.yaml @@ -3,33 +3,48 @@ name: "helm-charts/test" on: pull_request jobs: - lint: + generate-charts: runs-on: ubuntu-latest + name: Generate Charts + outputs: + deprecated: ${{ steps.deprecated.outputs.charts }} + maintained: ${{ steps.maintained.outputs.charts }} steps: - name: Checkout uses: actions/checkout@v4 - - - name: Fetch history - run: git fetch --prune --unshallow - - name: Install Chart Tester - uses: helm/chart-testing-action@v2.6.1 - - name: Add WyriHaximusNet repo - run: helm repo add WyriHaximusNet https://helm.wyrihaximus.net/ - - name: Lint charts - id: lint - run: ct lint --all + with: + sparse-checkout: | + charts/ + - name: Get values files + uses: tj-actions/glob@v22 + id: charts + with: + separator: "," + files: | + charts/${{ matrix.chart }}/**/Chart.yaml + - name: Deprecated Charts + id: deprecated + run: | + printf "charts=%s" $(echo "${{ steps.charts.outputs.paths }}" | docker run -i --rm -v $(pwd):$(pwd) -w $(pwd) ghcr.io/wyrihaximusnet/php:8.4-nts-alpine-root php -r 'echo str_replace(["charts", "Chart.yaml", "/", "\\"], "", json_encode(array_values(array_filter(explode(",", trim(fgets(STDIN))), static fn (string $path): bool => str_contains(file_get_contents($path), "deprecated: true"))))) . "\n";') >> $GITHUB_OUTPUT + - name: Maintained Charts + id: maintained + run: | + printf "charts=%s" $(echo "${{ steps.charts.outputs.paths }}" | docker run -i --rm -v $(pwd):$(pwd) -w $(pwd) ghcr.io/wyrihaximusnet/php:8.4-nts-alpine-root php -r 'echo str_replace(["charts", "Chart.yaml", "/", "\\"], "", json_encode(array_values(array_filter(explode(",", trim(fgets(STDIN))), static fn (string $path): bool => !str_contains(file_get_contents($path), "deprecated: true"))))) . "\n";') >> $GITHUB_OUTPUT + - name: Show chart lists + run: | + echo "Deprecated:" + echo ${{ steps.deprecated.outputs.charts }} + echo "Maintained:" + echo ${{ steps.maintained.outputs.charts }} validate-values-schema: runs-on: ubuntu-latest name: Validate values schema json + needs: + - generate-charts strategy: + fail-fast: false matrix: - chart: - - cron-jobs - - default-backend - - docker-hub-exporter - - pi-hole-exporter - - redirect - - redis-db-assignment-operator + chart: ${{ fromJson(needs.generate-charts.outputs.maintained) }} steps: - name: Checkout uses: actions/checkout@v4 @@ -49,11 +64,29 @@ jobs: input: ${{ steps.valueFiles.outputs.paths }} output: charts/${{ matrix.chart }}/values.schema.json fail-on-diff: true + lint: + name: Lint + runs-on: ubuntu-latest + needs: + - validate-values-schema + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Fetch history + run: git fetch --prune --unshallow + - name: Install Chart Tester + uses: helm/chart-testing-action@v2.6.1 + - name: Add WyriHaximusNet repo + run: helm repo add WyriHaximusNet https://helm.wyrihaximus.net/ + - name: Lint charts + id: lint + run: ct lint --all test: + Name: Test on Kubernetes v${{ matrix.k8s }} runs-on: ubuntu-latest needs: - lint - - validate-values-schema strategy: fail-fast: false matrix: