|
21 | 21 | cache: false |
22 | 22 |
|
23 | 23 | - 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 |
26 | 36 | - name: Vet |
27 | 37 | run: go vet ./... |
28 | 38 |
|
|
33 | 43 | uses: golangci/golangci-lint-action@v3 |
34 | 44 | with: |
35 | 45 | 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 |
36 | 64 | # Dry-run generated charts in cluster |
37 | 65 | - name: Install k8s cluster |
38 | 66 | |
|
0 commit comments