From c12232aaf5f06b7cee402f758c2c51de8dd3f056 Mon Sep 17 00:00:00 2001 From: Sam Simpson Date: Fri, 20 Jun 2025 13:45:07 +0100 Subject: [PATCH 1/3] Add chart diffing GHA workflow --- .github/workflows/diff-changes.yml | 84 ++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 .github/workflows/diff-changes.yml diff --git a/.github/workflows/diff-changes.yml b/.github/workflows/diff-changes.yml new file mode 100644 index 00000000000..195531da4f5 --- /dev/null +++ b/.github/workflows/diff-changes.yml @@ -0,0 +1,84 @@ +name: Diff chart changes +on: + pull_request: + types: [opened, reopened, synchronize] +concurrency: + group: ${{ github.workflow }}-${{ github.repository }}-${{ github.ref_name }} + cancel-in-progress: false + +jobs: + render-charts-base: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.base.ref }} + show-progress: false + - name: Run govuk-app-render + run: ./govuk-app-render.sh + - name: Archive rendered charts + uses: actions/upload-artifact@v4 + with: + name: rendered-charts-base + path: output/ + retention-days: 1 + render-charts-head: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.ref }} + show-progress: false + - name: Run govuk-app-render + run: ./govuk-app-render.sh + - name: Archive rendered charts + uses: actions/upload-artifact@v4 + with: + name: rendered-charts-head + path: output/ + retention-days: 1 + diff-charts: + runs-on: ubuntu-latest + needs: [render-charts-base, render-charts-head] + permissions: + pull-requests: write + steps: + - uses: actions/download-artifact@v4 + with: + name: rendered-charts-base + path: base-r/ + - uses: actions/download-artifact@v4 + with: + name: rendered-charts-head + path: head-r/ + - name: Diff charts and comment on PR + env: + GH_TOKEN: ${{ github.token }} + run: | + mkdir base head + + mv base-r/rendered-charts/* base/ + mv head-r/rendered-charts/* head/ + + DIFF=$(diff -r base/ head/) + + if [ -z "$DIFF" ]; then + cat < pr.md + No changes detected in rendered charts. + EOF + else + cat < pr.md +
+ Rendered charts diff + This PR results in the following changes to rendered charts: + + ```diff + ${DIFF} + ``` +
+ EOF + fi + + gh pr comment "${{github.event.pull_request.html_url}}" --create-if-none --edit-last --body-file pr.md From f3817f80b64d156a7df406fe0973cc5464d2538d Mon Sep 17 00:00:00 2001 From: Sam Simpson Date: Fri, 20 Jun 2025 14:00:06 +0100 Subject: [PATCH 2/3] Make example change to a chart value --- charts/app-config/values-staging.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/app-config/values-staging.yaml b/charts/app-config/values-staging.yaml index d936fee4b6b..02e95e8af0c 100644 --- a/charts/app-config/values-staging.yaml +++ b/charts/app-config/values-staging.yaml @@ -169,7 +169,7 @@ govukApplications: memory: 4Gi requests: cpu: 10m - memory: 2Gi + memory: 4Gi redis: enabled: true ingress: From a2e40c2ad52169ea284039a5b2194f52ce41851a Mon Sep 17 00:00:00 2001 From: Sam Simpson Date: Fri, 20 Jun 2025 14:00:45 +0100 Subject: [PATCH 3/3] Make example change to generic chart --- .github/workflows/diff-changes.yml | 33 ++++----------- .../generic-govuk-app/templates/ingress.yaml | 1 + create-diff-pr.sh | 40 +++++++++++++++++++ 3 files changed, 48 insertions(+), 26 deletions(-) create mode 100755 create-diff-pr.sh diff --git a/.github/workflows/diff-changes.yml b/.github/workflows/diff-changes.yml index 195531da4f5..4707b7e51c1 100644 --- a/.github/workflows/diff-changes.yml +++ b/.github/workflows/diff-changes.yml @@ -45,6 +45,11 @@ jobs: permissions: pull-requests: write steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.ref }} + show-progress: false - uses: actions/download-artifact@v4 with: name: rendered-charts-base @@ -56,29 +61,5 @@ jobs: - name: Diff charts and comment on PR env: GH_TOKEN: ${{ github.token }} - run: | - mkdir base head - - mv base-r/rendered-charts/* base/ - mv head-r/rendered-charts/* head/ - - DIFF=$(diff -r base/ head/) - - if [ -z "$DIFF" ]; then - cat < pr.md - No changes detected in rendered charts. - EOF - else - cat < pr.md -
- Rendered charts diff - This PR results in the following changes to rendered charts: - - ```diff - ${DIFF} - ``` -
- EOF - fi - - gh pr comment "${{github.event.pull_request.html_url}}" --create-if-none --edit-last --body-file pr.md + PR_URL: ${{ github.event.pull_request.html_url }} + run: ./create-diff-pr.sh diff --git a/charts/generic-govuk-app/templates/ingress.yaml b/charts/generic-govuk-app/templates/ingress.yaml index 137e4e7418e..26c32720d19 100644 --- a/charts/generic-govuk-app/templates/ingress.yaml +++ b/charts/generic-govuk-app/templates/ingress.yaml @@ -10,6 +10,7 @@ metadata: app: {{ $fullName }} app.kubernetes.io/name: {{ $fullName }} app.kubernetes.io/component: app + some-other-label: something annotations: {{- (tpl (toYaml .Values.ingress.annotations) .) | trim | nindent 4 }} spec: diff --git a/create-diff-pr.sh b/create-diff-pr.sh new file mode 100755 index 00000000000..f6060bda6f2 --- /dev/null +++ b/create-diff-pr.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +set -euo pipefail + +echo "directories" + +mkdir base head + +mv base-r/rendered-charts/* base/ +mv head-r/rendered-charts/* head/ + +echo "diff" + +diff -r base/ head/ + +DIFF=$(diff -r base/ head/) + +echo "before if" + +if [ -z "$DIFF" ]; then + cat <<'EOF' > pr.md +No changes detected in rendered charts. +EOF +else + echo "there are changes" + echo "${DIFF}" +cat <<'EOF' > pr.md +
+Rendered charts diff +This PR results in the following changes to rendered charts: + +```diff +EOF + { + echo "$DIFF" + echo '```' + echo '
' + } >> pr.md +fi + +gh pr comment "${PR_URL}" --create-if-none --edit-last --body-file pr.md