1
0
Fork 0

Add depends_on

This commit is contained in:
Lauris BH 2022-07-27 14:12:54 +03:00
parent 80b4fa4e23
commit 06d9534619
No known key found for this signature in database
GPG Key ID: DFDE60A0093EB926
5 changed files with 24 additions and 8 deletions

View File

@ -6,3 +6,14 @@
Go library and utility to convert different pipelines to Woodpecker CI pipeline(s).
Currently supports converting only from Drone CI pipeline format with limited functionality.
## Drone pipeline supported features
* `kind` - must be `pipeline`
* `type` - only `docker` supported
* `name`
* `steps`
* `name`
* `image`
* `commands`
* `depends_on`

View File

@ -31,8 +31,9 @@ func (d DronePipeline) Convert(pipeline *Pipeline) (*transform.Pipeline, error)
}
p := &transform.Pipeline{
Name: pipeline.Name,
Steps: make(transform.Steps, 0, len(pipeline.Steps)),
Name: pipeline.Name,
Steps: make(transform.Steps, 0, len(pipeline.Steps)),
DependsOn: pipeline.DependsOn,
}
for _, step := range pipeline.Steps {

View File

@ -42,7 +42,7 @@ func TestTransformSimple(t *testing.T) {
pipeline := getPipelineByName(pipelines, "build")
require.NotNil(t, pipeline, "build pipeline not found")
assert.Len(t, pipeline.Steps, 2)
require.Len(t, pipeline.Steps, 2)
assert.Equal(t, "test", pipeline.Steps[0].Name)
assert.Equal(t, "golang:1.18", pipeline.Steps[0].Image)
assert.Len(t, pipeline.Steps[0].Commands, 1)
@ -54,8 +54,10 @@ func TestTransformSimple(t *testing.T) {
pipeline = getPipelineByName(pipelines, "deploy")
require.NotNil(t, pipeline, "deploy pipeline not found")
assert.Len(t, pipeline.Steps, 1)
require.Len(t, pipeline.Steps, 1)
assert.Equal(t, "deploy", pipeline.Steps[0].Name)
assert.Equal(t, "alpine:latest", pipeline.Steps[0].Image)
assert.Len(t, pipeline.Steps[0].Commands, 1)
require.Len(t, pipeline.DependsOn, 1)
assert.Equal(t, "build", pipeline.DependsOn[0])
}

View File

@ -11,8 +11,9 @@ type Step struct {
}
type Pipeline struct {
Kind string `yaml:"kind"`
Type string `yaml:"type"`
Name string `yaml:"name"`
Steps []*Step `yaml:"steps"`
Kind string `yaml:"kind"`
Type string `yaml:"type"`
Name string `yaml:"name"`
Steps []*Step `yaml:"steps"`
DependsOn []string `yaml:"depends_on"`
}

View File

@ -40,4 +40,5 @@ type Pipeline struct {
Name string `yaml:"-"`
Workspace *Workspace `yaml:"workspace,omitempty"`
Steps Steps `yaml:"pipeline"`
DependsOn []string `yaml:"depends_on,omitempty"`
}