1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-08-11 17:50:58 +00:00

feat: add enable-email-notifications to the schema

This commit is contained in:
Earl Warren 2025-07-05 22:05:33 +02:00
parent 5faf1bbc54
commit 960b552ba9
2 changed files with 12 additions and 14 deletions

View file

@ -112,32 +112,25 @@ jobs:
func TestReadWorkflow_Notifications(t *testing.T) { func TestReadWorkflow_Notifications(t *testing.T) {
for _, testCase := range []struct { for _, testCase := range []struct {
expected bool expected bool
hasErr bool err string
snippet string snippet string
}{ }{
{ {
expected: false, expected: false,
hasErr: false,
snippet: "# nothing", snippet: "# nothing",
}, },
{ {
expected: true, expected: true,
hasErr: false,
snippet: "enable-email-notifications: true", snippet: "enable-email-notifications: true",
}, },
{ {
expected: false, expected: false,
hasErr: false,
snippet: "enable-email-notifications: false", snippet: "enable-email-notifications: false",
}, },
{ {
hasErr: true, err: "`invalid` into bool",
snippet: "enable-email-notifications: invalid", snippet: "enable-email-notifications: invalid",
}, },
{
hasErr: true,
snippet: "enable-email-notifications: [1,2]",
},
} { } {
t.Run(testCase.snippet, func(t *testing.T) { t.Run(testCase.snippet, func(t *testing.T) {
yaml := fmt.Sprintf(` yaml := fmt.Sprintf(`
@ -154,12 +147,12 @@ jobs:
`, testCase.snippet) `, testCase.snippet)
workflow, err := ReadWorkflow(strings.NewReader(yaml)) workflow, err := ReadWorkflow(strings.NewReader(yaml))
if testCase.err != "" {
assert.ErrorContains(t, err, testCase.err)
} else {
assert.NoError(t, err, "read workflow should succeed") assert.NoError(t, err, "read workflow should succeed")
notification, err := workflow.Notifications() notification, err := workflow.Notifications()
if testCase.hasErr {
assert.Error(t, err)
} else {
assert.NoError(t, err) assert.NoError(t, err)
assert.Equal(t, testCase.expected, notification) assert.Equal(t, testCase.expected, notification)
} }

View file

@ -7,6 +7,7 @@
"properties": { "properties": {
"on": "on", "on": "on",
"name": "workflow-name", "name": "workflow-name",
"enable-email-notifications": "workflow-enable-email-notifications",
"run-name": "run-name", "run-name": "run-name",
"defaults": "workflow-defaults", "defaults": "workflow-defaults",
"env": "workflow-env", "env": "workflow-env",
@ -44,6 +45,10 @@
"description": "The name of the workflow that GitHub displays on your repository's 'Actions' tab.\n\n[Documentation](https://docs.github.com/actions/using-workflows/workflow-syntax-for-github-actions#name)", "description": "The name of the workflow that GitHub displays on your repository's 'Actions' tab.\n\n[Documentation](https://docs.github.com/actions/using-workflows/workflow-syntax-for-github-actions#name)",
"string": {} "string": {}
}, },
"workflow-enable-email-notifications": {
"description": "Send an email notification when a workflow run fails.\n\n[Documentation](https://forgejo.org/docs/next/user/actions/#enable-email-notifications)",
"boolean": {}
},
"run-name": { "run-name": {
"context": ["github", "inputs", "vars"], "context": ["github", "inputs", "vars"],
"string": {}, "string": {},