-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Fix ephemeral runner deletion #34447
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
techknowlogick
merged 13 commits into
go-gitea:main
from
ChristopherHX:fix-ephemeral-runner-deletion
May 20, 2025
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b3b8eb5
Fix ephemeral runner deletion
ChristopherHX 3adc64b
fix fmt
ChristopherHX 4dcdf9f
fix typo
ChristopherHX d593f36
remove length checks of some runner tests
ChristopherHX eae6ad2
Merge branch 'main' of https://github.com/go-gitea/gitea into fix-eph…
ChristopherHX 8e8c127
revert local storage just to be sure
ChristopherHX dc08cc2
Merge branch 'main' of https://github.com/go-gitea/gitea into pr/Chri…
ChristopherHX 46e8086
Revert "revert local storage just to be sure"
ChristopherHX ee1058b
fix comment and method name
ChristopherHX d344fed
Revert "Revert "revert local storage just to be sure""
ChristopherHX d2af3ea
...
ChristopherHX 6da57f5
rename test
ChristopherHX 577a6dd
Merge branch 'main' into fix-ephemeral-runner-deletion
GiteaBot 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
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
79 changes: 79 additions & 0 deletions
79
tests/integration/ephemeral_actions_runner_deletion_test.go
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,79 @@ | ||
// Copyright 2025 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package integration | ||
|
||
import ( | ||
"testing" | ||
|
||
actions_model "code.gitea.io/gitea/models/actions" | ||
"code.gitea.io/gitea/models/unittest" | ||
user_model "code.gitea.io/gitea/models/user" | ||
"code.gitea.io/gitea/modules/util" | ||
repo_service "code.gitea.io/gitea/services/repository" | ||
user_service "code.gitea.io/gitea/services/user" | ||
"code.gitea.io/gitea/tests" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestEphemeralActionsRunnerDeletion(t *testing.T) { | ||
t.Run("ByTaskCompletion", testEphemeralActionsRunnerDeletionByTaskCompletion) | ||
t.Run("ByRepository", testEphemeralActionsRunnerDeletionByRepository) | ||
t.Run("ByUser", testEphemeralActionsRunnerDeletionByUser) | ||
} | ||
|
||
// Test that the ephemeral runner is deleted when the task is finished | ||
func testEphemeralActionsRunnerDeletionByTaskCompletion(t *testing.T) { | ||
defer tests.PrepareTestEnv(t)() | ||
|
||
_, err := actions_model.GetRunnerByID(t.Context(), 34350) | ||
assert.NoError(t, err) | ||
|
||
task := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionTask{ID: 52}) | ||
assert.Equal(t, actions_model.StatusRunning, task.Status) | ||
|
||
task.Status = actions_model.StatusSuccess | ||
err = actions_model.UpdateTask(t.Context(), task, "status") | ||
assert.NoError(t, err) | ||
|
||
_, err = actions_model.GetRunnerByID(t.Context(), 34350) | ||
assert.ErrorIs(t, err, util.ErrNotExist) | ||
} | ||
|
||
func testEphemeralActionsRunnerDeletionByRepository(t *testing.T) { | ||
defer tests.PrepareTestEnv(t)() | ||
|
||
_, err := actions_model.GetRunnerByID(t.Context(), 34350) | ||
assert.NoError(t, err) | ||
|
||
task := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionTask{ID: 52}) | ||
assert.Equal(t, actions_model.StatusRunning, task.Status) | ||
|
||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}) | ||
|
||
err = repo_service.DeleteRepositoryDirectly(t.Context(), user, task.RepoID, true) | ||
assert.NoError(t, err) | ||
|
||
_, err = actions_model.GetRunnerByID(t.Context(), 34350) | ||
assert.ErrorIs(t, err, util.ErrNotExist) | ||
} | ||
|
||
// Test that the ephemeral runner is deleted when a user is deleted | ||
func testEphemeralActionsRunnerDeletionByUser(t *testing.T) { | ||
defer tests.PrepareTestEnv(t)() | ||
|
||
_, err := actions_model.GetRunnerByID(t.Context(), 34350) | ||
assert.NoError(t, err) | ||
|
||
task := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionTask{ID: 52}) | ||
assert.Equal(t, actions_model.StatusRunning, task.Status) | ||
|
||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}) | ||
|
||
err = user_service.DeleteUser(t.Context(), user, true) | ||
assert.NoError(t, err) | ||
|
||
_, err = actions_model.GetRunnerByID(t.Context(), 34350) | ||
assert.ErrorIs(t, err, util.ErrNotExist) | ||
} |
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.