From 077cab3b4682f7a73e3504e2323cb4feac2e3439 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Tue, 17 Dec 2024 20:35:30 +0100 Subject: [PATCH 1/2] Disable corepack auto-pin during build (#4581) --- docker/Dockerfile.make | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile.make b/docker/Dockerfile.make index 8bedc7dae..44718613a 100644 --- a/docker/Dockerfile.make +++ b/docker/Dockerfile.make @@ -1,5 +1,5 @@ -# docker build --rm -f docker/Dockerfile.make -t woodpecker/make:local . -FROM docker.io/golang:1.23-alpine as golang_image +# docker build --rm -f docker/Dockerfile.make -t woodpecker/make:local . +FROM docker.io/golang:1.23-alpine AS golang_image FROM docker.io/node:23-alpine RUN apk add --no-cache --update make gcc binutils-gold musl-dev protoc && \ @@ -10,6 +10,7 @@ COPY --from=golang_image /usr/local/go /usr/local/go COPY Makefile / ENV PATH=$PATH:/usr/local/go/bin ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0 +ENV COREPACK_ENABLE_AUTO_PIN=0 # Cache tools RUN GOBIN=/usr/local/go/bin make install-tools && \ From 7fa474c5c38d062e5afc6715e18b6a4d54b53243 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Wed, 18 Dec 2024 08:58:08 +0100 Subject: [PATCH 2/2] Ignore blocked pipelines for badge rendering (#4582) --- pipeline/rpc/proto/woodpecker.pb.go | 194 ++++++++++------------- server/api/badge.go | 2 +- server/forge/mocks/forge.go | 4 +- server/queue/mocks/queue.go | 4 +- server/services/mocks/manager.go | 8 +- server/store/datastore/pipeline.go | 9 ++ server/store/mocks/store.go | 48 ++++-- server/store/store.go | 2 + woodpecker-go/woodpecker/mocks/client.go | 10 +- 9 files changed, 151 insertions(+), 130 deletions(-) diff --git a/pipeline/rpc/proto/woodpecker.pb.go b/pipeline/rpc/proto/woodpecker.pb.go index 8f5f059c4..8ded1251e 100644 --- a/pipeline/rpc/proto/woodpecker.pb.go +++ b/pipeline/rpc/proto/woodpecker.pb.go @@ -15,7 +15,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.2 +// protoc-gen-go v1.36.0 // protoc v4.24.4 // source: woodpecker.proto @@ -36,16 +36,15 @@ const ( ) type StepState struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + StepUuid string `protobuf:"bytes,1,opt,name=step_uuid,json=stepUuid,proto3" json:"step_uuid,omitempty"` + Started int64 `protobuf:"varint,2,opt,name=started,proto3" json:"started,omitempty"` + Finished int64 `protobuf:"varint,3,opt,name=finished,proto3" json:"finished,omitempty"` + Exited bool `protobuf:"varint,4,opt,name=exited,proto3" json:"exited,omitempty"` + ExitCode int32 `protobuf:"varint,5,opt,name=exit_code,json=exitCode,proto3" json:"exit_code,omitempty"` + Error string `protobuf:"bytes,6,opt,name=error,proto3" json:"error,omitempty"` unknownFields protoimpl.UnknownFields - - StepUuid string `protobuf:"bytes,1,opt,name=step_uuid,json=stepUuid,proto3" json:"step_uuid,omitempty"` - Started int64 `protobuf:"varint,2,opt,name=started,proto3" json:"started,omitempty"` - Finished int64 `protobuf:"varint,3,opt,name=finished,proto3" json:"finished,omitempty"` - Exited bool `protobuf:"varint,4,opt,name=exited,proto3" json:"exited,omitempty"` - ExitCode int32 `protobuf:"varint,5,opt,name=exit_code,json=exitCode,proto3" json:"exit_code,omitempty"` - Error string `protobuf:"bytes,6,opt,name=error,proto3" json:"error,omitempty"` + sizeCache protoimpl.SizeCache } func (x *StepState) Reset() { @@ -121,13 +120,12 @@ func (x *StepState) GetError() string { } type WorkflowState struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Started int64 `protobuf:"varint,4,opt,name=started,proto3" json:"started,omitempty"` + Finished int64 `protobuf:"varint,5,opt,name=finished,proto3" json:"finished,omitempty"` + Error string `protobuf:"bytes,6,opt,name=error,proto3" json:"error,omitempty"` unknownFields protoimpl.UnknownFields - - Started int64 `protobuf:"varint,4,opt,name=started,proto3" json:"started,omitempty"` - Finished int64 `protobuf:"varint,5,opt,name=finished,proto3" json:"finished,omitempty"` - Error string `protobuf:"bytes,6,opt,name=error,proto3" json:"error,omitempty"` + sizeCache protoimpl.SizeCache } func (x *WorkflowState) Reset() { @@ -182,15 +180,14 @@ func (x *WorkflowState) GetError() string { } type LogEntry struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + StepUuid string `protobuf:"bytes,1,opt,name=step_uuid,json=stepUuid,proto3" json:"step_uuid,omitempty"` + Time int64 `protobuf:"varint,2,opt,name=time,proto3" json:"time,omitempty"` + Line int32 `protobuf:"varint,3,opt,name=line,proto3" json:"line,omitempty"` + Type int32 `protobuf:"varint,4,opt,name=type,proto3" json:"type,omitempty"` // 0 = stdout, 1 = stderr, 2 = exit-code, 3 = metadata, 4 = progress + Data []byte `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"` unknownFields protoimpl.UnknownFields - - StepUuid string `protobuf:"bytes,1,opt,name=step_uuid,json=stepUuid,proto3" json:"step_uuid,omitempty"` - Time int64 `protobuf:"varint,2,opt,name=time,proto3" json:"time,omitempty"` - Line int32 `protobuf:"varint,3,opt,name=line,proto3" json:"line,omitempty"` - Type int32 `protobuf:"varint,4,opt,name=type,proto3" json:"type,omitempty"` // 0 = stdout, 1 = stderr, 2 = exit-code, 3 = metadata, 4 = progress - Data []byte `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"` + sizeCache protoimpl.SizeCache } func (x *LogEntry) Reset() { @@ -259,11 +256,10 @@ func (x *LogEntry) GetData() []byte { } type Filter struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Labels map[string]string `protobuf:"bytes,1,rep,name=labels,proto3" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` unknownFields protoimpl.UnknownFields - - Labels map[string]string `protobuf:"bytes,1,rep,name=labels,proto3" json:"labels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + sizeCache protoimpl.SizeCache } func (x *Filter) Reset() { @@ -304,13 +300,12 @@ func (x *Filter) GetLabels() map[string]string { } type Workflow struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Timeout int64 `protobuf:"varint,2,opt,name=timeout,proto3" json:"timeout,omitempty"` + Payload []byte `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"` unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Timeout int64 `protobuf:"varint,2,opt,name=timeout,proto3" json:"timeout,omitempty"` - Payload []byte `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"` + sizeCache protoimpl.SizeCache } func (x *Workflow) Reset() { @@ -365,11 +360,10 @@ func (x *Workflow) GetPayload() []byte { } type NextRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Filter *Filter `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"` unknownFields protoimpl.UnknownFields - - Filter *Filter `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"` + sizeCache protoimpl.SizeCache } func (x *NextRequest) Reset() { @@ -410,12 +404,11 @@ func (x *NextRequest) GetFilter() *Filter { } type InitRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + State *WorkflowState `protobuf:"bytes,2,opt,name=state,proto3" json:"state,omitempty"` unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - State *WorkflowState `protobuf:"bytes,2,opt,name=state,proto3" json:"state,omitempty"` + sizeCache protoimpl.SizeCache } func (x *InitRequest) Reset() { @@ -463,11 +456,10 @@ func (x *InitRequest) GetState() *WorkflowState { } type WaitRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *WaitRequest) Reset() { @@ -508,12 +500,11 @@ func (x *WaitRequest) GetId() string { } type DoneRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + State *WorkflowState `protobuf:"bytes,2,opt,name=state,proto3" json:"state,omitempty"` unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - State *WorkflowState `protobuf:"bytes,2,opt,name=state,proto3" json:"state,omitempty"` + sizeCache protoimpl.SizeCache } func (x *DoneRequest) Reset() { @@ -561,11 +552,10 @@ func (x *DoneRequest) GetState() *WorkflowState { } type ExtendRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *ExtendRequest) Reset() { @@ -606,12 +596,11 @@ func (x *ExtendRequest) GetId() string { } type UpdateRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + State *StepState `protobuf:"bytes,2,opt,name=state,proto3" json:"state,omitempty"` unknownFields protoimpl.UnknownFields - - Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - State *StepState `protobuf:"bytes,2,opt,name=state,proto3" json:"state,omitempty"` + sizeCache protoimpl.SizeCache } func (x *UpdateRequest) Reset() { @@ -659,11 +648,10 @@ func (x *UpdateRequest) GetState() *StepState { } type LogRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + LogEntries []*LogEntry `protobuf:"bytes,1,rep,name=logEntries,proto3" json:"logEntries,omitempty"` unknownFields protoimpl.UnknownFields - - LogEntries []*LogEntry `protobuf:"bytes,1,rep,name=logEntries,proto3" json:"logEntries,omitempty"` + sizeCache protoimpl.SizeCache } func (x *LogRequest) Reset() { @@ -704,9 +692,9 @@ func (x *LogRequest) GetLogEntries() []*LogEntry { } type Empty struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Empty) Reset() { @@ -740,11 +728,10 @@ func (*Empty) Descriptor() ([]byte, []int) { } type ReportHealthRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Status string `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` unknownFields protoimpl.UnknownFields - - Status string `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` + sizeCache protoimpl.SizeCache } func (x *ReportHealthRequest) Reset() { @@ -785,15 +772,14 @@ func (x *ReportHealthRequest) GetStatus() string { } type AgentInfo struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Platform string `protobuf:"bytes,1,opt,name=platform,proto3" json:"platform,omitempty"` + Capacity int32 `protobuf:"varint,2,opt,name=capacity,proto3" json:"capacity,omitempty"` + Backend string `protobuf:"bytes,3,opt,name=backend,proto3" json:"backend,omitempty"` + Version string `protobuf:"bytes,4,opt,name=version,proto3" json:"version,omitempty"` + CustomLabels map[string]string `protobuf:"bytes,5,rep,name=customLabels,proto3" json:"customLabels,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` unknownFields protoimpl.UnknownFields - - Platform string `protobuf:"bytes,1,opt,name=platform,proto3" json:"platform,omitempty"` - Capacity int32 `protobuf:"varint,2,opt,name=capacity,proto3" json:"capacity,omitempty"` - Backend string `protobuf:"bytes,3,opt,name=backend,proto3" json:"backend,omitempty"` - Version string `protobuf:"bytes,4,opt,name=version,proto3" json:"version,omitempty"` - CustomLabels map[string]string `protobuf:"bytes,5,rep,name=customLabels,proto3" json:"customLabels,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + sizeCache protoimpl.SizeCache } func (x *AgentInfo) Reset() { @@ -862,11 +848,10 @@ func (x *AgentInfo) GetCustomLabels() map[string]string { } type RegisterAgentRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Info *AgentInfo `protobuf:"bytes,1,opt,name=info,proto3" json:"info,omitempty"` unknownFields protoimpl.UnknownFields - - Info *AgentInfo `protobuf:"bytes,1,opt,name=info,proto3" json:"info,omitempty"` + sizeCache protoimpl.SizeCache } func (x *RegisterAgentRequest) Reset() { @@ -907,12 +892,11 @@ func (x *RegisterAgentRequest) GetInfo() *AgentInfo { } type VersionResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + GrpcVersion int32 `protobuf:"varint,1,opt,name=grpc_version,json=grpcVersion,proto3" json:"grpc_version,omitempty"` + ServerVersion string `protobuf:"bytes,2,opt,name=server_version,json=serverVersion,proto3" json:"server_version,omitempty"` unknownFields protoimpl.UnknownFields - - GrpcVersion int32 `protobuf:"varint,1,opt,name=grpc_version,json=grpcVersion,proto3" json:"grpc_version,omitempty"` - ServerVersion string `protobuf:"bytes,2,opt,name=server_version,json=serverVersion,proto3" json:"server_version,omitempty"` + sizeCache protoimpl.SizeCache } func (x *VersionResponse) Reset() { @@ -960,11 +944,10 @@ func (x *VersionResponse) GetServerVersion() string { } type NextResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Workflow *Workflow `protobuf:"bytes,1,opt,name=workflow,proto3" json:"workflow,omitempty"` unknownFields protoimpl.UnknownFields - - Workflow *Workflow `protobuf:"bytes,1,opt,name=workflow,proto3" json:"workflow,omitempty"` + sizeCache protoimpl.SizeCache } func (x *NextResponse) Reset() { @@ -1005,11 +988,10 @@ func (x *NextResponse) GetWorkflow() *Workflow { } type RegisterAgentResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + AgentId int64 `protobuf:"varint,1,opt,name=agent_id,json=agentId,proto3" json:"agent_id,omitempty"` unknownFields protoimpl.UnknownFields - - AgentId int64 `protobuf:"varint,1,opt,name=agent_id,json=agentId,proto3" json:"agent_id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *RegisterAgentResponse) Reset() { @@ -1050,12 +1032,11 @@ func (x *RegisterAgentResponse) GetAgentId() int64 { } type AuthRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + AgentToken string `protobuf:"bytes,1,opt,name=agent_token,json=agentToken,proto3" json:"agent_token,omitempty"` + AgentId int64 `protobuf:"varint,2,opt,name=agent_id,json=agentId,proto3" json:"agent_id,omitempty"` unknownFields protoimpl.UnknownFields - - AgentToken string `protobuf:"bytes,1,opt,name=agent_token,json=agentToken,proto3" json:"agent_token,omitempty"` - AgentId int64 `protobuf:"varint,2,opt,name=agent_id,json=agentId,proto3" json:"agent_id,omitempty"` + sizeCache protoimpl.SizeCache } func (x *AuthRequest) Reset() { @@ -1103,13 +1084,12 @@ func (x *AuthRequest) GetAgentId() int64 { } type AuthResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Status string `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` + AgentId int64 `protobuf:"varint,2,opt,name=agent_id,json=agentId,proto3" json:"agent_id,omitempty"` + AccessToken string `protobuf:"bytes,3,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` unknownFields protoimpl.UnknownFields - - Status string `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` - AgentId int64 `protobuf:"varint,2,opt,name=agent_id,json=agentId,proto3" json:"agent_id,omitempty"` - AccessToken string `protobuf:"bytes,3,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"` + sizeCache protoimpl.SizeCache } func (x *AuthResponse) Reset() { diff --git a/server/api/badge.go b/server/api/badge.go index a06fd8bb2..e39dcffe1 100644 --- a/server/api/badge.go +++ b/server/api/badge.go @@ -72,7 +72,7 @@ func GetBadge(c *gin.Context) { branch = repo.Branch } - pipeline, err := _store.GetPipelineLast(repo, branch) + pipeline, err := _store.GetPipelineBadge(repo, branch) if err != nil { if !errors.Is(err, types.RecordNotExist) { log.Warn().Err(err).Msg("could not get last pipeline for badge") diff --git a/server/forge/mocks/forge.go b/server/forge/mocks/forge.go index 3deb6b960..9bc45855c 100644 --- a/server/forge/mocks/forge.go +++ b/server/forge/mocks/forge.go @@ -282,7 +282,7 @@ func (_m *Forge) Login(ctx context.Context, r *types.OAuthRequest) (*model.User, return r0, r1, r2 } -// Name provides a mock function with given fields: +// Name provides a mock function with no fields func (_m *Forge) Name() string { ret := _m.Called() @@ -528,7 +528,7 @@ func (_m *Forge) Teams(ctx context.Context, u *model.User) ([]*model.Team, error return r0, r1 } -// URL provides a mock function with given fields: +// URL provides a mock function with no fields func (_m *Forge) URL() string { ret := _m.Called() diff --git a/server/queue/mocks/queue.go b/server/queue/mocks/queue.go index ad8686971..d56f19d5e 100644 --- a/server/queue/mocks/queue.go +++ b/server/queue/mocks/queue.go @@ -150,7 +150,7 @@ func (_m *Queue) KickAgentWorkers(agentID int64) { _m.Called(agentID) } -// Pause provides a mock function with given fields: +// Pause provides a mock function with no fields func (_m *Queue) Pause() { _m.Called() } @@ -221,7 +221,7 @@ func (_m *Queue) PushAtOnce(c context.Context, tasks []*model.Task) error { return r0 } -// Resume provides a mock function with given fields: +// Resume provides a mock function with no fields func (_m *Queue) Resume() { _m.Called() } diff --git a/server/services/mocks/manager.go b/server/services/mocks/manager.go index 1d94cdec8..df1000ca6 100644 --- a/server/services/mocks/manager.go +++ b/server/services/mocks/manager.go @@ -48,7 +48,7 @@ func (_m *Manager) ConfigServiceFromRepo(repo *model.Repo) config.Service { return r0 } -// EnvironmentService provides a mock function with given fields: +// EnvironmentService provides a mock function with no fields func (_m *Manager) EnvironmentService() environment.Service { ret := _m.Called() @@ -158,7 +158,7 @@ func (_m *Manager) ForgeFromUser(user *model.User) (forge.Forge, error) { return r0, r1 } -// RegistryService provides a mock function with given fields: +// RegistryService provides a mock function with no fields func (_m *Manager) RegistryService() registry.Service { ret := _m.Called() @@ -198,7 +198,7 @@ func (_m *Manager) RegistryServiceFromRepo(repo *model.Repo) registry.Service { return r0 } -// SecretService provides a mock function with given fields: +// SecretService provides a mock function with no fields func (_m *Manager) SecretService() secret.Service { ret := _m.Called() @@ -238,7 +238,7 @@ func (_m *Manager) SecretServiceFromRepo(repo *model.Repo) secret.Service { return r0 } -// SignaturePublicKey provides a mock function with given fields: +// SignaturePublicKey provides a mock function with no fields func (_m *Manager) SignaturePublicKey() crypto.PublicKey { ret := _m.Called() diff --git a/server/store/datastore/pipeline.go b/server/store/datastore/pipeline.go index 9a32bf482..a22ff4834 100644 --- a/server/store/datastore/pipeline.go +++ b/server/store/datastore/pipeline.go @@ -35,6 +35,15 @@ func (s storage) GetPipelineNumber(repo *model.Repo, num int64) (*model.Pipeline ).Get(pipeline)) } +func (s storage) GetPipelineBadge(repo *model.Repo, branch string) (*model.Pipeline, error) { + pipeline := new(model.Pipeline) + return pipeline, wrapGet(s.engine. + Desc("number"). + Where(builder.Eq{"repo_id": repo.ID, "branch": branch, "event": model.EventPush}). + Where(builder.Neq{"status": model.StatusBlocked}). + Get(pipeline)) +} + func (s storage) GetPipelineLast(repo *model.Repo, branch string) (*model.Pipeline, error) { pipeline := new(model.Pipeline) return pipeline, wrapGet(s.engine. diff --git a/server/store/mocks/store.go b/server/store/mocks/store.go index 3b778395c..ff50ab0f5 100644 --- a/server/store/mocks/store.go +++ b/server/store/mocks/store.go @@ -191,7 +191,7 @@ func (_m *Store) AgentUpdate(_a0 *model.Agent) error { return r0 } -// Close provides a mock function with given fields: +// Close provides a mock function with no fields func (_m *Store) Close() error { ret := _m.Called() @@ -748,7 +748,37 @@ func (_m *Store) GetPipeline(_a0 int64) (*model.Pipeline, error) { return r0, r1 } -// GetPipelineCount provides a mock function with given fields: +// GetPipelineBadge provides a mock function with given fields: _a0, _a1 +func (_m *Store) GetPipelineBadge(_a0 *model.Repo, _a1 string) (*model.Pipeline, error) { + ret := _m.Called(_a0, _a1) + + if len(ret) == 0 { + panic("no return value specified for GetPipelineBadge") + } + + var r0 *model.Pipeline + var r1 error + if rf, ok := ret.Get(0).(func(*model.Repo, string) (*model.Pipeline, error)); ok { + return rf(_a0, _a1) + } + if rf, ok := ret.Get(0).(func(*model.Repo, string) *model.Pipeline); ok { + r0 = rf(_a0, _a1) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*model.Pipeline) + } + } + + if rf, ok := ret.Get(1).(func(*model.Repo, string) error); ok { + r1 = rf(_a0, _a1) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetPipelineCount provides a mock function with no fields func (_m *Store) GetPipelineCount() (int64, error) { ret := _m.Called() @@ -896,7 +926,7 @@ func (_m *Store) GetPipelineNumber(_a0 *model.Repo, _a1 int64) (*model.Pipeline, return r0, r1 } -// GetPipelineQueue provides a mock function with given fields: +// GetPipelineQueue provides a mock function with no fields func (_m *Store) GetPipelineQueue() ([]*model.Feed, error) { ret := _m.Called() @@ -956,7 +986,7 @@ func (_m *Store) GetRepo(_a0 int64) (*model.Repo, error) { return r0, r1 } -// GetRepoCount provides a mock function with given fields: +// GetRepoCount provides a mock function with no fields func (_m *Store) GetRepoCount() (int64, error) { ret := _m.Called() @@ -1104,7 +1134,7 @@ func (_m *Store) GetUser(_a0 int64) (*model.User, error) { return r0, r1 } -// GetUserCount provides a mock function with given fields: +// GetUserCount provides a mock function with no fields func (_m *Store) GetUserCount() (int64, error) { ret := _m.Called() @@ -1796,7 +1826,7 @@ func (_m *Store) PermUpsert(perm *model.Perm) error { return r0 } -// Ping provides a mock function with given fields: +// Ping provides a mock function with no fields func (_m *Store) Ping() error { ret := _m.Called() @@ -1928,7 +1958,7 @@ func (_m *Store) RegistryList(_a0 *model.Repo, _a1 bool, _a2 *model.ListOptions) return r0, r1 } -// RegistryListAll provides a mock function with given fields: +// RegistryListAll provides a mock function with no fields func (_m *Store) RegistryListAll() ([]*model.Registry, error) { ret := _m.Called() @@ -2162,7 +2192,7 @@ func (_m *Store) SecretList(_a0 *model.Repo, _a1 bool, _a2 *model.ListOptions) ( return r0, r1 } -// SecretListAll provides a mock function with given fields: +// SecretListAll provides a mock function with no fields func (_m *Store) SecretListAll() ([]*model.Secret, error) { ret := _m.Called() @@ -2508,7 +2538,7 @@ func (_m *Store) TaskInsert(_a0 *model.Task) error { return r0 } -// TaskList provides a mock function with given fields: +// TaskList provides a mock function with no fields func (_m *Store) TaskList() ([]*model.Task, error) { ret := _m.Called() diff --git a/server/store/store.go b/server/store/store.go index a3503e386..5618deb9a 100644 --- a/server/store/store.go +++ b/server/store/store.go @@ -72,6 +72,8 @@ type Store interface { GetPipeline(int64) (*model.Pipeline, error) // GetPipelineNumber gets a pipeline by number. GetPipelineNumber(*model.Repo, int64) (*model.Pipeline, error) + // GetPipelineBadge gets the last relevant pipeline for the badge. + GetPipelineBadge(*model.Repo, string) (*model.Pipeline, error) // GetPipelineLast gets the last pipeline for the branch. GetPipelineLast(*model.Repo, string) (*model.Pipeline, error) // GetPipelineLastBefore gets the last pipeline before pipeline number N. diff --git a/woodpecker-go/woodpecker/mocks/client.go b/woodpecker-go/woodpecker/mocks/client.go index 0a2e72f87..97313d34f 100644 --- a/woodpecker-go/woodpecker/mocks/client.go +++ b/woodpecker-go/woodpecker/mocks/client.go @@ -95,7 +95,7 @@ func (_m *Client) AgentDelete(_a0 int64) error { return r0 } -// AgentList provides a mock function with given fields: +// AgentList provides a mock function with no fields func (_m *Client) AgentList() ([]*woodpecker.Agent, error) { ret := _m.Called() @@ -629,7 +629,7 @@ func (_m *Client) GlobalSecretUpdate(secret *woodpecker.Secret) (*woodpecker.Sec return r0, r1 } -// LogLevel provides a mock function with given fields: +// LogLevel provides a mock function with no fields func (_m *Client) LogLevel() (*woodpecker.LogLevel, error) { ret := _m.Called() @@ -1241,7 +1241,7 @@ func (_m *Client) PipelineMetadata(repoID int64, pipelineNumber int) ([]byte, er return r0, r1 } -// PipelineQueue provides a mock function with given fields: +// PipelineQueue provides a mock function with no fields func (_m *Client) PipelineQueue() ([]*woodpecker.Feed, error) { ret := _m.Called() @@ -1319,7 +1319,7 @@ func (_m *Client) PipelineStop(repoID int64, pipeline int64) error { return r0 } -// QueueInfo provides a mock function with given fields: +// QueueInfo provides a mock function with no fields func (_m *Client) QueueInfo() (*woodpecker.Info, error) { ret := _m.Called() @@ -1859,7 +1859,7 @@ func (_m *Client) SecretUpdate(repoID int64, secret *woodpecker.Secret) (*woodpe return r0, r1 } -// Self provides a mock function with given fields: +// Self provides a mock function with no fields func (_m *Client) Self() (*woodpecker.User, error) { ret := _m.Called()