mirror of
https://gitea.com/gitea/act_runner.git
synced 2026-03-24 15:55:03 +01:00
Fix all 93 lint-go errors
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -143,14 +143,14 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report.
|
||||
return err
|
||||
}
|
||||
job := workflow.GetJob(jobID)
|
||||
var stepIds []string
|
||||
var stepIDs []string
|
||||
for i, v := range job.Steps {
|
||||
if v.ID == "" {
|
||||
v.ID = strconv.Itoa(i)
|
||||
}
|
||||
stepIds = append(stepIds, v.ID)
|
||||
stepIDs = append(stepIDs, v.ID)
|
||||
}
|
||||
reporter.SetStepIdMapping(stepIds...)
|
||||
reporter.SetStepIdMapping(stepIDs...)
|
||||
|
||||
taskContext := task.Context.Fields
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ func generateWorkflow(task *runnerv1.Task) (*model.Workflow, string, error) {
|
||||
|
||||
// TODO GITEA
|
||||
workflow.Jobs[jobID].RawNeeds = rawNeeds
|
||||
workflow.Jobs[jobID].RawRunsOn.Encode("dummy")
|
||||
_ = workflow.Jobs[jobID].RawRunsOn.Encode("dummy")
|
||||
|
||||
return workflow, jobID, nil
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ import (
|
||||
|
||||
runnerv1 "code.gitea.io/actions-proto-go/runner/v1"
|
||||
"gitea.com/gitea/act_runner/pkg/model"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.yaml.in/yaml/v4"
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
|
||||
func Test_generateWorkflow(t *testing.T) {
|
||||
@@ -58,7 +58,7 @@ jobs:
|
||||
},
|
||||
},
|
||||
assert: func(t *testing.T, wf *model.Workflow) {
|
||||
assert.DeepEqual(t, wf.GetJob("job9").Needs(), []string{"job1", "job2"})
|
||||
assert.Equal(t, []string{"job1", "job2"}, wf.GetJob("job9").Needs())
|
||||
},
|
||||
want1: "job9",
|
||||
wantErr: false,
|
||||
@@ -83,8 +83,8 @@ jobs:
|
||||
},
|
||||
assert: func(t *testing.T, wf *model.Workflow) {
|
||||
job := wf.GetJob("test")
|
||||
assert.DeepEqual(t, job.Needs(), []string{})
|
||||
assert.Equal(t, len(job.Steps), 2)
|
||||
assert.Equal(t, []string{}, job.Needs())
|
||||
assert.Len(t, job.Steps, 2)
|
||||
},
|
||||
want1: "test",
|
||||
wantErr: false,
|
||||
@@ -125,9 +125,9 @@ jobs:
|
||||
assert: func(t *testing.T, wf *model.Workflow) {
|
||||
job := wf.GetJob("deploy")
|
||||
needs := job.Needs()
|
||||
assert.DeepEqual(t, needs, []string{"build", "lint", "test"})
|
||||
assert.Equal(t, wf.Jobs["test"].Outputs["coverage"], "80%")
|
||||
assert.Equal(t, wf.Jobs["lint"].Result, "failure")
|
||||
assert.Equal(t, []string{"build", "lint", "test"}, needs)
|
||||
assert.Equal(t, "80%", wf.Jobs["test"].Outputs["coverage"])
|
||||
assert.Equal(t, "failure", wf.Jobs["lint"].Result)
|
||||
},
|
||||
want1: "deploy",
|
||||
wantErr: false,
|
||||
@@ -165,11 +165,11 @@ jobs:
|
||||
},
|
||||
},
|
||||
assert: func(t *testing.T, wf *model.Workflow) {
|
||||
assert.Equal(t, wf.Name, "Complex workflow")
|
||||
assert.Equal(t, wf.Env["NODE_ENV"], "production")
|
||||
assert.Equal(t, wf.Env["CI"], "true")
|
||||
assert.Equal(t, "Complex workflow", wf.Name)
|
||||
assert.Equal(t, "production", wf.Env["NODE_ENV"])
|
||||
assert.Equal(t, "true", wf.Env["CI"])
|
||||
job := wf.GetJob("build")
|
||||
assert.Equal(t, len(job.Steps), 4)
|
||||
assert.Len(t, job.Steps, 4)
|
||||
},
|
||||
want1: "build",
|
||||
wantErr: false,
|
||||
@@ -200,8 +200,8 @@ jobs:
|
||||
assert: func(t *testing.T, wf *model.Workflow) {
|
||||
job := wf.GetJob("integration")
|
||||
container := job.Container()
|
||||
assert.Equal(t, container.Image, "node:18")
|
||||
assert.Equal(t, job.Services["postgres"].Image, "postgres:15")
|
||||
assert.Equal(t, "node:18", container.Image)
|
||||
assert.Equal(t, "postgres:15", job.Services["postgres"].Image)
|
||||
},
|
||||
want1: "integration",
|
||||
wantErr: false,
|
||||
@@ -231,7 +231,7 @@ jobs:
|
||||
job := wf.GetJob("test")
|
||||
matrixes, err := job.GetMatrixes()
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, len(matrixes), 2)
|
||||
assert.Len(t, matrixes, 2)
|
||||
},
|
||||
want1: "test",
|
||||
wantErr: false,
|
||||
@@ -245,9 +245,9 @@ jobs:
|
||||
},
|
||||
},
|
||||
assert: func(t *testing.T, wf *model.Workflow) {
|
||||
assert.Equal(t, wf.Name, "Special: characters & test")
|
||||
assert.Equal(t, "Special: characters & test", wf.Name)
|
||||
job := wf.GetJob("test")
|
||||
assert.Equal(t, len(job.Steps), 3)
|
||||
assert.Len(t, job.Steps, 3)
|
||||
},
|
||||
want1: "test",
|
||||
wantErr: false,
|
||||
@@ -283,7 +283,7 @@ jobs:
|
||||
}
|
||||
require.NoError(t, err)
|
||||
tt.assert(t, got)
|
||||
assert.Equal(t, got1, tt.want1)
|
||||
assert.Equal(t, tt.want1, got1)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -301,7 +301,7 @@ func Test_yamlV4NodeRoundTrip(t *testing.T) {
|
||||
|
||||
out, err := yaml.Marshal(&node)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, string(out), "- a\n- b\n- c\n")
|
||||
assert.Equal(t, "- a\n- b\n- c\n", string(out))
|
||||
})
|
||||
|
||||
t.Run("unmarshal and re-marshal workflow", func(t *testing.T) {
|
||||
@@ -310,7 +310,7 @@ func Test_yamlV4NodeRoundTrip(t *testing.T) {
|
||||
var wf map[string]any
|
||||
err := yaml.Unmarshal(input, &wf)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, wf["name"], "test")
|
||||
assert.Equal(t, "test", wf["name"])
|
||||
|
||||
out, err := yaml.Marshal(wf)
|
||||
require.NoError(t, err)
|
||||
@@ -318,7 +318,7 @@ func Test_yamlV4NodeRoundTrip(t *testing.T) {
|
||||
var wf2 map[string]any
|
||||
err = yaml.Unmarshal(out, &wf2)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, wf2["name"], "test")
|
||||
assert.Equal(t, "test", wf2["name"])
|
||||
})
|
||||
|
||||
t.Run("node kind constants", func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user