Skip to content

Commit e43bb89

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

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

.github/workflows/ci.yml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,18 @@ jobs:
2121
cache: false
2222

2323
- name: Fmt
24-
run: go fmt ./...
25-
24+
run: |
25+
# Run gofmt in "diff" mode to check for unformatted code
26+
UNFORMATTED_FILES=$(gofmt -l .)
27+
# Check if any files are unformatted
28+
if [[ -n "$UNFORMATTED_FILES" ]]; then
29+
echo "::error::The following Go files are not formatted correctly:"
30+
echo "$UNFORMATTED_FILES" # List unformatted files in the log
31+
echo "::error::Please format your Go code by running \`go fmt ./...\` and commit the changes."
32+
exit 1 # Fail the check
33+
else
34+
echo "All Go files are properly formatted."
35+
fi
2636
- name: Vet
2737
run: go vet ./...
2838

@@ -33,6 +43,24 @@ jobs:
3343
uses: golangci/golangci-lint-action@v3
3444
with:
3545
version: v1.54
46+
# Generate example charts
47+
- name: Generate example charts
48+
run: |
49+
cat test_data/sample-app.yaml | go run ./cmd/helmify examples/app
50+
cat test_data/k8s-operator-kustomize.output | go run ./cmd/helmify examples/operator
51+
- name: Check that chart examples were commited
52+
run: |
53+
if [[ -n "$(git status --porcelain)" ]]; then
54+
# Capture the list of uncommitted files
55+
UNCOMMITTED_FILES=$(git status --porcelain)
56+
echo "::error::Chart examples generation step has uncommitted changes: $UNCOMMITTED_FILES
57+
Please run following commands and commit the results:
58+
- \`cat test_data/sample-app.yaml | go run ./cmd/helmify examples/app\`
59+
- \`cat test_data/k8s-operator-kustomize.output | go run ./cmd/helmify examples/operator\`"
60+
exit 1
61+
else
62+
echo "Chart examples generation check passed. No uncommitted changes."
63+
fi
3664
# Dry-run generated charts in cluster
3765
- name: Install k8s cluster
3866
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)