-
Notifications
You must be signed in to change notification settings - Fork 2
Unit test overhaul and handling additional PackagePush and Lint function use cases #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Unit test overhaul and handling additional PackagePush and Lint function use cases #70
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the tests!
I have some errors running dagger -m tests/ call all
./main.go:140:145: unknown field Version in struct literal of type dagger.HelmPackagePushOpts
./main.go:169:145: unknown field AppVersion in struct literal of type dagger.HelmPackagePushOpts
You are not having problems?
Sometime I have testing issues because of caching.
@chrira : My apologies for those issues. I am having problems running unit tests in my local environment....in our company we have to use a custom runner for Dagger due to needing to setup certificates for our company proxy. RIght now we use Dagger v0.14.0 with our customized base image while your unit tests use v0.16. Do you have any general Dagger advice for handling different environments like this? I know you are working on setting up CI here....would it be possible to get a minimal CI setup going....just enough to at least run the unit tests upon any change? While it is not ideal to go back to 'push and pray,' I may have to. :( |
@frizzr no worries! Yes, the tests are executed in GitHub. Here is one example on your fork: https://github.com/frizzr/dagger-module-helm/actions/runs/13639799085/job/38126851023 Hope this helps you getting forward. |
Hello @chrira! It has been awhile, but I finally finished a complete rework of the unit tests along with my feature adds. I'm happy to say that it is all safe to execute the tests in parallel and I came up with a way to guarantee each test is completely independent of each other by having a set of This struct, when instantiated as part of With a different set of chart names per test, it guarantees that we can safely perform tests using This was a LOT of work I know, and I hope it isn't too crazy or too drastic of a change. Still, I think it could solve some things now and into the future, but I'll let you be the judge of that. If the whole thing is "too much", then I could fall back and move my feature adds across to the other PR and leave the unit tests alone. Thanks for considering! |
@frizzr what a work, thank you! Unfortunately it breaks our main return logic of the PackagePush method. See comment: As @RetGal mentioned, the test method for this logic on the main branch (helm-package-push-with-existing-chart) fails with your changes. Changing |
These are hopefully the last set of changes! I added a good bit more logic, including a use case I had to handle immediately for both Although it sounds limiting to assume that the same set of credentials can login to multiple different registries, this limitation is acceptable to me given we use the same JFrog Artifactory instance for all of our Helm repositories, but we still need to login to each repository in our dependencies. I would think my situation would be fairly common, so I felt the limitation is acceptable in general. I also changed the I did have to make a (breaking?) change to the The big question I have is....how did my non-OCI unit test ever work? Wouldn't we need to simulate a non-OCI repository to do the test (given that |
@frizzr you're right, the non-OCI test probably never worked. @chrira we should probably always call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@frizzr are you still working on it?
Note when you are finished. Then we will do the final review and merge it.
Thanks for contributing!
@@ -12,18 +12,23 @@ import ( | |||
"fmt" | |||
"os" | |||
"strings" | |||
"hash/crc32" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix formatting
Registry string `yaml:"registry"` | ||
Repository string `yaml:"repository"` | ||
Oci bool `yaml:"oci"` | ||
NonOCISubpath string `yaml:"nonOciSubpath"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix alignment (check tabs/spaces)
Registry: registry, | ||
Repository: repository, | ||
Oci: !useNonOciHelmRepo, | ||
NonOCISubpath: nonOciRepoSubpath, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix alignment (check tabs/spaces)
WithWorkdir("/helm") | ||
version, err := c.WithExec([]string{"sh", "-c", "helm show chart . | yq eval '.version' -"}).Stdout(ctx) | ||
c := h.createContainer(directory) | ||
//c := dag.Container(). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove commented code
@@ -197,7 +293,8 @@ func (h *Helm) Test( | |||
args []string, | |||
) (string, error) { | |||
c := h.createContainer(directory) | |||
out, err := c.WithExec([]string{"sh", "-c", fmt.Sprintf("%s %s", "helm-unittest", strings.Join(args, " "))}).Stdout(ctx) | |||
out, err := c.WithExec([]string{"sh", "-c", | |||
fmt.Sprintf("%s %s", "helm-unittest", strings.Join(args, " "))}).Stdout(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check formatting
WithExec([]string{"sh", "-c", `echo ${REGISTRY_PASSWORD} | helm registry login ${REGISTRY_URL} --username ${REGISTRY_USERNAME} --password-stdin`}). | ||
WithoutSecretVariable("REGISTRY_PASSWORD"). | ||
Sync(ctx) | ||
// We assume we are already logged into an OCI registry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is here no login needed?
@RetGal do we have Integration tests for the case that the version exists on the registry?
} | ||
|
||
func (h *Helm) hasMissingDependencies( | ||
func (h *Helm) queryChartWithYq( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
Sorry for the delays. I am getting laid off from my job effective late next
month, but I do want to keep working on this even after my job ends.
The main problem that I am having right now is very specific to our CI
environment. The code as-is works perfectly except in our
'docker-in-docker' environment...we run Actions Runner Controller in a K8s
cluster and I am having a bizarre issue with `helm repo add` not keeping
state...the very next `WithExec` command I run completely loses the dot
config directory for Helm...but in all other environments it seems to work
great.
I'll post more info later.
Thanks!
…On Mon, May 12, 2025, 10:38 Christoph Raaflaub ***@***.***> wrote:
*chrira* left a comment (puzzle/dagger-module-helm#70)
<#70 (comment)>
@frizzr <https://github.com/frizzr>
Please run gofmt -w helm/main.go on your go files. We formatted the code
on main.
Then you should be able to rebase your branch with main.
We are still struggling with testing, see #84
<#84>
Thanks
—
Reply to this email directly, view it on GitHub
<#70 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGKTEYEQWTHZW7WPKB5ROD26CW7LAVCNFSM6AAAAABYEJGGYSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQNZSHA2DENZUGQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I added the Chart struct to help with, for example, modifying your test Helm chart(s) dynamically. This was necessary since by supplying the optional
PackagePush
setVersionTo
andsetAppVersionTo
parameters, it would change the test charts' content and it was just easier to dynamically make those modifications.