Skip to content

Commit

Permalink
test: debug
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfogre committed Apr 20, 2023
1 parent 3646ea4 commit 29ad93f
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions routers/api/actions/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"code.gitea.io/actions-proto-go/runner/v1/runnerv1connect"
"github.com/bufbuild/connect-go"
gouuid "github.com/google/uuid"
"github.com/nektos/act/pkg/jobparser"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
Expand Down Expand Up @@ -109,12 +110,33 @@ func (s *Service) FetchTask(
task = t
}

if task != nil {
var workflowJob *jobparser.Job
if gots, err := jobparser.Parse(task.WorkflowPayload); err != nil {
panic(err)
} else if len(gots) != 1 {
panic(err)
} else {
_, workflowJob = gots[0].Job()
}
if workflowJob.Name == "job2" {
task.Needs = map[string]*runnerv1.TaskNeed{
"job1": {
Outputs: debugOutputs,
Result: runnerv1.Result_RESULT_SUCCESS,
},
}
}
}

res := connect.NewResponse(&runnerv1.FetchTaskResponse{
Task: task,
})
return res, nil
}

var debugOutputs = map[string]string{}

// UpdateTask updates the task status.
func (s *Service) UpdateTask(
ctx context.Context,
Expand Down Expand Up @@ -145,6 +167,11 @@ func (s *Service) UpdateTask(
return nil, status.Errorf(codes.Internal, "update task: %v", err)
}

for k, v := range req.Msg.Outputs {
log.Info("task %d output %s: %s", task.ID, k, v)
debugOutputs[k] = v
}

if err := task.LoadJob(ctx); err != nil {
return nil, status.Errorf(codes.Internal, "load job: %v", err)
}
Expand Down

0 comments on commit 29ad93f

Please sign in to comment.