-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Send email on Workflow Run Success/Failure #34982
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
NorthRealm
wants to merge
34
commits into
go-gitea:main
Choose a base branch
from
NorthRealm:patch4
base: main
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.
+418
−36
Open
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
c8b64c7
Refactor
NorthRealm 027c9fe
MAILER
NorthRealm 0081ef8
Merge branch 'main' into patch3
NorthRealm 31d82a4
Merge branch 'main' into patch4
NorthRealm a630935
MAILER
NorthRealm 1f6c68d
MAILER
NorthRealm bf468fe
MAILER
NorthRealm bf3559f
MAILER
NorthRealm bb5e10b
fmt
NorthRealm ed7b2bc
Refactor
NorthRealm 0126656
Merge branch 'patch3' into patch4
NorthRealm 4f3f1b9
Decoration
NorthRealm a0737b1
Decoration
NorthRealm 53970ec
Refactor
NorthRealm 8100f63
silly
NorthRealm 204f7ca
stop if cannot render template
NorthRealm d41aee8
34982#discussion_r2191579495
NorthRealm 2bac8d8
terrible
NorthRealm afe2dee
Merge branch 'patch3' into patch4
NorthRealm cc6c8d1
Any other recipient?
NorthRealm 6a28be3
style
NorthRealm 9da6b36
Merge branch 'main' into workflow-email
wxiaoguang 2fa624a
fix merge
wxiaoguang 0a92da5
sort
NorthRealm 65b1f08
Merge remote-tracking branch 'upstream/main' into patch4
NorthRealm 7a635dd
Merge remote-tracking branch 'upstream/main' into patch4
NorthRealm 540c3f0
DATABASE
NorthRealm 4f31cd8
UI
NorthRealm 32ad9ba
update
NorthRealm 07602a0
fix
NorthRealm d92ec01
locale
NorthRealm fed3ade
rewrite
NorthRealm 985e641
update
NorthRealm 628ace2
UPDATE
NorthRealm 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright 2025 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package user | ||
|
||
// setting values | ||
const ( | ||
EmailNotificationGiteaActionsAll = "all" | ||
EmailNotificationGiteaActionsFailureOnly = "failureonly" // Default for actions email preference | ||
EmailNotificationGiteaActionsDisabled = "disabled" | ||
) |
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,34 @@ | ||
// Copyright 2025 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package user | ||
|
||
import ( | ||
"testing" | ||
|
||
"code.gitea.io/gitea/models/db" | ||
"code.gitea.io/gitea/models/unittest" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestNotificationSettings(t *testing.T) { | ||
assert.NoError(t, unittest.PrepareTestDatabase()) | ||
|
||
u := unittest.AssertExistsAndLoadBean(t, &User{ID: 1}) | ||
|
||
assert.NoError(t, SetUserSetting(db.DefaultContext, u.ID, SettingsEmailNotificationGiteaActions, EmailNotificationGiteaActionsAll)) | ||
settings, err := GetSetting(db.DefaultContext, u.ID, SettingsEmailNotificationGiteaActions) | ||
assert.NoError(t, err) | ||
assert.Equal(t, EmailNotificationGiteaActionsAll, settings) | ||
|
||
assert.NoError(t, SetUserSetting(db.DefaultContext, u.ID, SettingsEmailNotificationGiteaActions, EmailNotificationGiteaActionsDisabled)) | ||
settings, err = GetSetting(db.DefaultContext, u.ID, SettingsEmailNotificationGiteaActions) | ||
assert.NoError(t, err) | ||
assert.Equal(t, EmailNotificationGiteaActionsDisabled, settings) | ||
|
||
assert.NoError(t, SetUserSetting(db.DefaultContext, u.ID, SettingsEmailNotificationGiteaActions, EmailNotificationGiteaActionsFailureOnly)) | ||
settings, err = GetSetting(db.DefaultContext, u.ID, SettingsEmailNotificationGiteaActions) | ||
assert.NoError(t, err) | ||
assert.Equal(t, EmailNotificationGiteaActionsFailureOnly, settings) | ||
} |
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
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 |
---|---|---|
|
@@ -16,6 +16,7 @@ import ( | |
"testing" | ||
texttmpl "text/template" | ||
|
||
actions_model "code.gitea.io/gitea/models/actions" | ||
activities_model "code.gitea.io/gitea/models/activities" | ||
"code.gitea.io/gitea/models/db" | ||
issues_model "code.gitea.io/gitea/models/issues" | ||
|
@@ -298,13 +299,13 @@ func testComposeIssueCommentMessage(t *testing.T, ctx *mailComment, recipients [ | |
return msgs[0] | ||
} | ||
|
||
func TestGenerateAdditionalHeaders(t *testing.T) { | ||
func TestGenerateAdditionalHeadersForIssue(t *testing.T) { | ||
doer, _, issue, _ := prepareMailerTest(t) | ||
|
||
comment := &mailComment{Issue: issue, Doer: doer} | ||
recipient := &user_model.User{Name: "test", Email: "[email protected]"} | ||
|
||
headers := generateAdditionalHeaders(comment, "dummy-reason", recipient) | ||
headers := generateAdditionalHeadersForIssue(comment, "dummy-reason", recipient) | ||
|
||
expected := map[string]string{ | ||
"List-ID": "user2/repo1 <repo1.user2.localhost>", | ||
|
@@ -441,6 +442,16 @@ func TestGenerateMessageIDForRelease(t *testing.T) { | |
assert.Equal(t, "<owner/repo/releases/1@localhost>", msgID) | ||
} | ||
|
||
func TestGenerateMessageIDForActionsWorkflowRunStatusEmail(t *testing.T) { | ||
assert.NoError(t, unittest.PrepareTestDatabase()) | ||
|
||
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 2}) | ||
run := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionRun{ID: 795, RepoID: repo.ID}) | ||
assert.NoError(t, run.LoadAttributes(db.DefaultContext)) | ||
msgID := generateMessageIDForActionsWorkflowRunStatusEmail(repo, run) | ||
assert.Equal(t, "<user2/repo2/actions/runs/191@localhost>", msgID) | ||
} | ||
|
||
func TestFromDisplayName(t *testing.T) { | ||
tmpl, err := texttmpl.New("mailFrom").Parse("{{ .DisplayName }}") | ||
assert.NoError(t, err) | ||
|
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.