Skip to content

Commit 7b3986b

Browse files
committed
ci: generated chart examples check
1 parent 56a8017 commit 7b3986b

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

.github/workflows/ci.yml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,19 @@ jobs:
2121
cache: false
2222

2323
- name: Fmt
24-
run: go fmt ./...
24+
# run: go fmt ./...
25+
run: |
26+
# Run gofmt in "diff" mode to check for unformatted code
27+
UNFORMATTED_FILES=$(gofmt -l .)
28+
# Check if any files are unformatted
29+
if [[ -n "$UNFORMATTED_FILES" ]]; then
30+
echo "::error::The following Go files are not formatted correctly:"
31+
echo "$UNFORMATTED_FILES" # List unformatted files in the log
32+
echo "::error::Please format your Go code by running \`go fmt ./...\` and commit the changes."
33+
exit 1 # Fail the check
34+
else
35+
echo "All Go files are properly formatted."
36+
fi
2537
2638
- name: Vet
2739
run: go vet ./...
@@ -33,6 +45,24 @@ jobs:
3345
uses: golangci/golangci-lint-action@v3
3446
with:
3547
version: v1.54
48+
# Generate example charts
49+
- name: Generate example charts
50+
run: |
51+
cat test_data/sample-app.yaml | go run ./cmd/helmify examples/app
52+
cat test_data/k8s-operator-kustomize.output | go run ./cmd/helmify examples/operator
53+
- name: Check that chart examples were commited
54+
run: |
55+
if [[ -n "$(git status --porcelain)" ]]; then
56+
# Capture the list of uncommitted files
57+
UNCOMMITTED_FILES=$(git status --porcelain)
58+
echo "::error::Chart examples generation step has uncommitted changes: $UNCOMMITTED_FILES
59+
Please run following commands and commit the results:
60+
- \`cat test_data/sample-app.yaml | go run ./cmd/helmify examples/app\`
61+
- \`cat test_data/k8s-operator-kustomize.output | go run ./cmd/helmify examples/operator\`"
62+
exit 1
63+
else
64+
echo "Chart examples generation check passed. No uncommitted changes."
65+
fi
3666
# Dry-run generated charts in cluster
3767
- name: Install k8s cluster
3868
uses: helm/[email protected]

test_data/sample-app.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ spec:
2424
- name: app
2525
args:
2626
- --health-probe-bind-address=:8081
27-
- --metrics-bind-address=127.0.0.1:8080
28-
- --leader-elect
27+
# - --metrics-bind-address=127.0.0.1:8080
28+
# - --leader-elect
2929
command:
3030
- /manager
3131
volumeMounts:

0 commit comments

Comments
 (0)