Skip to content

Commit 29ad93f

Browse files
committed
test: debug
1 parent 3646ea4 commit 29ad93f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

routers/api/actions/runner/runner.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"code.gitea.io/actions-proto-go/runner/v1/runnerv1connect"
2020
"github.com/bufbuild/connect-go"
2121
gouuid "github.com/google/uuid"
22+
"github.com/nektos/act/pkg/jobparser"
2223
"google.golang.org/grpc/codes"
2324
"google.golang.org/grpc/status"
2425
)
@@ -109,12 +110,33 @@ func (s *Service) FetchTask(
109110
task = t
110111
}
111112

113+
if task != nil {
114+
var workflowJob *jobparser.Job
115+
if gots, err := jobparser.Parse(task.WorkflowPayload); err != nil {
116+
panic(err)
117+
} else if len(gots) != 1 {
118+
panic(err)
119+
} else {
120+
_, workflowJob = gots[0].Job()
121+
}
122+
if workflowJob.Name == "job2" {
123+
task.Needs = map[string]*runnerv1.TaskNeed{
124+
"job1": {
125+
Outputs: debugOutputs,
126+
Result: runnerv1.Result_RESULT_SUCCESS,
127+
},
128+
}
129+
}
130+
}
131+
112132
res := connect.NewResponse(&runnerv1.FetchTaskResponse{
113133
Task: task,
114134
})
115135
return res, nil
116136
}
117137

138+
var debugOutputs = map[string]string{}
139+
118140
// UpdateTask updates the task status.
119141
func (s *Service) UpdateTask(
120142
ctx context.Context,
@@ -145,6 +167,11 @@ func (s *Service) UpdateTask(
145167
return nil, status.Errorf(codes.Internal, "update task: %v", err)
146168
}
147169

170+
for k, v := range req.Msg.Outputs {
171+
log.Info("task %d output %s: %s", task.ID, k, v)
172+
debugOutputs[k] = v
173+
}
174+
148175
if err := task.LoadJob(ctx); err != nil {
149176
return nil, status.Errorf(codes.Internal, "load job: %v", err)
150177
}

0 commit comments

Comments
 (0)