-
Notifications
You must be signed in to change notification settings - Fork 150
feat(release): Enhance build and publish workflows #4473
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
+454
−56
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f5426c9
feat(release): implement extensible hook system with timeout
radTuti e470142
feat(release): add cloning repo for generating CRDs
radTuti fc9ed2d
fix(release): update creating github release flag & validation
radTuti ac32634
fix: typos
radTuti 91fb235
updates based on review
radTuti 2c3d26a
Merge remote-tracking branch 'upstream/master' into reltool-hooks
radTuti 071db3c
fix: address review comment
radTuti b6d96aa
Merge remote-tracking branch 'upstream/master' into reltool-hooks
radTuti 0de8b8d
refactor(release): replace hook system and add allowance for command …
radTuti 6935714
Merge remote-tracking branch 'upstream/master' into reltool-hooks
radTuti 1244c2b
fix(release): cleanups
radTuti 3c8391e
Merge remote-tracking branch 'upstream/master' into reltool-hooks
radTuti 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,157 @@ | ||
| // Copyright (c) 2026 Tigera, Inc. All rights reserved. | ||
|
|
||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package main | ||
|
|
||
| import ( | ||
| "context" | ||
| "errors" | ||
| "slices" | ||
| "strings" | ||
| "testing" | ||
| ) | ||
|
|
||
| func TestExtractGitHashFromVersion(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| cases := []struct { | ||
| version string | ||
| want string | ||
| wantErr bool | ||
| }{ | ||
| { | ||
| version: "v3.22.1", | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| version: "v3.22.0-1.0", | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| version: "v3.22.0-gshorthash", | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| version: "v3.22.0-glonghashthatisnotvalid", | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| version: "v3.22.1-25-g997f6be93484-extra", | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| version: "v3.22.1-25-g997f6be93484-dirty", | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| version: "v3.22.1-948-g997f6be93484", | ||
| want: "997f6be93484", | ||
| }, | ||
| { | ||
| version: "v3.22.1-calient-0.dev-948-g1234567890ab", | ||
| want: "1234567890ab", | ||
| }, | ||
| { | ||
| version: "v3.23.0-2.0-calient-0.dev-948-gabcdef123456", | ||
| want: "abcdef123456", | ||
| }, | ||
| } | ||
|
|
||
| for _, tc := range cases { | ||
| t.Run(tc.version, func(t *testing.T) { | ||
| t.Parallel() | ||
| got, err := extractGitHashFromVersion(tc.version) | ||
| if tc.wantErr { | ||
| if err == nil { | ||
| t.Fatalf("expected error, got none") | ||
| } | ||
| return | ||
| } | ||
| if err != nil { | ||
| t.Fatalf("unexpected error: %v", err) | ||
| } | ||
| if got != tc.want { | ||
| t.Fatalf("extractGitHashFromVersion(%q) = %q, want %q", tc.version, got, tc.want) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| // Tests below must NOT be parallel since they mutate package-level vars. | ||
|
|
||
| func TestRunBuildCleanup(t *testing.T) { | ||
| t.Run("LIFO order and error collection", func(t *testing.T) { | ||
| buildCleanupFns = nil | ||
| defer func() { buildCleanupFns = nil }() | ||
|
|
||
| var order []int | ||
| buildCleanupFns = append(buildCleanupFns, func(ctx context.Context) error { | ||
| order = append(order, 1) | ||
| return errors.New("cleanup-1 failed") | ||
| }) | ||
| buildCleanupFns = append(buildCleanupFns, func(ctx context.Context) error { | ||
| order = append(order, 2) | ||
| return nil | ||
| }) | ||
| buildCleanupFns = append(buildCleanupFns, func(ctx context.Context) error { | ||
| order = append(order, 3) | ||
| return errors.New("cleanup-3 failed") | ||
| }) | ||
|
|
||
| err := runBuildCleanup(context.Background()) | ||
| if err == nil { | ||
| t.Fatal("expected error, got nil") | ||
| } | ||
| if !strings.Contains(err.Error(), "cleanup-1 failed") { | ||
| t.Fatalf("missing cleanup-1 error: %v", err) | ||
| } | ||
| if !strings.Contains(err.Error(), "cleanup-3 failed") { | ||
| t.Fatalf("missing cleanup-3 error: %v", err) | ||
| } | ||
| if !slices.Equal(order, []int{3, 2, 1}) { | ||
| t.Fatalf("expected LIFO order [3, 2, 1], got %v", order) | ||
| } | ||
| if buildCleanupFns != nil { | ||
| t.Fatal("expected buildCleanupFns to be nil after cleanup") | ||
| } | ||
| }) | ||
|
|
||
| t.Run("empty slice is no-op", func(t *testing.T) { | ||
| buildCleanupFns = nil | ||
| if err := runBuildCleanup(context.Background()); err != nil { | ||
| t.Fatalf("unexpected error: %v", err) | ||
| } | ||
| }) | ||
|
|
||
| t.Run("propagates context cancellation", func(t *testing.T) { | ||
| buildCleanupFns = nil | ||
| defer func() { buildCleanupFns = nil }() | ||
|
|
||
| buildCleanupFns = append(buildCleanupFns, func(ctx context.Context) error { | ||
| select { | ||
| case <-ctx.Done(): | ||
| return ctx.Err() | ||
| default: | ||
| return nil | ||
| } | ||
| }) | ||
|
|
||
| ctx, cancel := context.WithCancel(context.Background()) | ||
| cancel() | ||
| err := runBuildCleanup(ctx) | ||
| if !errors.Is(err, context.Canceled) { | ||
| t.Fatalf("expected context.Canceled, got: %v", err) | ||
| } | ||
| }) | ||
| } |
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
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
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.