feat: add test suite, CI pipeline, and helmspray refactor (84% coverage)#102
Open
mirai-toto wants to merge 6 commits into
Open
feat: add test suite, CI pipeline, and helmspray refactor (84% coverage)#102mirai-toto wants to merge 6 commits into
mirai-toto wants to merge 6 commits into
Conversation
0323237 to
7cacf84
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR: Add test suite, CI pipeline, and codebase refactor
Summary
helmspraypackage into focused helper functions to improve testability and readabilityChanges
~156 test functions across 8 packages
cmdNewRootCmdvalidation, all flag-conflict guards, URL/local/repo fetch pathsinternal/dependenciesinternal/logWithNumberedLinespaddinginternal/valuespick,indent,Merge,mergeMapspkg/helmList, 100%UpgradeWithValuesflag paths via fake helm binarypkg/helmspraySpray, 100% of all pure helperspkg/kubectlgenerateTemplate, early-return paths for allAre*Readyfunctionspkg/utilDurationbranchesFake helm binary test approach
Functions that exec the
helmbinary are tested by writing a shell script stub to a temp directory and prepending it toPATH. This enables full end-to-end coverage ofSpray()→upgrade()→UpgradeWithValues()without a Kubernetes cluster.Codebase refactor (
pkg/helmspray)The monolithic
upgrade()function was split into focused helpers:writeTempValuesFilecomputeReleasePrefixdeployByWeightupgradeDependencybuildDepValuesSetdep.enabled=true/falseflags stringcollectWorkloadslogUpgradedWorkloadscheckReadyvalidateNamesCI pipeline
GitHub Actions (
ci.yaml): runsgo vet+go test ./...on every push and PR. Updatedgithub-release.yamlto useactions/checkout@v4,actions/setup-go@v5, andgo-version-file: go.mod.GitLab CI (
.gitlab-ci.yml):build → test → scan → reportpipeline with SonarQube quality gate. Excludes*_test.gofrom the coverage denominator viasonar.coverage.exclusions.How to verify