mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-08-11 17:50:58 +00:00
feat: parse types of reusable workflows (#1414)
This change does parse the different types of workflow jobs. It is not much by itself but the start to implement reusable workflows. Relates to #826 Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
fef9bd3448
commit
7a4d3e467b
2 changed files with 75 additions and 0 deletions
|
@ -138,6 +138,31 @@ jobs:
|
|||
})
|
||||
}
|
||||
|
||||
func TestReadWorkflow_JobTypes(t *testing.T) {
|
||||
yaml := `
|
||||
name: invalid job definition
|
||||
|
||||
jobs:
|
||||
default-job:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: echo
|
||||
remote-reusable-workflow:
|
||||
runs-on: ubuntu-latest
|
||||
uses: remote/repo/.github/workflows/workflow.yml@main
|
||||
local-reusable-workflow:
|
||||
runs-on: ubuntu-latest
|
||||
uses: ./.github/workflows/workflow.yml
|
||||
`
|
||||
|
||||
workflow, err := ReadWorkflow(strings.NewReader(yaml))
|
||||
assert.NoError(t, err, "read workflow should succeed")
|
||||
assert.Len(t, workflow.Jobs, 3)
|
||||
assert.Equal(t, workflow.Jobs["default-job"].Type(), JobTypeDefault)
|
||||
assert.Equal(t, workflow.Jobs["remote-reusable-workflow"].Type(), JobTypeReusableWorkflowRemote)
|
||||
assert.Equal(t, workflow.Jobs["local-reusable-workflow"].Type(), JobTypeReusableWorkflowLocal)
|
||||
}
|
||||
|
||||
func TestReadWorkflow_StepsTypes(t *testing.T) {
|
||||
yaml := `
|
||||
name: invalid step definition
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue