Skip to content

chore: integration: add test for pushing to cache repo that requires auth #233

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

Merged
merged 2 commits into from
Jun 12, 2024

Conversation

johnstcn
Copy link
Member

@johnstcn johnstcn commented Jun 12, 2024

Addresses a gap in our testing for the case when the cache repo requires auth.
NOTE: this shows that being unable to push the image will fail the build outright.
Do we maybe want to relax this?

@johnstcn johnstcn self-assigned this Jun 12, 2024
@@ -1101,6 +1107,130 @@ func TestPushImage(t *testing.T) {
require.NoError(t, err)
})

t.Run("CacheAndPushAuth", func(t *testing.T) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review: I may look into making this more of a table-driven test, as it's getting pretty unwieldy

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was gonna suggest the same.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a try and there's a bit too much difference behaviour between the various test cases to really make it worthwhile IMO compared with the cognitive overhead of DRYing this.

@@ -249,18 +249,3 @@ func WriteFile(t *testing.T, fs billy.Filesystem, path, content string) {
err = file.Close()
require.NoError(t, err)
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

review: moved as this isn't specific to testing git stuff

@johnstcn johnstcn requested review from dannykopping and mtojek June 12, 2024 11:32
Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

NOTE: this shows that being unable to push the image will fail the build outright.
Do we maybe want to relax this?

The pushed image is just an optimization to speed up the subsequent runs, correct?
It feels like Principle of Least Surprise here would be to complete the primary objective (which is building), and any ancillary steps to optimize should not fail that.

@@ -1101,6 +1107,130 @@ func TestPushImage(t *testing.T) {
require.NoError(t, err)
})

t.Run("CacheAndPushAuth", func(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was gonna suggest the same.

envbuilderEnv("GET_CACHED_IMAGE", "1"),
envbuilderEnv("DOCKER_CONFIG_BASE64", base64.StdEncoding.EncodeToString(regAuthJSON)),
}})
require.NoError(t, err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any more specificity we could add here? The absence of an error is fine, but validating the cached image exists explicitly would be better.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see L1168/1169

@johnstcn
Copy link
Member Author

The pushed image is just an optimization to speed up the subsequent runs, correct? It feels like Principle of Least Surprise here would be to complete the primary objective (which is building), and any ancillary steps to optimize should not fail that.

As a counterpoint, I can foresee this being used in a CI scenario along with something like ENVBUILDER_INIT_SCRIPT=exit 0 in order to 'pre-warm' the cache repo. I'm not sure which behaviour is most desirable here.

Copy link
Member

@mtojek mtojek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea 👍

@johnstcn johnstcn merged commit fbfbf56 into main Jun 12, 2024
4 checks passed
@johnstcn johnstcn deleted the cj/test-build-push-cache-auth branch June 12, 2024 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants