Skip to content

Commit

Permalink
allow stages to be skipped or excluded after they have failed
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Simmons committed Aug 30, 2023
1 parent 1d9a495 commit a67800e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions mission/mission.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ func (m *Mission) FinishStage(stageName string, ignoreDependencies bool) (Respon

// SkipStage changes a stage's state to skip using the following logic:
// - does stage exist?
// - state can't be started, failed, excluded or already skipped?
// - state can't be started, excluded or already skipped?
// - are all upstream dependencies finished or skipped?
func (m *Mission) SkipStage(stageName string) (Response, error) {
if m.isComplete {
Expand All @@ -342,11 +342,11 @@ func (m *Mission) SkipStage(stageName string) (Response, error) {

// Check the state of the stage
switch s.State {
case ready:
case ready, failed:
s.State = skipped
case skipped, excluded, finished:
// this is allowed, but state will not be changed - mission logic should not be affected
case started, failed:
case started:
err := &StageChangeError{fmt.Sprintf("cannot skip stage '%v' because it has previously been %s", stageName, s.State)}
return Response{false, nil, m.isComplete}, err
}
Expand Down Expand Up @@ -418,13 +418,13 @@ func (m *Mission) ExcludeStage(stageName string) (Response, error) {

func (m *Mission) tryExcludingStage(s *Stage) error {
switch s.State {
case ready, excluded:
case ready, failed:
s.State = excluded
return nil
case finished, skipped:
case finished, skipped, excluded:
// this is allowed, but state will not be changed - mission logic should not be affected
return nil
case started, failed:
case started:
err := &StageChangeError{fmt.Sprintf("cannot exclude stage '%v' because it is %s, not ready", s.Name, s.State)}
return err
}
Expand Down

0 comments on commit a67800e

Please sign in to comment.