Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions pkg/schema/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,86 @@ jobs:
}).UnmarshalYAML(&node)
assert.NoError(t, err)
}

func TestConcurrencyQueue(t *testing.T) {
cases := []struct {
name string
yaml string
wantErr bool
}{
{
name: "queue single is accepted",
yaml: `
on: push
concurrency:
group: g
queue: single
jobs:
noop:
runs-on: ubuntu-latest
steps:
- run: echo ok
`,
},
{
name: "queue max is accepted",
yaml: `
on: push
concurrency:
group: g
queue: max
jobs:
noop:
runs-on: ubuntu-latest
steps:
- run: echo ok
`,
},
{
name: "queue at job level is accepted",
yaml: `
on: push
jobs:
noop:
runs-on: ubuntu-latest
concurrency:
group: g
queue: max
steps:
- run: echo ok
`,
},
{
name: "queue with unknown value is rejected",
yaml: `
on: push
concurrency:
group: g
queue: bogus
jobs:
noop:
runs-on: ubuntu-latest
steps:
- run: echo ok
`,
wantErr: true,
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
var node yaml.Node
if err := yaml.Unmarshal([]byte(tc.yaml), &node); !assert.NoError(t, err) {
return
}
err := (&Node{
Definition: "workflow-root-strict",
Schema: GetWorkflowSchema(),
}).UnmarshalYAML(&node)
if tc.wantErr {
assert.Error(t, err)
} else {
assert.NoError(t, err)
}
})
}
}
7 changes: 7 additions & 0 deletions pkg/schema/workflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1643,10 +1643,17 @@
"cancel-in-progress": {
"type": "boolean",
"description": "To cancel any currently running job or workflow in the same concurrency group, specify cancel-in-progress: true."
},
"queue": {
"type": "concurrency-queue",
"description": "Controls how pending jobs or workflow runs are queued in the concurrency group. `single` (default): at most one job or workflow run can be pending. `max`: up to 100 jobs or workflow runs can be pending. The combination of `queue: max` and `cancel-in-progress: true` is not allowed and will result in a workflow validation error.\n\n[Documentation](https://docs.github.com/actions/using-workflows/workflow-syntax-for-github-actions#concurrency)"
}
}
}
},
"concurrency-queue": {
"allowed-values": ["single", "max"]
},
"job-environment": {
"description": "The environment that the job references. All environment protection rules must pass before a job referencing the environment is sent to a runner.",
"context": ["github", "inputs", "vars", "needs", "strategy", "matrix"],
Expand Down