support for fast failure
This commit is contained in:
@@ -191,7 +191,7 @@ func (c *execCommand) run(*kingpin.ParseContext) error {
|
||||
Number: len(c.Stage.Steps) + 1,
|
||||
Name: step.Name,
|
||||
Status: drone.StatusPending,
|
||||
ErrIgnore: step.IgnoreErr,
|
||||
ErrIgnore: step.ErrPolicy == runtime.ErrIgnore,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ func createStep(spec *resource.Pipeline, src *resource.Step) *engine.Step {
|
||||
DNSSearch: src.DNSSearch,
|
||||
Envs: convertStaticEnv(src.Environment),
|
||||
ExtraHosts: src.ExtraHosts,
|
||||
IgnoreErr: strings.EqualFold(src.Failure, "ignore"),
|
||||
IgnoreStderr: false,
|
||||
IgnoreStdout: false,
|
||||
Network: src.Network,
|
||||
@@ -101,5 +100,14 @@ func createStep(spec *resource.Pipeline, src *resource.Step) *engine.Step {
|
||||
dst.RunPolicy = runtime.RunOnFailure
|
||||
}
|
||||
|
||||
// set the pipeline failure policy. steps can choose
|
||||
// to ignore the failure, or fail fast.
|
||||
switch src.Failure {
|
||||
case "ignore":
|
||||
dst.ErrPolicy = runtime.ErrIgnore
|
||||
case "fast", "fast-fail", "fail-fast":
|
||||
dst.ErrPolicy = runtime.ErrFailFast
|
||||
}
|
||||
|
||||
return dst
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@ type (
|
||||
DNSSearch []string `json:"dns_search,omitempty"`
|
||||
Entrypoint []string `json:"entrypoint,omitempty"`
|
||||
Envs map[string]string `json:"environment,omitempty"`
|
||||
ErrPolicy runtime.ErrPolicy `json:"err_policy,omitempty"`
|
||||
ExtraHosts []string `json:"extra_hosts,omitempty"`
|
||||
IgnoreErr bool `json:"ignore_err,omitempty"`
|
||||
IgnoreStdout bool `json:"ignore_stderr,omitempty"`
|
||||
IgnoreStderr bool `json:"ignore_stdout,omitempty"`
|
||||
Image string `json:"image,omitempty"`
|
||||
@@ -151,7 +151,7 @@ func (s *Step) GetName() string { return s.Name }
|
||||
func (s *Step) GetDependencies() []string { return s.DependsOn }
|
||||
func (s *Step) GetEnviron() map[string]string { return s.Envs }
|
||||
func (s *Step) SetEnviron(env map[string]string) { s.Envs = env }
|
||||
func (s *Step) GetErrPolicy() runtime.ErrPolicy { return runtime.ErrFail }
|
||||
func (s *Step) GetErrPolicy() runtime.ErrPolicy { return s.ErrPolicy }
|
||||
func (s *Step) GetRunPolicy() runtime.RunPolicy { return s.RunPolicy }
|
||||
func (s *Step) GetSecretAt(i int) runtime.Secret { return s.Secrets[i] }
|
||||
func (s *Step) GetSecretLen() int { return len(s.Secrets) }
|
||||
|
||||
2
go.mod
2
go.mod
@@ -12,7 +12,7 @@ require (
|
||||
github.com/drone/drone-go v1.1.1-0.20191119212130-1d2e07e87e79
|
||||
github.com/drone/drone-runtime v1.1.0
|
||||
github.com/drone/envsubst v1.0.2
|
||||
github.com/drone/runner-go v1.5.0
|
||||
github.com/drone/runner-go v1.5.1-0.20191209224608-17a63102bc1d
|
||||
github.com/drone/signal v1.0.0
|
||||
github.com/ghodss/yaml v1.0.0
|
||||
github.com/golang/mock v1.3.1
|
||||
|
||||
2
go.sum
2
go.sum
@@ -58,6 +58,8 @@ github.com/drone/runner-go v1.4.1-0.20191206210533-80bb9688cb0c h1:T3CIdRKiTiaNb
|
||||
github.com/drone/runner-go v1.4.1-0.20191206210533-80bb9688cb0c/go.mod h1:ZIhsNU4EHG7R7J+OXeXuwwAxlxOBYLCc0gCkbbhWb/o=
|
||||
github.com/drone/runner-go v1.5.0 h1:4cgQn+ZIf9TKHQpAF8wC06knqSULZ8T46tFxPZ5ADs0=
|
||||
github.com/drone/runner-go v1.5.0/go.mod h1:ZIhsNU4EHG7R7J+OXeXuwwAxlxOBYLCc0gCkbbhWb/o=
|
||||
github.com/drone/runner-go v1.5.1-0.20191209224608-17a63102bc1d h1:nrtqRjjyIpC9qM5Iruzu+wV8L7ugAJGE2G2KZCbXn9g=
|
||||
github.com/drone/runner-go v1.5.1-0.20191209224608-17a63102bc1d/go.mod h1:ZIhsNU4EHG7R7J+OXeXuwwAxlxOBYLCc0gCkbbhWb/o=
|
||||
github.com/drone/signal v1.0.0 h1:NrnM2M/4yAuU/tXs6RP1a1ZfxnaHwYkd0kJurA1p6uI=
|
||||
github.com/drone/signal v1.0.0/go.mod h1:S8t92eFT0g4WUgEc/LxG+LCuiskpMNsG0ajAMGnyZpc=
|
||||
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
// Copyright 2019 Drone.IO Inc. All rights reserved.
|
||||
// Use of this source code is governed by the Polyform License
|
||||
// that can be found in the LICENSE file.
|
||||
|
||||
package mock
|
||||
|
||||
//go:generate mockgen -package=mock -destination=mock_engine_gen.go github.com/drone-runners/drone-runner-docker/engine Engine
|
||||
//go:generate mockgen -package=mock -destination=mock_execer_gen.go github.com/drone-runners/drone-runner-docker/runtime Execer
|
||||
@@ -1,79 +0,0 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: github.com/drone-runners/drone-runner-docker/engine (interfaces: Engine)
|
||||
|
||||
// Package mock is a generated GoMock package.
|
||||
package mock
|
||||
|
||||
import (
|
||||
context "context"
|
||||
engine "github.com/drone-runners/drone-runner-docker/engine"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
io "io"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
||||
// MockEngine is a mock of Engine interface
|
||||
type MockEngine struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockEngineMockRecorder
|
||||
}
|
||||
|
||||
// MockEngineMockRecorder is the mock recorder for MockEngine
|
||||
type MockEngineMockRecorder struct {
|
||||
mock *MockEngine
|
||||
}
|
||||
|
||||
// NewMockEngine creates a new mock instance
|
||||
func NewMockEngine(ctrl *gomock.Controller) *MockEngine {
|
||||
mock := &MockEngine{ctrl: ctrl}
|
||||
mock.recorder = &MockEngineMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use
|
||||
func (m *MockEngine) EXPECT() *MockEngineMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Destroy mocks base method
|
||||
func (m *MockEngine) Destroy(arg0 context.Context, arg1 *engine.Spec) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Destroy", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Destroy indicates an expected call of Destroy
|
||||
func (mr *MockEngineMockRecorder) Destroy(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Destroy", reflect.TypeOf((*MockEngine)(nil).Destroy), arg0, arg1)
|
||||
}
|
||||
|
||||
// Run mocks base method
|
||||
func (m *MockEngine) Run(arg0 context.Context, arg1 *engine.Spec, arg2 *engine.Step, arg3 io.Writer) (*engine.State, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Run", arg0, arg1, arg2, arg3)
|
||||
ret0, _ := ret[0].(*engine.State)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// Run indicates an expected call of Run
|
||||
func (mr *MockEngineMockRecorder) Run(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Run", reflect.TypeOf((*MockEngine)(nil).Run), arg0, arg1, arg2, arg3)
|
||||
}
|
||||
|
||||
// Setup mocks base method
|
||||
func (m *MockEngine) Setup(arg0 context.Context, arg1 *engine.Spec) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Setup", arg0, arg1)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Setup indicates an expected call of Setup
|
||||
func (mr *MockEngineMockRecorder) Setup(arg0, arg1 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Setup", reflect.TypeOf((*MockEngine)(nil).Setup), arg0, arg1)
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
// Code generated by MockGen. DO NOT EDIT.
|
||||
// Source: github.com/drone-runners/drone-runner-docker/runtime (interfaces: Execer)
|
||||
|
||||
// Package mock is a generated GoMock package.
|
||||
package mock
|
||||
|
||||
import (
|
||||
context "context"
|
||||
engine "github.com/drone-runners/drone-runner-docker/engine"
|
||||
pipeline "github.com/drone/runner-go/pipeline"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
reflect "reflect"
|
||||
)
|
||||
|
||||
// MockExecer is a mock of Execer interface
|
||||
type MockExecer struct {
|
||||
ctrl *gomock.Controller
|
||||
recorder *MockExecerMockRecorder
|
||||
}
|
||||
|
||||
// MockExecerMockRecorder is the mock recorder for MockExecer
|
||||
type MockExecerMockRecorder struct {
|
||||
mock *MockExecer
|
||||
}
|
||||
|
||||
// NewMockExecer creates a new mock instance
|
||||
func NewMockExecer(ctrl *gomock.Controller) *MockExecer {
|
||||
mock := &MockExecer{ctrl: ctrl}
|
||||
mock.recorder = &MockExecerMockRecorder{mock}
|
||||
return mock
|
||||
}
|
||||
|
||||
// EXPECT returns an object that allows the caller to indicate expected use
|
||||
func (m *MockExecer) EXPECT() *MockExecerMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Exec mocks base method
|
||||
func (m *MockExecer) Exec(arg0 context.Context, arg1 *engine.Spec, arg2 *pipeline.State) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Exec", arg0, arg1, arg2)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Exec indicates an expected call of Exec
|
||||
func (mr *MockExecerMockRecorder) Exec(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Exec", reflect.TypeOf((*MockExecer)(nil).Exec), arg0, arg1, arg2)
|
||||
}
|
||||
Reference in New Issue
Block a user