-
Notifications
You must be signed in to change notification settings - Fork 1
167 lines (153 loc) · 7.19 KB
/
zz_generated.diff_helm_render_templates.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# DO NOT EDIT. Generated with:
#
# devctl
#
# https://github.com/giantswarm/devctl/blob/c90dd09846d2e87f1bad62d2089405b78da11a82/pkg/gen/input/workflows/internal/file/helm_render_diff.yaml.template
#
name: Compare Helm Rendering
on:
pull_request:
push:
branches: [HEAD_BRANCH, main]
env:
dyff_ver: "1.7.1"
helm_ver: "3.11.1"
jobs:
# This job is for checking for the `/no_diffs_printing` comment in the PR. When it is found,
# the `get-rendering-values` job is skipped, what makes `cmp-helm-rendering` skipped as well.
check-cmp-state:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Find suspend comment
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0
continue-on-error: true
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
body-regex: '^\s*/no_diffs_printing' # on a separate line, not as Markdown `<!-- /no_diffs_printing -->` comment
- name: Find suspend comment in PR body # PR body isn't a comment, so the above step won't find it
id: pr_body
run: |
if jq -r .pull_request.body "${GITHUB_EVENT_PATH}" | grep -qE '^\s*/no_diffs_printing'; then
echo "Found /no_diffs_printing command in PR body"
echo "suspend_diffs_printing_from_pr_body=true" >> $GITHUB_OUTPUT
else
echo "Did not find /no_diffs_printing command in PR body"
echo "suspend_diffs_printing_from_pr_body=false" >> $GITHUB_OUTPUT
fi
outputs:
suspend_comment_id: ${{ steps.fc.outputs.comment-id }}
suspend_diffs_printing_from_pr_body: ${{ steps.pr_body.outputs.suspend_diffs_printing_from_pr_body }}
cmp-helm-rendering:
needs: check-cmp-state
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && needs.check-cmp-state.outputs.suspend_comment_id == 0 && needs.check-cmp-state.outputs.suspend_diffs_printing_from_pr_body == 'false'
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: install helm
uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0
with:
version: ${{ env.helm_ver }}
- run: which helm
- name: install dyff
uses: giantswarm/install-binary-action@c37eb401e5092993fc76d545030b1d1769e61237 # v3.0.0
with:
binary: dyff
download_url: "https://github.com/homeport/dyff/releases/download/v${version}/dyff_${version}_linux_amd64.tar.gz"
smoke_test: "${binary} version"
tarball_binary_path: "${binary}"
version: ${{ env.dyff_ver }}
- run: which dyff
- run: ls -la /opt/hostedtoolcache
- name: render helm with current code
run: |
helm repo add cluster-catalog https://giantswarm.github.io/cluster-catalog/
# We also add cluster-test-catalog so we can more easily test dev builds of subcharts.
# Charts from cluster-test-catalog should be used only for testing purposes.
helm repo add cluster-test-catalog https://giantswarm.github.io/cluster-test-catalog/
helm dependency build helm/${{ github.event.repository.name }}
for test_file_path in helm/${{ github.event.repository.name }}/ci/test-*-values.yaml; do
echo
echo "Rendering Helm template for ${test_file_path} on current code"
mkdir -p "/tmp/${test_file_path}"
helm template -n org-giantswarm -f "helm/${{ github.event.repository.name }}/ci/ci-values.yaml" -f "${test_file_path}" "helm/${{ github.event.repository.name }}" > "/tmp/${test_file_path}/render-new.yaml"
done
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
ref: "${{ github.event.repository.default_branch }}"
path: 'old'
- name: render helm with main branch code
run: |
helm dependency build old/helm/${{ github.event.repository.name }}
for test_file_path in helm/${{ github.event.repository.name }}/ci/test-*-values.yaml; do
echo
echo "Rendering Helm template for ${test_file_path} on old code"
if [ ! -d "/tmp/${test_file_path}" ]; then
echo "File ${test_file_path} does not yet exist in old code, skipping"
continue
fi
helm template -n org-giantswarm -f "old/helm/${{ github.event.repository.name }}/ci/ci-values.yaml" -f "${test_file_path}" "old/helm/${{ github.event.repository.name }}" > "/tmp/${test_file_path}/render-old.yaml"
done
- name: get the diffs
uses: mathiasvr/command-output@34408ea3d0528273faff3d9e201761ae96106cd0 # v2.0.0
with:
run: |
marker="=== No differences at all ==="
(
found_differences=
first=1
for test_file_path in helm/${{ github.event.repository.name }}/ci/test-*-values.yaml; do
if [ "${first}" = 1 ]; then
first=
else
echo
echo
fi
echo "=== Differences when rendered with values file ${test_file_path} ==="
dyff between --set-exit-code --ignore-order-changes --omit-header --use-go-patch-style "/tmp/${test_file_path}/render-old.yaml" "/tmp/${test_file_path}/render-new.yaml" && echo "No difference" || { res=$?; found_differences=1; if [[ $res -eq 255 ]]; then echo "Diff error"; fi; }
done
if [ -z "${found_differences}" ]; then
echo
echo
echo "${marker}"
fi
) > /tmp/diffs
(
if ! grep -qF "${marker}" /tmp/diffs ; then
echo "**There were differences in the rendered Helm template, please check! ⚠️**"
else
echo "There were no differences in the rendered Helm template."
fi
echo
echo "<details>"
echo "<summary>Output</summary>"
echo "<!-- mandatory empty line -->"
echo ""
echo '```'
cat /tmp/diffs
echo '```'
echo "</details>"
echo "<!-- mandatory empty line -->"
) > /tmp/comment-body
- name: Find diff comment
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0
continue-on-error: true
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'differences in the rendered Helm template'
- name: Delete old comment
uses: winterjung/comment@fda92dbcb5e7e79cccd55ecb107a8a3d7802a469 # v1.1.0
continue-on-error: true
if: steps.fc.outputs.comment-id != 0
with:
type: delete
comment_id: ${{ steps.fc.outputs.comment-id }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Create comment
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
with:
issue-number: ${{ github.event.pull_request.number }}
body-path: /tmp/comment-body