1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2025-09-16 08:46:30 +02:00

Cleanup state reporting (#3850)

This commit is contained in:
Anbraten
2024-07-01 11:20:55 +02:00
committed by GitHub
parent daeab8d3c7
commit 2fa9432ef8
18 changed files with 590 additions and 514 deletions

View File

@@ -17,17 +17,17 @@ type Peer struct {
mock.Mock
}
// Done provides a mock function with given fields: c, id, state
func (_m *Peer) Done(c context.Context, id string, state rpc.State) error {
ret := _m.Called(c, id, state)
// Done provides a mock function with given fields: c, workflowID, state
func (_m *Peer) Done(c context.Context, workflowID string, state rpc.WorkflowState) error {
ret := _m.Called(c, workflowID, state)
if len(ret) == 0 {
panic("no return value specified for Done")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string, rpc.State) error); ok {
r0 = rf(c, id, state)
if rf, ok := ret.Get(0).(func(context.Context, string, rpc.WorkflowState) error); ok {
r0 = rf(c, workflowID, state)
} else {
r0 = ret.Error(0)
}
@@ -35,9 +35,9 @@ func (_m *Peer) Done(c context.Context, id string, state rpc.State) error {
return r0
}
// Extend provides a mock function with given fields: c, id
func (_m *Peer) Extend(c context.Context, id string) error {
ret := _m.Called(c, id)
// Extend provides a mock function with given fields: c, workflowID
func (_m *Peer) Extend(c context.Context, workflowID string) error {
ret := _m.Called(c, workflowID)
if len(ret) == 0 {
panic("no return value specified for Extend")
@@ -45,7 +45,7 @@ func (_m *Peer) Extend(c context.Context, id string) error {
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string) error); ok {
r0 = rf(c, id)
r0 = rf(c, workflowID)
} else {
r0 = ret.Error(0)
}
@@ -53,17 +53,17 @@ func (_m *Peer) Extend(c context.Context, id string) error {
return r0
}
// Init provides a mock function with given fields: c, id, state
func (_m *Peer) Init(c context.Context, id string, state rpc.State) error {
ret := _m.Called(c, id, state)
// Init provides a mock function with given fields: c, workflowID, state
func (_m *Peer) Init(c context.Context, workflowID string, state rpc.WorkflowState) error {
ret := _m.Called(c, workflowID, state)
if len(ret) == 0 {
panic("no return value specified for Init")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string, rpc.State) error); ok {
r0 = rf(c, id, state)
if rf, ok := ret.Get(0).(func(context.Context, string, rpc.WorkflowState) error); ok {
r0 = rf(c, workflowID, state)
} else {
r0 = ret.Error(0)
}
@@ -183,17 +183,17 @@ func (_m *Peer) UnregisterAgent(ctx context.Context) error {
return r0
}
// Update provides a mock function with given fields: c, id, state
func (_m *Peer) Update(c context.Context, id string, state rpc.State) error {
ret := _m.Called(c, id, state)
// Update provides a mock function with given fields: c, workflowID, state
func (_m *Peer) Update(c context.Context, workflowID string, state rpc.StepState) error {
ret := _m.Called(c, workflowID, state)
if len(ret) == 0 {
panic("no return value specified for Update")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string, rpc.State) error); ok {
r0 = rf(c, id, state)
if rf, ok := ret.Get(0).(func(context.Context, string, rpc.StepState) error); ok {
r0 = rf(c, workflowID, state)
} else {
r0 = ret.Error(0)
}
@@ -231,9 +231,9 @@ func (_m *Peer) Version(c context.Context) (*rpc.Version, error) {
return r0, r1
}
// Wait provides a mock function with given fields: c, id
func (_m *Peer) Wait(c context.Context, id string) error {
ret := _m.Called(c, id)
// Wait provides a mock function with given fields: c, workflowID
func (_m *Peer) Wait(c context.Context, workflowID string) error {
ret := _m.Called(c, workflowID)
if len(ret) == 0 {
panic("no return value specified for Wait")
@@ -241,7 +241,7 @@ func (_m *Peer) Wait(c context.Context, id string) error {
var r0 error
if rf, ok := ret.Get(0).(func(context.Context, string) error); ok {
r0 = rf(c, id)
r0 = rf(c, workflowID)
} else {
r0 = ret.Error(0)
}

View File

@@ -27,11 +27,18 @@ type (
Labels map[string]string `json:"labels"`
}
// State defines the step state.
State struct {
// StepState defines the step state.
StepState struct {
StepUUID string `json:"step_uuid"`
Started int64 `json:"started"`
Finished int64 `json:"finished"`
Exited bool `json:"exited"`
ExitCode int `json:"exit_code"`
Error string `json:"error"`
}
// WorkflowState defines the workflow state.
WorkflowState struct {
Started int64 `json:"started"`
Finished int64 `json:"finished"`
Error string `json:"error"`
@@ -61,21 +68,21 @@ type Peer interface {
Next(c context.Context, f Filter) (*Workflow, error)
// Wait blocks until the workflow is complete
Wait(c context.Context, id string) error
Wait(c context.Context, workflowID string) error
// Init signals the step is initialized
Init(c context.Context, id string, state State) error
// Init signals the workflow is initialized
Init(c context.Context, workflowID string, state WorkflowState) error
// Done signals the step is complete
Done(c context.Context, id string, state State) error
// Done signals the workflow is complete
Done(c context.Context, workflowID string, state WorkflowState) error
// Extend extends the workflow deadline
Extend(c context.Context, id string) error
Extend(c context.Context, workflowID string) error
// Update updates the step state
Update(c context.Context, id string, state State) error
Update(c context.Context, workflowID string, state StepState) error
// Log writes the workflow log entry
// Log writes the step log entry
Log(c context.Context, logEntry *LogEntry) error
// RegisterAgent register our agent to the server

View File

@@ -16,4 +16,4 @@ package proto
// Version is the version of the woodpecker.proto file,
// IMPORTANT: increased by 1 each time it get changed.
const Version int32 = 8
const Version int32 = 9

File diff suppressed because it is too large Load Diff

View File

@@ -41,10 +41,16 @@ service Woodpecker {
// Basic Types
//
message State {
message StepState {
string step_uuid = 1;
bool exited = 2;
int32 exit_code = 3;
int64 started = 2;
int64 finished = 3;
bool exited = 4;
int32 exit_code = 5;
string error = 6;
}
message WorkflowState {
int64 started = 4;
int64 finished = 5;
string error = 6;
@@ -78,7 +84,7 @@ message NextRequest {
message InitRequest {
string id = 1;
State state = 2;
WorkflowState state = 2;
}
message WaitRequest {
@@ -87,7 +93,7 @@ message WaitRequest {
message DoneRequest {
string id = 1;
State state = 2;
WorkflowState state = 2;
}
message ExtendRequest {
@@ -96,7 +102,7 @@ message ExtendRequest {
message UpdateRequest {
string id = 1;
State state = 2;
StepState state = 2;
}
message LogRequest {