Skip to content

Commit

Permalink
Merge branch 'woodpecker-ci:main' into 1541-secret-encryption-2
Browse files Browse the repository at this point in the history
  • Loading branch information
zc-devs authored Sep 24, 2023
2 parents bead27c + f8e91f0 commit f555fa1
Show file tree
Hide file tree
Showing 185 changed files with 5,779 additions and 3,541 deletions.
40 changes: 40 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:recommended", ":maintainLockFilesWeekly"],
"prConcurrentLimit": 5,
"packageRules": [
{
"matchManagers": ["docker-compose"],
"matchFileNames": ["docker-compose.gitpod.yml"],
"labels": ["devx"]
},
{
"matchManagers": ["gomod", "npm", "dockerfile"],
"labels": ["dependencies"]
},
{
"matchManagers": ["woodpecker"],
"labels": ["build"]
},
{
"groupName": "golang deps non-major",
"matchManagers": ["gomod"],
"matchUpdateTypes": ["minor", "patch"],
"extends": ["schedule:daily"]
},
{
"groupName": "web npm deps non-major",
"matchManagers": ["npm"],
"matchUpdateTypes": ["minor", "patch"],
"matchFileNames": ["web/package.json"],
"extends": ["schedule:daily"]
},
{
"groupName": "docs npm deps non-major",
"matchManagers": ["npm"],
"matchUpdateTypes": ["minor", "patch"],
"matchFileNames": ["docs/**/package.json"],
"extends": ["schedule:daily"]
}
]
}
4 changes: 2 additions & 2 deletions .woodpecker/binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ when:
event: tag

variables:
- &golang_image 'golang:1.20.2'
- &node_image 'node:18-alpine'
- &golang_image 'golang:1.21.1'
- &node_image 'node:20-alpine'
- &xgo_image 'techknowlogick/xgo:go-1.20.2'
- &xgo_version 'go-1.20.2'

Expand Down
4 changes: 2 additions & 2 deletions .woodpecker/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ depends_on:
- web

variables:
- &golang_image 'golang:1.20.2'
- &node_image 'node:18-alpine'
- &golang_image 'golang:1.21.1'
- &node_image 'node:20-alpine'
- &xgo_image 'techknowlogick/xgo:go-1.20.2'
- &xgo_version 'go-1.20.2'
- &platforms_release 'linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/386,linux/amd64,linux/ppc64le,linux/riscv64,linux/s390x,freebsd/arm64,freebsd/amd64,openbsd/arm64,openbsd/amd64'
Expand Down
4 changes: 2 additions & 2 deletions .woodpecker/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ when:
event: cron

variables:
- &golang_image 'golang:1.20.2'
- &node_image 'node:18-alpine'
- &golang_image 'golang:1.21.1'
- &node_image 'node:20-alpine'

steps:
build-cli:
Expand Down
14 changes: 14 additions & 0 deletions .woodpecker/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
steps:
release:
image: woodpeckerci/plugin-ready-release-go
pull: true
settings:
release_branch: ${CI_REPO_DEFAULT_BRANCH}
forge_type: github
git_email: woodpecker-bot@obermui.de
github_token:
from_secret: GITHUB_TOKEN

when:
event: push
branch: ${CI_REPO_DEFAULT_BRANCH}
2 changes: 1 addition & 1 deletion .woodpecker/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ when:
- release/*

variables:
- &golang_image 'golang:1.20.2'
- &golang_image 'golang:1.21.1'
- &when
- path: &when_path
# related config files
Expand Down
2 changes: 1 addition & 1 deletion .woodpecker/web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ when:
- release/*

variables:
- &node_image 'node:18-alpine'
- &node_image 'node:20-alpine'
- &when
path:
# related config files
Expand Down
17 changes: 8 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GO_PACKAGES ?= $(shell go list ./... | grep -v /vendor/)

TARGETOS ?= linux
TARGETARCH ?= amd64
TARGETOS ?= $(shell go env GOOS)
TARGETARCH ?= $(shell go env GOARCH)

BIN_SUFFIX :=
ifeq ($(TARGETOS),windows)
Expand All @@ -14,20 +14,20 @@ CI_COMMIT_SHA ?= $(shell git rev-parse HEAD)

# it's a tagged release
ifneq ($(CI_COMMIT_TAG),)
BUILD_VERSION := $(CI_COMMIT_TAG:v%=%)
VERSION := $(CI_COMMIT_TAG:v%=%)
VERSION_NUMBER := ${CI_COMMIT_TAG:v%=%}
else
# append commit-sha to next version
ifeq ($(VERSION),next)
BUILD_VERSION := $(shell echo "next-$(shell echo ${CI_COMMIT_SHA} | cut -c -10)")
VERSION := $(shell echo "next-$(shell echo ${CI_COMMIT_SHA} | cut -c -10)")
endif
# append commit-sha to release branch version
ifeq ($(shell echo ${CI_COMMIT_BRANCH} | cut -c -9),release/v)
BUILD_VERSION := $(shell echo "$(shell echo ${CI_COMMIT_BRANCH} | cut -c 10-)-$(shell echo ${CI_COMMIT_SHA} | cut -c -10)")
VERSION := $(shell echo "$(shell echo ${CI_COMMIT_BRANCH} | cut -c 10-)-$(shell echo ${CI_COMMIT_SHA} | cut -c -10)")
endif
endif

LDFLAGS := -s -w -extldflags "-static" -X github.com/woodpecker-ci/woodpecker/version.Version=${BUILD_VERSION}
LDFLAGS := -s -w -extldflags "-static" -X github.com/woodpecker-ci/woodpecker/version.Version=${VERSION}
CGO_ENABLED ?= 1 # only used to compile server

HAS_GO = $(shell hash go > /dev/null 2>&1 && echo "GO" || echo "NOGO" )
Expand All @@ -50,7 +50,6 @@ ifeq (in_docker,$(firstword $(MAKECMDGOALS)))
@docker run -it \
--user $(shell id -u):$(shell id -g) \
-e VERSION="$(VERSION)" \
-e BUILD_VERSION="$(BUILD_VERSION)" \
-e CI_COMMIT_SHA="$(CI_COMMIT_SHA)" \
-e TARGETOS="$(TARGETOS)" \
-e TARGETARCH="$(TARGETARCH)" \
Expand All @@ -68,7 +67,7 @@ all: help

.PHONY: version
version: ## Print the current version
@echo ${BUILD_VERSION}
@echo ${VERSION}

# The help target prints out all targets with their descriptions organized
# beneath their categories. The categories are represented by '##@' and the
Expand Down Expand Up @@ -139,7 +138,7 @@ ui-dependencies: ## Install UI dependencies
.PHONY: lint
lint: install-tools ## Lint code
@echo "Running golangci-lint"
golangci-lint run --timeout 10m
golangci-lint run --timeout 15m
@echo "Running zerolog linter"
lint github.com/woodpecker-ci/woodpecker/cmd/agent
lint github.com/woodpecker-ci/woodpecker/cmd/cli
Expand Down
4 changes: 2 additions & 2 deletions agent/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/woodpecker-ci/woodpecker/pipeline/rpc"
)

func (r *Runner) createLogger(logger zerolog.Logger, uploads *sync.WaitGroup, work *rpc.Pipeline) pipeline.LogFunc {
func (r *Runner) createLogger(logger zerolog.Logger, uploads *sync.WaitGroup, workflow *rpc.Workflow) pipeline.LogFunc {
return func(step *backend.Step, rc multipart.Reader) error {
loglogger := logger.With().
Str("image", step.Image).
Expand All @@ -41,7 +41,7 @@ func (r *Runner) createLogger(logger zerolog.Logger, uploads *sync.WaitGroup, wo
uploads.Add(1)

var secrets []string
for _, secret := range work.Config.Secrets {
for _, secret := range workflow.Config.Secrets {
if secret.Mask {
secrets = append(secrets, secret.Value)
}
Expand Down
2 changes: 1 addition & 1 deletion agent/rpc/auth_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (interceptor *AuthInterceptor) refreshToken() error {
}

interceptor.accessToken = accessToken
log.Trace().Str("token", accessToken).Msg("Token refreshed")
log.Trace().Msg("token refreshed")

return nil
}
32 changes: 16 additions & 16 deletions agent/rpc/client_grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ func (c *client) Version(ctx context.Context) (*rpc.Version, error) {
}, nil
}

// Next returns the next pipeline in the queue.
func (c *client) Next(ctx context.Context, f rpc.Filter) (*rpc.Pipeline, error) {
// Next returns the next workflow in the queue.
func (c *client) Next(ctx context.Context, f rpc.Filter) (*rpc.Workflow, error) {
var res *proto.NextResponse
var err error
retry := c.newBackOff()
Expand Down Expand Up @@ -111,21 +111,21 @@ func (c *client) Next(ctx context.Context, f rpc.Filter) (*rpc.Pipeline, error)
}
}

if res.GetPipeline() == nil {
if res.GetWorkflow() == nil {
return nil, nil
}

p := new(rpc.Pipeline)
p.ID = res.GetPipeline().GetId()
p.Timeout = res.GetPipeline().GetTimeout()
p.Config = new(backend.Config)
if err := json.Unmarshal(res.GetPipeline().GetPayload(), p.Config); err != nil {
log.Error().Err(err).Msgf("could not unmarshal pipeline config of '%s'", p.ID)
w := new(rpc.Workflow)
w.ID = res.GetWorkflow().GetId()
w.Timeout = res.GetWorkflow().GetTimeout()
w.Config = new(backend.Config)
if err := json.Unmarshal(res.GetWorkflow().GetPayload(), w.Config); err != nil {
log.Error().Err(err).Msgf("could not unmarshal workflow config of '%s'", w.ID)
}
return p, nil
return w, nil
}

// Wait blocks until the pipeline is complete.
// Wait blocks until the workflow is complete.
func (c *client) Wait(ctx context.Context, id string) (err error) {
retry := c.newBackOff()
req := new(proto.WaitRequest)
Expand Down Expand Up @@ -159,7 +159,7 @@ func (c *client) Wait(ctx context.Context, id string) (err error) {
return nil
}

// Init signals the pipeline is initialized.
// Init signals the workflow is initialized.
func (c *client) Init(ctx context.Context, id string, state rpc.State) (err error) {
retry := c.newBackOff()
req := new(proto.InitRequest)
Expand Down Expand Up @@ -200,7 +200,7 @@ func (c *client) Init(ctx context.Context, id string, state rpc.State) (err erro
return nil
}

// Done signals the pipeline is complete.
// Done signals the work is complete.
func (c *client) Done(ctx context.Context, id string, state rpc.State) (err error) {
retry := c.newBackOff()
req := new(proto.DoneRequest)
Expand Down Expand Up @@ -241,7 +241,7 @@ func (c *client) Done(ctx context.Context, id string, state rpc.State) (err erro
return nil
}

// Extend extends the pipeline deadline
// Extend extends the workflow deadline
func (c *client) Extend(ctx context.Context, id string) (err error) {
retry := c.newBackOff()
req := new(proto.ExtendRequest)
Expand Down Expand Up @@ -275,7 +275,7 @@ func (c *client) Extend(ctx context.Context, id string) (err error) {
return nil
}

// Update updates the pipeline state.
// Update updates the workflow state.
func (c *client) Update(ctx context.Context, id string, state rpc.State) (err error) {
retry := c.newBackOff()
req := new(proto.UpdateRequest)
Expand Down Expand Up @@ -316,7 +316,7 @@ func (c *client) Update(ctx context.Context, id string, state rpc.State) (err er
return nil
}

// Log writes the pipeline log entry.
// Log writes the workflow log entry.
func (c *client) Log(ctx context.Context, logEntry *rpc.LogEntry) (err error) {
retry := c.newBackOff()
req := new(proto.LogRequest)
Expand Down
2 changes: 1 addition & 1 deletion agent/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"time"

"github.com/rs/zerolog/log"
"github.com/tevino/abool"
"github.com/tevino/abool/v2"
"google.golang.org/grpc/metadata"

"github.com/woodpecker-ci/woodpecker/pipeline"
Expand Down
4 changes: 2 additions & 2 deletions agent/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/woodpecker-ci/woodpecker/pipeline/rpc"
)

func (r *Runner) createTracer(ctxmeta context.Context, logger zerolog.Logger, work *rpc.Pipeline) pipeline.TraceFunc {
func (r *Runner) createTracer(ctxmeta context.Context, logger zerolog.Logger, workflow *rpc.Workflow) pipeline.TraceFunc {
return func(state *pipeline.State) error {
steplogger := logger.With().
Str("image", state.Pipeline.Step.Image).
Expand All @@ -50,7 +50,7 @@ func (r *Runner) createTracer(ctxmeta context.Context, logger zerolog.Logger, wo
defer func() {
steplogger.Debug().Msg("update step status")

if uerr := r.client.Update(ctxmeta, work.ID, stepState); uerr != nil {
if uerr := r.client.Update(ctxmeta, workflow.ID, stepState); uerr != nil {
steplogger.Debug().
Err(uerr).
Msg("update step status error")
Expand Down
2 changes: 1 addition & 1 deletion cmd/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"time"

"github.com/rs/zerolog/log"
"github.com/tevino/abool"
"github.com/tevino/abool/v2"
"github.com/urfave/cli/v2"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
Expand Down
2 changes: 1 addition & 1 deletion cmd/common/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,5 @@ func SetupGlobalLogger(c *cli.Context) {
log.Logger = log.With().Caller().Logger()
}

log.Log().Msgf("LogLevel = %s", zerolog.GlobalLevel().String())
log.Info().Msgf("LogLevel = %s", zerolog.GlobalLevel().String())
}
Loading

0 comments on commit f555fa1

Please sign in to comment.