-
Notifications
You must be signed in to change notification settings - Fork 876
Resolve the latest release image to a published version #7786
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
Open
CharlieTLe
wants to merge
2
commits into
cortexproject:master
Choose a base branch
from
CharlieTLe:release-1.22-pr-a-fix-latest-release-image
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+257
−5
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| //go:build integration | ||
|
|
||
| package integration | ||
|
|
||
| import ( | ||
| "os" | ||
| "path/filepath" | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestLatestReleaseVersion(t *testing.T) { | ||
| tests := map[string]struct { | ||
| version string | ||
| expected string | ||
| expectedErr bool | ||
| }{ | ||
| "a GA version is already published": { | ||
| version: "1.21.1", | ||
| expected: "1.21.1", | ||
| }, | ||
| "a GA version with a zero patch is already published": { | ||
| version: "1.21.0", | ||
| expected: "1.21.0", | ||
| }, | ||
| "a minor release candidate falls back to the previous minor": { | ||
| version: "1.22.0-rc.0", | ||
| expected: "1.21.0", | ||
| }, | ||
| "a later minor release candidate falls back to the same previous minor": { | ||
| version: "1.22.0-rc.3", | ||
| expected: "1.21.0", | ||
| }, | ||
| "a patch release candidate falls back to the preceding patch": { | ||
| version: "1.22.1-rc.0", | ||
| expected: "1.22.0", | ||
| }, | ||
| "a later patch release candidate falls back to the preceding patch": { | ||
| version: "1.22.3-rc.1", | ||
| expected: "1.22.2", | ||
| }, | ||
| "a major release candidate cannot be resolved": { | ||
| version: "2.0.0-rc.0", | ||
| expectedErr: true, | ||
| }, | ||
| "an empty VERSION is rejected": { | ||
| version: "", | ||
| expectedErr: true, | ||
| }, | ||
| "a malformed pre-release base is rejected": { | ||
| version: "1.22-rc.0", | ||
| expectedErr: true, | ||
| }, | ||
| "a non-numeric pre-release base is rejected": { | ||
| version: "1.x.0-rc.0", | ||
| expectedErr: true, | ||
| }, | ||
| } | ||
|
|
||
| for name, testData := range tests { | ||
| t.Run(name, func(t *testing.T) { | ||
| actual, err := latestReleaseVersion(testData.version) | ||
| if testData.expectedErr { | ||
| require.Error(t, err) | ||
| return | ||
| } | ||
|
|
||
| require.NoError(t, err) | ||
| assert.Equal(t, testData.expected, actual) | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| func TestGetLatestReleaseImage(t *testing.T) { | ||
| // Point getCortexProjectDir() at a scratch checkout so we can exercise the VERSION file | ||
| // contents a release branch would actually have. | ||
| dir := t.TempDir() | ||
| t.Setenv("CORTEX_CHECKOUT_DIR", dir) | ||
| require.NoError(t, os.WriteFile(filepath.Join(dir, "VERSION"), []byte("1.22.0-rc.0\n"), 0o600)) | ||
|
|
||
| image, err := getLatestReleaseImage() | ||
| require.NoError(t, err) | ||
| assert.Equal(t, "quay.io/cortexproject/cortex:v1.21.0", image) | ||
| } | ||
|
|
||
| func TestGetLatestReleaseImage_HonorsOverride(t *testing.T) { | ||
| t.Setenv("CORTEX_LATEST_RELEASE_IMAGE", "quay.io/cortexproject/cortex:v1.20.1") | ||
|
|
||
| image, err := getLatestReleaseImage() | ||
| require.NoError(t, err) | ||
| assert.Equal(t, "quay.io/cortexproject/cortex:v1.20.1", image) | ||
| } | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
The
discover-tagsjob excludes integration soutil.testcannot be tested. We need to use something like anintegration_query_fuzz.