mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-09-11 16:18:25 +02:00
Compare commits
4 commits
4935e6e1a3
...
72620db8df
Author | SHA1 | Date | |
---|---|---|---|
|
72620db8df | ||
|
b669564f39 | ||
|
aca7e8a9af | ||
|
b580c830e0 |
15 changed files with 191 additions and 7 deletions
|
@ -44,6 +44,11 @@ func defaultLoggingFlags() []cli.Flag {
|
||||||
Aliases: []string{"e"},
|
Aliases: []string{"e"},
|
||||||
Usage: "Matching expression for the logger",
|
Usage: "Matching expression for the logger",
|
||||||
},
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "exclusion",
|
||||||
|
Aliases: []string{"x"},
|
||||||
|
Usage: "Exclusion for the logger",
|
||||||
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "prefix",
|
Name: "prefix",
|
||||||
Aliases: []string{"p"},
|
Aliases: []string{"p"},
|
||||||
|
@ -286,6 +291,9 @@ func commonAddLogger(ctx context.Context, c *cli.Command, mode string, vals map[
|
||||||
if len(c.String("expression")) > 0 {
|
if len(c.String("expression")) > 0 {
|
||||||
vals["expression"] = c.String("expression")
|
vals["expression"] = c.String("expression")
|
||||||
}
|
}
|
||||||
|
if len(c.String("exclusion")) > 0 {
|
||||||
|
vals["exclusion"] = c.String("exclusion")
|
||||||
|
}
|
||||||
if len(c.String("prefix")) > 0 {
|
if len(c.String("prefix")) > 0 {
|
||||||
vals["prefix"] = c.String("prefix")
|
vals["prefix"] = c.String("prefix")
|
||||||
}
|
}
|
||||||
|
|
|
@ -631,6 +631,7 @@ LEVEL = Info
|
||||||
;LEVEL=
|
;LEVEL=
|
||||||
;FLAGS = stdflags or journald
|
;FLAGS = stdflags or journald
|
||||||
;EXPRESSION =
|
;EXPRESSION =
|
||||||
|
;EXCLUSION =
|
||||||
;PREFIX =
|
;PREFIX =
|
||||||
;COLORIZE = false
|
;COLORIZE = false
|
||||||
;;
|
;;
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -24,7 +24,7 @@ require (
|
||||||
github.com/ProtonMail/go-crypto v1.3.0
|
github.com/ProtonMail/go-crypto v1.3.0
|
||||||
github.com/PuerkitoBio/goquery v1.10.3
|
github.com/PuerkitoBio/goquery v1.10.3
|
||||||
github.com/SaveTheRbtz/zstd-seekable-format-go/pkg v0.7.2
|
github.com/SaveTheRbtz/zstd-seekable-format-go/pkg v0.7.2
|
||||||
github.com/alecthomas/chroma/v2 v2.18.0
|
github.com/alecthomas/chroma/v2 v2.19.0
|
||||||
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb
|
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb
|
||||||
github.com/blevesearch/bleve/v2 v2.5.2
|
github.com/blevesearch/bleve/v2 v2.5.2
|
||||||
github.com/buildkite/terminal-to-html/v3 v3.16.8
|
github.com/buildkite/terminal-to-html/v3 v3.16.8
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -62,8 +62,8 @@ github.com/SaveTheRbtz/zstd-seekable-format-go/pkg v0.7.2/go.mod h1:JitQWJ8JuV4Y
|
||||||
github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0=
|
github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0=
|
||||||
github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
|
github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
|
||||||
github.com/alecthomas/chroma/v2 v2.2.0/go.mod h1:vf4zrexSH54oEjJ7EdB65tGNHmH3pGZmVkgTP5RHvAs=
|
github.com/alecthomas/chroma/v2 v2.2.0/go.mod h1:vf4zrexSH54oEjJ7EdB65tGNHmH3pGZmVkgTP5RHvAs=
|
||||||
github.com/alecthomas/chroma/v2 v2.18.0 h1:6h53Q4hW83SuF+jcsp7CVhLsMozzvQvO8HBbKQW+gn4=
|
github.com/alecthomas/chroma/v2 v2.19.0 h1:Im+SLRgT8maArxv81mULDWN8oKxkzboH07CHesxElq4=
|
||||||
github.com/alecthomas/chroma/v2 v2.18.0/go.mod h1:RVX6AvYm4VfYe/zsk7mjHueLDZor3aWCNE14TFlepBk=
|
github.com/alecthomas/chroma/v2 v2.19.0/go.mod h1:RVX6AvYm4VfYe/zsk7mjHueLDZor3aWCNE14TFlepBk=
|
||||||
github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
|
github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
|
||||||
github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc=
|
github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc=
|
||||||
github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
|
github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
|
||||||
|
|
|
@ -26,6 +26,7 @@ type WriterMode struct {
|
||||||
Flags Flags
|
Flags Flags
|
||||||
|
|
||||||
Expression string
|
Expression string
|
||||||
|
Exclusion string
|
||||||
|
|
||||||
StacktraceLevel Level
|
StacktraceLevel Level
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,14 @@ func (b *EventWriterBaseImpl) Run(ctx context.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var exclusionRegexp *regexp.Regexp
|
||||||
|
if b.Mode.Exclusion != "" {
|
||||||
|
var err error
|
||||||
|
if exclusionRegexp, err = regexp.Compile(b.Mode.Exclusion); err != nil {
|
||||||
|
FallbackErrorf("unable to compile exclusion %q for writer %q: %v", b.Mode.Exclusion, b.Name, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
handlePaused := func() {
|
handlePaused := func() {
|
||||||
if pause := b.GetPauseChan(); pause != nil {
|
if pause := b.GetPauseChan(); pause != nil {
|
||||||
select {
|
select {
|
||||||
|
@ -95,6 +103,13 @@ func (b *EventWriterBaseImpl) Run(ctx context.Context) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if exclusionRegexp != nil {
|
||||||
|
fileLineCaller := fmt.Sprintf("%s:%d:%s", event.Origin.Filename, event.Origin.Line, event.Origin.Caller)
|
||||||
|
matched := exclusionRegexp.MatchString(fileLineCaller) || exclusionRegexp.MatchString(event.Origin.MsgSimpleText)
|
||||||
|
if matched {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
switch msg := event.Msg.(type) {
|
switch msg := event.Msg.(type) {
|
||||||
|
|
|
@ -31,3 +31,49 @@ func TestBufferLogger(t *testing.T) {
|
||||||
logger.Close()
|
logger.Close()
|
||||||
assert.Contains(t, bufferWriter.Buffer.String(), expected)
|
assert.Contains(t, bufferWriter.Buffer.String(), expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestBufferLoggerWithExclusion(t *testing.T) {
|
||||||
|
prefix := "ExclusionPrefix "
|
||||||
|
level := log.INFO
|
||||||
|
message := "something"
|
||||||
|
|
||||||
|
bufferWriter := log.NewEventWriterBuffer("test-buffer", log.WriterMode{
|
||||||
|
Level: level,
|
||||||
|
Prefix: prefix,
|
||||||
|
Exclusion: message,
|
||||||
|
})
|
||||||
|
|
||||||
|
logger := log.NewLoggerWithWriters(t.Context(), "test", bufferWriter)
|
||||||
|
|
||||||
|
logger.SendLogEvent(&log.Event{
|
||||||
|
Level: log.INFO,
|
||||||
|
MsgSimpleText: message,
|
||||||
|
})
|
||||||
|
logger.Close()
|
||||||
|
assert.NotContains(t, bufferWriter.Buffer.String(), message)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBufferLoggerWithExpressionAndExclusion(t *testing.T) {
|
||||||
|
prefix := "BothPrefix "
|
||||||
|
level := log.INFO
|
||||||
|
expression := ".*foo.*"
|
||||||
|
exclusion := ".*bar.*"
|
||||||
|
|
||||||
|
bufferWriter := log.NewEventWriterBuffer("test-buffer", log.WriterMode{
|
||||||
|
Level: level,
|
||||||
|
Prefix: prefix,
|
||||||
|
Expression: expression,
|
||||||
|
Exclusion: exclusion,
|
||||||
|
})
|
||||||
|
|
||||||
|
logger := log.NewLoggerWithWriters(t.Context(), "test", bufferWriter)
|
||||||
|
|
||||||
|
logger.SendLogEvent(&log.Event{Level: log.INFO, MsgSimpleText: "foo expression"})
|
||||||
|
logger.SendLogEvent(&log.Event{Level: log.INFO, MsgSimpleText: "bar exclusion"})
|
||||||
|
logger.SendLogEvent(&log.Event{Level: log.INFO, MsgSimpleText: "foo bar both"})
|
||||||
|
logger.SendLogEvent(&log.Event{Level: log.INFO, MsgSimpleText: "none"})
|
||||||
|
logger.Close()
|
||||||
|
|
||||||
|
assert.Contains(t, bufferWriter.Buffer.String(), "foo expression")
|
||||||
|
assert.NotContains(t, bufferWriter.Buffer.String(), "bar")
|
||||||
|
}
|
||||||
|
|
|
@ -143,3 +143,19 @@ func TestLoggerExpressionFilter(t *testing.T) {
|
||||||
|
|
||||||
assert.Equal(t, []string{"foo\n", "foo bar\n", "by filename\n"}, w1.GetLogs())
|
assert.Equal(t, []string{"foo\n", "foo bar\n", "by filename\n"}, w1.GetLogs())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLoggerExclusionFilter(t *testing.T) {
|
||||||
|
logger := NewLoggerWithWriters(t.Context(), "test")
|
||||||
|
|
||||||
|
w1 := newDummyWriter("dummy-1", DEBUG, 0)
|
||||||
|
w1.Mode.Exclusion = "foo.*"
|
||||||
|
logger.AddWriters(w1)
|
||||||
|
|
||||||
|
logger.Info("foo")
|
||||||
|
logger.Info("bar")
|
||||||
|
logger.Info("foo bar")
|
||||||
|
logger.SendLogEvent(&Event{Level: INFO, Filename: "foo.go", MsgSimpleText: "by filename"})
|
||||||
|
logger.Close()
|
||||||
|
|
||||||
|
assert.Equal(t, []string{"bar\n"}, w1.GetLogs())
|
||||||
|
}
|
||||||
|
|
|
@ -133,6 +133,7 @@ func loadLogModeByName(rootCfg ConfigProvider, loggerName, modeName string) (wri
|
||||||
writerMode.StacktraceLevel = log.LevelFromString(ConfigInheritedKeyString(sec, "STACKTRACE_LEVEL", Log.StacktraceLogLevel.String()))
|
writerMode.StacktraceLevel = log.LevelFromString(ConfigInheritedKeyString(sec, "STACKTRACE_LEVEL", Log.StacktraceLogLevel.String()))
|
||||||
writerMode.Prefix = ConfigInheritedKeyString(sec, "PREFIX")
|
writerMode.Prefix = ConfigInheritedKeyString(sec, "PREFIX")
|
||||||
writerMode.Expression = ConfigInheritedKeyString(sec, "EXPRESSION")
|
writerMode.Expression = ConfigInheritedKeyString(sec, "EXPRESSION")
|
||||||
|
writerMode.Exclusion = ConfigInheritedKeyString(sec, "EXCLUSION")
|
||||||
// flags are updated and set below
|
// flags are updated and set below
|
||||||
|
|
||||||
switch writerType {
|
switch writerType {
|
||||||
|
|
|
@ -44,6 +44,7 @@ func TestLogConfigDefault(t *testing.T) {
|
||||||
"BufferLen": 10000,
|
"BufferLen": 10000,
|
||||||
"Colorize": false,
|
"Colorize": false,
|
||||||
"Expression": "",
|
"Expression": "",
|
||||||
|
"Exclusion": "",
|
||||||
"Flags": "stdflags",
|
"Flags": "stdflags",
|
||||||
"Level": "info",
|
"Level": "info",
|
||||||
"Prefix": "",
|
"Prefix": "",
|
||||||
|
@ -83,6 +84,7 @@ logger.xorm.MODE =
|
||||||
"BufferLen": 10000,
|
"BufferLen": 10000,
|
||||||
"Colorize": false,
|
"Colorize": false,
|
||||||
"Expression": "",
|
"Expression": "",
|
||||||
|
"Exclusion": "",
|
||||||
"Flags": "stdflags",
|
"Flags": "stdflags",
|
||||||
"Level": "info",
|
"Level": "info",
|
||||||
"Prefix": "",
|
"Prefix": "",
|
||||||
|
@ -121,6 +123,7 @@ MODE = console
|
||||||
"BufferLen": 10000,
|
"BufferLen": 10000,
|
||||||
"Colorize": false,
|
"Colorize": false,
|
||||||
"Expression": "",
|
"Expression": "",
|
||||||
|
"Exclusion": "",
|
||||||
"Flags": "stdflags",
|
"Flags": "stdflags",
|
||||||
"Level": "info",
|
"Level": "info",
|
||||||
"Prefix": "",
|
"Prefix": "",
|
||||||
|
@ -168,6 +171,7 @@ ACCESS = file
|
||||||
"BufferLen": 10000,
|
"BufferLen": 10000,
|
||||||
"Colorize": false,
|
"Colorize": false,
|
||||||
"Expression": "",
|
"Expression": "",
|
||||||
|
"Exclusion": "",
|
||||||
"Flags": "stdflags",
|
"Flags": "stdflags",
|
||||||
"Level": "info",
|
"Level": "info",
|
||||||
"Prefix": "",
|
"Prefix": "",
|
||||||
|
@ -191,6 +195,7 @@ ACCESS = file
|
||||||
"BufferLen": 10000,
|
"BufferLen": 10000,
|
||||||
"Colorize": false,
|
"Colorize": false,
|
||||||
"Expression": "",
|
"Expression": "",
|
||||||
|
"Exclusion": "",
|
||||||
"Flags": "none",
|
"Flags": "none",
|
||||||
"Level": "info",
|
"Level": "info",
|
||||||
"Prefix": "",
|
"Prefix": "",
|
||||||
|
@ -257,6 +262,7 @@ STDERR = true
|
||||||
"BufferLen": 10000,
|
"BufferLen": 10000,
|
||||||
"Colorize": false,
|
"Colorize": false,
|
||||||
"Expression": "",
|
"Expression": "",
|
||||||
|
"Exclusion": "",
|
||||||
"Flags": "stdflags",
|
"Flags": "stdflags",
|
||||||
"Level": "warn",
|
"Level": "warn",
|
||||||
"Prefix": "",
|
"Prefix": "",
|
||||||
|
@ -270,6 +276,7 @@ STDERR = true
|
||||||
"BufferLen": 10000,
|
"BufferLen": 10000,
|
||||||
"Colorize": false,
|
"Colorize": false,
|
||||||
"Expression": "",
|
"Expression": "",
|
||||||
|
"Exclusion": "",
|
||||||
"Flags": "stdflags",
|
"Flags": "stdflags",
|
||||||
"Level": "error",
|
"Level": "error",
|
||||||
"Prefix": "",
|
"Prefix": "",
|
||||||
|
@ -287,6 +294,7 @@ STDERR = true
|
||||||
"BufferLen": 10000,
|
"BufferLen": 10000,
|
||||||
"Colorize": false,
|
"Colorize": false,
|
||||||
"Expression": "",
|
"Expression": "",
|
||||||
|
"Exclusion": "",
|
||||||
"Flags": "none",
|
"Flags": "none",
|
||||||
"Level": "warn",
|
"Level": "warn",
|
||||||
"Prefix": "",
|
"Prefix": "",
|
||||||
|
@ -323,6 +331,7 @@ MODE = file
|
||||||
LEVEL = error
|
LEVEL = error
|
||||||
STACKTRACE_LEVEL = fatal
|
STACKTRACE_LEVEL = fatal
|
||||||
EXPRESSION = filter
|
EXPRESSION = filter
|
||||||
|
EXCLUSION = not
|
||||||
FLAGS = medfile
|
FLAGS = medfile
|
||||||
PREFIX = "[Prefix] "
|
PREFIX = "[Prefix] "
|
||||||
FILE_NAME = file-xxx.log
|
FILE_NAME = file-xxx.log
|
||||||
|
@ -341,6 +350,7 @@ COMPRESSION_LEVEL = 4
|
||||||
"BufferLen": 10,
|
"BufferLen": 10,
|
||||||
"Colorize": false,
|
"Colorize": false,
|
||||||
"Expression": "",
|
"Expression": "",
|
||||||
|
"Exclusion": "",
|
||||||
"Flags": "stdflags",
|
"Flags": "stdflags",
|
||||||
"Level": "info",
|
"Level": "info",
|
||||||
"Prefix": "",
|
"Prefix": "",
|
||||||
|
@ -360,6 +370,7 @@ COMPRESSION_LEVEL = 4
|
||||||
"BufferLen": 10,
|
"BufferLen": 10,
|
||||||
"Colorize": false,
|
"Colorize": false,
|
||||||
"Expression": "filter",
|
"Expression": "filter",
|
||||||
|
"Exclusion": "not",
|
||||||
"Flags": "medfile",
|
"Flags": "medfile",
|
||||||
"Level": "error",
|
"Level": "error",
|
||||||
"Prefix": "[Prefix] ",
|
"Prefix": "[Prefix] ",
|
||||||
|
|
|
@ -145,6 +145,7 @@ func AddLogger(ctx *context.PrivateContext) {
|
||||||
|
|
||||||
writerMode.Prefix, _ = opts.Config["prefix"].(string)
|
writerMode.Prefix, _ = opts.Config["prefix"].(string)
|
||||||
writerMode.Expression, _ = opts.Config["expression"].(string)
|
writerMode.Expression, _ = opts.Config["expression"].(string)
|
||||||
|
writerMode.Exclusion, _ = opts.Config["exclusion"].(string)
|
||||||
|
|
||||||
switch writerType {
|
switch writerType {
|
||||||
case "console":
|
case "console":
|
||||||
|
|
|
@ -16,8 +16,8 @@ const (
|
||||||
tplActionNowDone base.TplName = "actions/now_done"
|
tplActionNowDone base.TplName = "actions/now_done"
|
||||||
)
|
)
|
||||||
|
|
||||||
// requires !run.Status.IsSuccess() or !lastRun.Status.IsSuccess()
|
var MailActionRun = mailActionRun // make it mockable
|
||||||
func MailActionRun(run *actions_model.ActionRun, priorStatus actions_model.Status, lastRun *actions_model.ActionRun) error {
|
func mailActionRun(run *actions_model.ActionRun, priorStatus actions_model.Status, lastRun *actions_model.ActionRun) error {
|
||||||
if setting.MailService == nil {
|
if setting.MailService == nil {
|
||||||
// No mail service configured
|
// No mail service configured
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -57,6 +57,91 @@ func assertTranslatedLocaleMailActionsNowDone(t *testing.T, msgBody string) {
|
||||||
AssertTranslatedLocale(t, msgBody, "mail.actions.successful_run_after_failure", "mail.actions.not_successful_run", "mail.actions.run_info_cur_status", "mail.actions.run_info_ref", "mail.actions.run_info_previous_status", "mail.actions.run_info_trigger", "mail.view_it_on")
|
AssertTranslatedLocale(t, msgBody, "mail.actions.successful_run_after_failure", "mail.actions.not_successful_run", "mail.actions.run_info_cur_status", "mail.actions.run_info_ref", "mail.actions.run_info_previous_status", "mail.actions.run_info_trigger", "mail.view_it_on")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestActionRunNowDoneStatusMatrix(t *testing.T) {
|
||||||
|
successStatuses := []actions_model.Status{
|
||||||
|
actions_model.StatusSuccess,
|
||||||
|
actions_model.StatusSkipped,
|
||||||
|
actions_model.StatusCancelled,
|
||||||
|
}
|
||||||
|
failureStatuses := []actions_model.Status{
|
||||||
|
actions_model.StatusFailure,
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, testCase := range []struct {
|
||||||
|
name string
|
||||||
|
statuses []actions_model.Status
|
||||||
|
hasLastRun bool
|
||||||
|
lastStatuses []actions_model.Status
|
||||||
|
run bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "FailureNoLastRun",
|
||||||
|
statuses: failureStatuses,
|
||||||
|
run: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "SuccessNoLastRun",
|
||||||
|
statuses: successStatuses,
|
||||||
|
run: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "FailureLastRunSuccess",
|
||||||
|
statuses: failureStatuses,
|
||||||
|
hasLastRun: true,
|
||||||
|
lastStatuses: successStatuses,
|
||||||
|
run: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "FailureLastRunFailure",
|
||||||
|
statuses: failureStatuses,
|
||||||
|
hasLastRun: true,
|
||||||
|
lastStatuses: failureStatuses,
|
||||||
|
run: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "SuccessLastRunFailure",
|
||||||
|
statuses: successStatuses,
|
||||||
|
hasLastRun: true,
|
||||||
|
lastStatuses: failureStatuses,
|
||||||
|
run: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "SuccessLastRunSuccess",
|
||||||
|
statuses: successStatuses,
|
||||||
|
hasLastRun: true,
|
||||||
|
lastStatuses: successStatuses,
|
||||||
|
run: false,
|
||||||
|
},
|
||||||
|
} {
|
||||||
|
t.Run(testCase.name, func(t *testing.T) {
|
||||||
|
var called bool
|
||||||
|
defer test.MockVariableValue(&MailActionRun, func(run *actions_model.ActionRun, priorStatus actions_model.Status, lastRun *actions_model.ActionRun) error {
|
||||||
|
called = true
|
||||||
|
return nil
|
||||||
|
})()
|
||||||
|
for _, status := range testCase.statuses {
|
||||||
|
for _, lastStatus := range testCase.lastStatuses {
|
||||||
|
called = false
|
||||||
|
n := NewNotifier()
|
||||||
|
var lastRun *actions_model.ActionRun
|
||||||
|
if testCase.hasLastRun {
|
||||||
|
lastRun = &actions_model.ActionRun{
|
||||||
|
Status: lastStatus,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
n.ActionRunNowDone(t.Context(),
|
||||||
|
&actions_model.ActionRun{
|
||||||
|
Status: status,
|
||||||
|
},
|
||||||
|
actions_model.StatusUnknown,
|
||||||
|
lastRun)
|
||||||
|
assert.Equal(t, testCase.run, called, "status = %s, lastStatus = %s", status, lastStatus)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestActionRunNowDoneNotificationMail(t *testing.T) {
|
func TestActionRunNowDoneNotificationMail(t *testing.T) {
|
||||||
ctx := t.Context()
|
ctx := t.Context()
|
||||||
|
|
||||||
|
|
|
@ -212,7 +212,7 @@ func (m *mailNotifier) NewUserSignUp(ctx context.Context, newUser *user_model.Us
|
||||||
|
|
||||||
func (m *mailNotifier) ActionRunNowDone(ctx context.Context, run *actions_model.ActionRun, priorStatus actions_model.Status, lastRun *actions_model.ActionRun) {
|
func (m *mailNotifier) ActionRunNowDone(ctx context.Context, run *actions_model.ActionRun, priorStatus actions_model.Status, lastRun *actions_model.ActionRun) {
|
||||||
// Only send a mail on a successful run when the workflow recovered (i.e., the run before failed).
|
// Only send a mail on a successful run when the workflow recovered (i.e., the run before failed).
|
||||||
if run.Status.IsSuccess() && (lastRun == nil || lastRun.Status.IsSuccess()) {
|
if !run.Status.IsFailure() && (lastRun == nil || !lastRun.Status.IsFailure()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := MailActionRun(run, priorStatus, lastRun); err != nil {
|
if err := MailActionRun(run, priorStatus, lastRun); err != nil {
|
||||||
|
|
|
@ -42,7 +42,6 @@ test('WebAuthn register & login flow', async ({browser, request}, workerInfo) =>
|
||||||
await page.locator('div[aria-label="Profile and settings…"]').click();
|
await page.locator('div[aria-label="Profile and settings…"]').click();
|
||||||
await page.getByText('Sign out').click();
|
await page.getByText('Sign out').click();
|
||||||
}).toPass();
|
}).toPass();
|
||||||
await page.waitForURL(`${workerInfo.project.use.baseURL}/`);
|
|
||||||
|
|
||||||
// Login.
|
// Login.
|
||||||
response = await page.goto('/user/login');
|
response = await page.goto('/user/login');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue