Skip to content

Commit

Permalink
Merge branch 'master' into fix/evaluate_matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Feb 15, 2022
2 parents 454db0b + 0fae967 commit 0cce8cb
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 28 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ scoop install act
yay -S act
```

### [COPR](https://copr.fedorainfracloud.org/coprs/rubemlrm/act-cli/) (Linux)

```shell
dnf copr enable rubemlrm/act-cli
dnf install act-cli
```

### [Nix](https://nixos.org) (Linux/macOS)

[Nix recipe](https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/tools/misc/act/default.nix)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/andreaskoch/go-fswatch v1.0.0
github.com/containerd/continuity v0.2.0 // indirect
github.com/docker/cli v20.10.12+incompatible
github.com/docker/distribution v2.7.1+incompatible
github.com/docker/distribution v2.8.0+incompatible
github.com/docker/docker v20.10.12+incompatible
github.com/go-git/go-billy/v5 v5.3.1
github.com/go-git/go-git/v5 v5.4.2
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,9 @@ github.com/docker/cli v20.10.12+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hH
github.com/docker/distribution v0.0.0-20190905152932-14b96e55d84c/go.mod h1:0+TTO4EOBfRPhZXAeF1Vu+W3hHZ8eLp8PgKVZlcvtFY=
github.com/docker/distribution v2.6.0-rc.1.0.20180327202408-83389a148052+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug=
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/distribution v2.8.0+incompatible h1:l9EaZDICImO1ngI+uTifW+ZYvvz7fKISBAKpg+MbWbY=
github.com/docker/distribution v2.8.0+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v0.0.0-20200511152416-a93e9eb0e95c/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v0.7.3-0.20190327010347-be7ac8be2ae0/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v1.4.2-0.20180531152204-71cd53e4a197/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
Expand Down
6 changes: 2 additions & 4 deletions pkg/runner/job_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func newJobExecutor(info jobInfo) common.Executor {
return nil
})
}

steps = append(steps, func(ctx context.Context) error {
err := info.stopContainer()(ctx)
if err != nil {
Expand All @@ -64,8 +65,5 @@ func newJobExecutor(info jobInfo) common.Executor {
return nil
})

return common.NewPipelineExecutor(steps...).Finally(info.interpolateOutputs()).Finally(func(ctx context.Context) error {
info.closeContainer()
return nil
})
return common.NewPipelineExecutor(steps...).Finally(info.interpolateOutputs()).Finally(info.closeContainer())
}
92 changes: 70 additions & 22 deletions pkg/runner/job_executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,74 +62,122 @@ func (jpm *jobInfoMock) result(result string) {

func TestNewJobExecutor(t *testing.T) {
table := []struct {
name string
steps []*model.Step
result string
hasError bool
name string
steps []*model.Step
executedSteps []string
result string
hasError bool
}{
{
"zeroSteps",
[]*model.Step{},
"success",
false,
name: "zeroSteps",
steps: []*model.Step{},
executedSteps: []string{
"startContainer",
"stopContainer",
"interpolateOutputs",
"closeContainer",
},
result: "success",
hasError: false,
},
{
"stepWithoutPrePost",
[]*model.Step{{
name: "stepWithoutPrePost",
steps: []*model.Step{{
ID: "1",
}},
"success",
false,
executedSteps: []string{
"startContainer",
"step1",
"stopContainer",
"interpolateOutputs",
"closeContainer",
},
result: "success",
hasError: false,
},
{
"stepWithFailure",
[]*model.Step{{
name: "stepWithFailure",
steps: []*model.Step{{
ID: "1",
}},
"failure",
true,
executedSteps: []string{
"startContainer",
"step1",
"stopContainer",
"interpolateOutputs",
"closeContainer",
},
result: "failure",
hasError: true,
},
{
name: "multipleSteps",
steps: []*model.Step{{
ID: "1",
}, {
ID: "2",
}},
executedSteps: []string{
"startContainer",
"step1",
"step2",
"stopContainer",
"interpolateOutputs",
"closeContainer",
},
result: "success",
hasError: false,
},
}

for _, tt := range table {
t.Run(tt.name, func(t *testing.T) {
ctx := common.WithJobErrorContainer(context.Background())
jpm := &jobInfoMock{}
executorOrder := make([]string, 0)

jpm.On("startContainer").Return(func(ctx context.Context) error {
executorOrder = append(executorOrder, "startContainer")
return nil
})

jpm.On("steps").Return(tt.steps)

for _, stepMock := range tt.steps {
jpm.On("newStepExecutor", stepMock).Return(func(ctx context.Context) error {
if tt.hasError {
return fmt.Errorf("error")
}
return nil
})
func(stepMock *model.Step) {
jpm.On("newStepExecutor", stepMock).Return(func(ctx context.Context) error {
executorOrder = append(executorOrder, "step"+stepMock.ID)
if tt.hasError {
return fmt.Errorf("error")
}
return nil
})
}(stepMock)
}

jpm.On("interpolateOutputs").Return(func(ctx context.Context) error {
executorOrder = append(executorOrder, "interpolateOutputs")
return nil
})

jpm.On("matrix").Return(map[string]interface{}{})

jpm.On("stopContainer").Return(func(ctx context.Context) error {
executorOrder = append(executorOrder, "stopContainer")
return nil
})

jpm.On("result", tt.result)

jpm.On("closeContainer").Return(func(ctx context.Context) error {
executorOrder = append(executorOrder, "closeContainer")
return nil
})

executor := newJobExecutor(jpm)
err := executor(ctx)
assert.Nil(t, err)
assert.Equal(t, tt.executedSteps, executorOrder)
})
}
}

0 comments on commit 0cce8cb

Please sign in to comment.