Skip to content

Commit 70182fe

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

File tree

3 files changed

+54
-3
lines changed

3 files changed

+54
-3
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]

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,26 @@ go test ./...
162162
Beside unit-tests, project contains e2e test `pkg/app/app_e2e_test.go`.
163163
It's a go test, which uses `test_data/*` to generate a chart in temporary directory.
164164
Then runs `helm lint --strict` to check if generated chart is valid.
165+
166+
## Contribute
167+
168+
Following rules will help changes to be accepted faster:
169+
- For more than one-line bugfixes consider creating an issue with bug description or feature request
170+
- For feature request try to think about and cover following topics (when applicable):
171+
- Motivation: why feature is needed? Which problem does it solve? What is current workaround?
172+
- Backward-compatibility: existing users expect that after upgrading helmify version their existing generated charts wont be changed without consent.
173+
- For bugfix PR consider adding example to [/test_data](./test_data/) source yamls reproducing bug.
174+
175+
### Contribution flow
176+
177+
Check list before submitting PR:
178+
1. Run `go fmt ./...`
179+
2. Run tests `go test ./...`
180+
3. Update chart examples:
181+
```shell
182+
cat test_data/sample-app.yaml | go run ./cmd/helmify examples/app
183+
```
184+
```shell
185+
cat test_data/k8s-operator-kustomize.output | go run ./cmd/helmify examples/operator
186+
```
187+
4. In case of long commit history (more than 3) squash local commits into one

pkg/processor/meta.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func ProcessObjMeta(appMeta helmify.AppMetadata, obj *unstructured.Unstructured,
8282
}
8383
}
8484

85-
if (obj.GetNamespace() != "") && (appMeta.Config().PreserveNs){
85+
if (obj.GetNamespace() != "") && (appMeta.Config().PreserveNs) {
8686
namespace, err = yamlformat.Marshal(map[string]interface{}{"namespace": obj.GetNamespace()}, 2)
8787
if err != nil {
8888
return "", err

0 commit comments

Comments
 (0)