From 785339c7a5b08dd9b6c241f296a6a71c01a0f5e3 Mon Sep 17 00:00:00 2001 From: Tommy Skaug Date: Mon, 11 Nov 2024 19:38:40 +0100 Subject: [PATCH] chore: restructure workflows --- .forgejo/config/release.yaml | 15 --------- .forgejo/ct.yaml | 3 +- .forgejo/workflows/testing.yaml | 59 ++++++++++++++++++++------------- Taskfile.yaml | 12 +++++-- 4 files changed, 48 insertions(+), 41 deletions(-) delete mode 100644 .forgejo/config/release.yaml diff --git a/.forgejo/config/release.yaml b/.forgejo/config/release.yaml deleted file mode 100644 index 47b67ac..0000000 --- a/.forgejo/config/release.yaml +++ /dev/null @@ -1,15 +0,0 @@ -name: Release -on: - push: - branches: - - 'main' - -jobs: - release: - name: Release - uses: stenic/github-workflows/.github/workflows/release-docker-helm.yaml@main - with: - docker_image: "ghcr.io/${{ github.repository }}" - chart_path: './charts/well-known' - secrets: - token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} diff --git a/.forgejo/ct.yaml b/.forgejo/ct.yaml index 1f03617..1324759 100644 --- a/.forgejo/ct.yaml +++ b/.forgejo/ct.yaml @@ -2,4 +2,5 @@ chart-dirs: - charts remote: origin target-branch: main -check-version-increment: false +check-version-increment: true +validate-maintainers: false diff --git a/.forgejo/workflows/testing.yaml b/.forgejo/workflows/testing.yaml index 70c0ee8..20e0bc5 100644 --- a/.forgejo/workflows/testing.yaml +++ b/.forgejo/workflows/testing.yaml @@ -1,11 +1,13 @@ -name: Chart +name: Chart Validation on: pull_request: - - pull_request: + paths: + - 'charts/**' branches: - 'main' push: + paths: + - 'charts/**' branches: - 'main' @@ -18,18 +20,21 @@ jobs: with: fetch-depth: 0 - - name: Run chart-testing (list-changed) - id: list-changed + - name: List changed charts + id: changed-charts run: | - changed=$(ct --config .forgejo/ct.yaml list-changed) + changed=$(ct --config .forgejo/ct.yaml list-changed | tr '\n' ' ' | jq -R -s -c 'split(" ") | map(select(length > 0))') if [[ -n "$changed" ]]; then - echo "::set-output name=changed::true" + echo "changesExist=true" >> $GITHUB_ENV + echo "::set-output name=reposChanged::$changed" # Sets output as a JSON array fi + outputs: + reposChanged: ${{ steps.changed-charts.outputs.reposChanged }} + changesExist: ${{ env.changesExist }} - - name: Run chart-testing (lint) - run: ct --config .forgejo/ct.yaml lint - - polaris-audit: + validation: + needs: chart-testing + if: needs.chart-testing.outputs.changesExist == 'true' runs-on: flakes-action steps: - name: Checkout @@ -37,18 +42,26 @@ jobs: with: fetch-depth: 0 - - name: Run audit + - name: Process Changed Repositories run: | - polaris audit --helm-chart ./charts/well-known --helm-values ./charts/well-known/values.yaml --format pretty --set-exit-code-on-danger --set-exit-code-below-score 90 + repos='${{ needs.chart-testing.outputs.reposChanged }}' + for repo in $(echo $repos | jq -r '.[]'); do + echo "Linting $repo" + ct --config .forgejo/ct.yaml lint "$repo" - pluto-scan: - runs-on: flakes-action - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 + echo "Auditing $repo" + polaris audit --helm-chart "$repo" \ + --helm-values "$repo/values.yaml" \ + --format pretty \ + --set-exit-code-on-danger \ + --set-exit-code-below-score 90 - - name: Use pluto - run: | - helm template ./charts/well-known -f ./charts/well-known/ci/pluto-values.yaml | pluto detect - --ignore-deprecations + echo "Checking deprecated apiVersions for $repo" + helm template "$repo" -f "$repo/ci/pluto-values.yaml" | pluto detect - --ignore-deprecations + done + #with: + # FORGEJO_API_URL=https://code.252.no/api/v1 + # FORGEJO_TOKEN=123 + # REPO_OWNER=tommy + # REPO_NAME=charts + # ISSUE_INDEX=115 diff --git a/Taskfile.yaml b/Taskfile.yaml index 93f75ea..1042b14 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -5,12 +5,20 @@ vars: sh: "git rev-parse --show-toplevel" tasks: + act: + interactive: true + env: + DOCKER_HOST: ssh://colima + cmds: + - | + act --container-architecture linux/amd64 -W .forgejo -P flakes-action=code.252.no/tommy/flakes-action:latest + test: silent: false interactive: true cmds: - - act --artifact-server-path /tmp/artifacts --container-architecture linux/amd64 - + - act --artifact-server-path /tmp/artifacts --container-architecture + linux/amd64 validate: desc: Validate charts