Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint go code with cspell #3706

Merged
merged 31 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
361ccb1
cspell lint cmd
6543 May 14, 2024
0923e8d
cspell more
6543 May 14, 2024
8b97aa4
more
6543 May 14, 2024
bacf087
cspell more linting
6543 May 14, 2024
d05ccce
more
6543 May 14, 2024
2ba0954
more
6543 May 14, 2024
50f9ac3
more
6543 May 14, 2024
7f882df
more
6543 May 14, 2024
75b6a03
bindata not needed
6543 May 14, 2024
8e6d4ea
no space
6543 May 14, 2024
d66b3b7
more
6543 May 14, 2024
8059e65
finish for now
6543 May 14, 2024
17e52d7
fix yamllint
6543 May 14, 2024
f963c2c
prettier
6543 May 14, 2024
d342ea5
Merge branch 'main' into cspell_more-dictionaries
6543 May 14, 2024
7c73994
Merge branch 'main' into cspell_more-dictionaries
6543 May 23, 2024
b904033
test
6543 May 23, 2024
3e377bf
golang imports should be ignored
6543 May 23, 2024
78dfcc6
fix last package name issues
6543 May 23, 2024
cf85493
fix
6543 May 23, 2024
ba362df
Merge branch 'main' into cspell_more-dictionaries
6543 May 23, 2024
d750df6
Merge branch 'main' into cspell_more-dictionaries
6543 May 24, 2024
6d2447b
Add pwsh to cspell words
6543 May 24, 2024
2664e07
cleanup missed one
6543 May 24, 2024
7a991f4
cleanup missed one (2)
6543 May 24, 2024
fde537c
docker images from docker.io are also just strings
6543 May 24, 2024
6b5e910
fix missed one
6543 May 24, 2024
c8ffe8f
use "-" instead of "_" as its used on all other woodpecker conf to na…
6543 May 24, 2024
f799eec
Merge branch 'main' into cspell_more-dictionaries
6543 May 24, 2024
753564e
fix
6543 May 24, 2024
fcf5c62
exclude testdata and fixtures
6543 May 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 55 additions & 8 deletions .cspell.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
{
"version": "0.2",
"language": "en",
"dictionaries": [
// language
"en_us",
// code
"go",
"node",
// package names
"npm"
],
"words": [
"abool",
"BUILDPLATFORM",
"Codeberg",
"Curr",
Expand All @@ -21,47 +31,55 @@
"Ionescu",
"Kaniko",
"Keyfunc",
"LASTEXITCODE",
"Laszlo",
"Msgf",
"Netrc",
"PROTOC",
"Pinia",
"Println",
"pwsh",
"Refspec",
"Reviewdog",
"Rydzewski",
"SSHURL",
"TARGETARCH",
"TARGETOS",
"Typeflag",
"Upsert",
"WORKDIR",
"Warnf",
"Weblate",
"Wrapf",
"anbraten",
"apimachinery",
"autoincr",
"autoscaler",
"binutils",
"bitbucketdatacenter",
"bradrydzewski",
"brightbox",
"buildx",
"ccmenu",
"charmbracelet",
"ciphertext",
"compatiblelicenses",
"corepack",
"cpuset",
"creativecommons",
"datacenter",
"desaturate",
"devx",
"doublestar",
"envsubst",
"estree",
"errgroup",
"evenodd",
"excalidraw",
"favicons",
"forbidigo",
"fsnotify",
"gitea",
"gocritic",
"golangci",
"gomod",
"gonic",
Expand All @@ -73,7 +91,10 @@
"laszlocph",
"logfile",
"loglevel",
"mapstructure",
"markdownlint",
"memswap",
"moby",
"multiarch",
"multierr",
"netdns",
Expand All @@ -86,24 +107,37 @@
"ppid",
"prismjs",
"proto",
"protobuf",
"protoc",
"protoimpl",
"protoreflect",
"rawurl",
"regcred",
"repology",
"reslimit",
"riscv",
"rundll32",
"seccomp",
"secprofile",
"securecookie",
"sess",
"shellescape",
"stepbuilder",
"stretchr",
"sublicensable",
"swaggo",
"techknowlogick",
"testdata",
"tink",
"tinycolor",
"tmpfs",
"tmpl",
"tolerations",
"ttlcache",
"typecheck",
"unplugin",
"urfave",
"varchar",
"vite",
"vitejs",
"vueuse",
"waivable",
"windi",
Expand All @@ -112,13 +146,15 @@
"xlog",
"xorm",
"xormigrate",
"xyaml",
"zerolog",
"zerologger"
],
"ignorePaths": [
"**/node_modules/**/*",
"*.excalidraw",
"*.svg",
"*_test.go",
".cspell.json",
".git/**/*",
".gitignore",
Expand All @@ -130,18 +166,29 @@
"flake.nix",
"go.mod",
"go.sum",
"pipeline/rpc/proto/woodpecker.pb.go",
"pnpm-lock.yaml",
"server/store/datastore/migration/**/*",
"web/components.d.ts",
"web/src/assets/locales/**/*",
"**/fixtures/**",
"**/testdata/**",
// TODO: remove the following
".woodpecker/",
"agent/",
"cli/",
"cmd/",
"docs/",
"pipeline/",
"server/"
],
// Exclude imports, because they are also strings.
"ignoreRegExpList": [
// ignore mulltiline imports
"import\\s*\\((.|[\r\n])*?\\)",
// ignore single line imports
"import\\s*.*\".*?\"",
// ignore go generate directive
"//\\s*go:generate.*",
// ignore nolint directive
"//\\s*nolint:.*",
// ignore docker image names
"\\s*docker\\.io/.*"
],
"enableFiletypes": ["dockercompose"]
}
2 changes: 2 additions & 0 deletions .woodpecker/binaries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ variables:
- &node_image 'docker.io/node:22-alpine'
- &xgo_image 'docker.io/techknowlogick/xgo:go-1.22.x'

# cspell:words bindata netgo TARGZ

steps:
build-web:
image: *node_image
Expand Down
6 changes: 4 additions & 2 deletions .woodpecker/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ variables:
- &platforms_alpine 'linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le'
- &build_args 'CI_COMMIT_SHA=${CI_COMMIT_SHA},CI_COMMIT_BRANCH=${CI_COMMIT_BRANCH},CI_COMMIT_TAG=${CI_COMMIT_TAG}'

# cspell:words woodpeckerbot netgo TARGZ

# vars used on push / tag events only
- publish_logins: &publish_logins # Default DockerHub login
- registry: https://index.docker.io/v1/
Expand Down Expand Up @@ -96,7 +98,7 @@ steps:
- make cross-compile-server
environment:
PLATFORMS: linux|amd64
TAGS: bindata sqlite sqlite_unlock_notify netgo
TAGS: sqlite sqlite_unlock_notify netgo
when:
- event: pull_request
evaluate: 'CI_COMMIT_PULL_REQUEST_LABELS contains "build_pr_images"'
Expand All @@ -118,7 +120,7 @@ steps:
- make cross-compile-server
environment:
PLATFORMS: linux|arm/v7;linux|arm64/v8;linux|amd64;linux|ppc64le;linux|riscv64
TAGS: bindata sqlite sqlite_unlock_notify netgo
TAGS: sqlite sqlite_unlock_notify netgo
when:
branch:
- ${CI_REPO_DEFAULT_BRANCH}
Expand Down
5 changes: 2 additions & 3 deletions .woodpecker/securityscan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ when:
- renovate/*

variables:
- &trivy_image aquasec/trivy:0.46.1
- &trivy_plugin woodpeckerci/plugin-trivy:1.0.1
- &trivy_plugin docker.io/woodpeckerci/plugin-trivy:1.0.1

steps:
backend:
Expand All @@ -22,7 +21,7 @@ steps:
settings:
skip-dirs: node_modules/,plugins/woodpecker-plugins/node_modules/
dir: docs/
# well we should check it, but we can not do much about old deps if docusaurus do not take that serously
# well we should check it, but we can not do much about old deps if docusaurus do not take that seriously
# but this is not an issue as we just generate a static site anyway ...
failure: ignore

Expand Down
5 changes: 3 additions & 2 deletions .woodpecker/static.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ steps:
commands:
- corepack enable
- pnpx cspell lint --no-progress --gitignore '{**,.*}/{*,.*}'
- apk add --no-cache -U tree # busybox tree dont understand "-I"
- apk add --no-cache -U tree # busybox tree don't understand "-I"
# cspell:disable-next-line
- tree --gitignore -I 012_columns_rename_procs_to_steps.go -I versioned_docs -I '*opensource.svg'| pnpx cspell lint --no-progress stdin

- name: prettier
Expand All @@ -28,7 +29,7 @@ steps:
version: 3.2.5

- name: links
image: lycheeverse/lychee:0.14.3
image: docker.io/lycheeverse/lychee:0.14.3
depends_on: []
commands:
- lychee pipeline/frontend/yaml/linter/schema/schema.json
Expand Down
4 changes: 2 additions & 2 deletions .woodpecker/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ steps:
lint-license-header:
image: *golang_image
commands:
- go install github.com/google/addlicense@latest
- go install github.com/google/addlicense@latest # cspell:words addlicense
xoxys marked this conversation as resolved.
Show resolved Hide resolved
- 'addlicense -check -ignore "vendor/**" **/*.go'
when: *when

Expand Down Expand Up @@ -107,7 +107,7 @@ steps:
image: *golang_image
environment:
WOODPECKER_DATABASE_DRIVER: postgres
WOODPECKER_DATABASE_DATASOURCE: 'host=postgres user=postgres dbname=postgres sslmode=disable'
WOODPECKER_DATABASE_DATASOURCE: 'host=postgres user=postgres dbname=postgres sslmode=disable' # cspell:disable-line
commands:
- make test-server-datastore
when: *when
Expand Down
2 changes: 1 addition & 1 deletion .woodpecker/web.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ steps:
- pnpm lint
when: *when

formatcheck:
format-check:
depends_on:
- install-dependencies
image: *node_image
Expand Down
6 changes: 3 additions & 3 deletions agent/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

func (r *Runner) createLogger(logger zerolog.Logger, uploads *sync.WaitGroup, workflow *rpc.Workflow) pipeline.Logger {
return func(step *backend.Step, rc io.Reader) error {
loglogger := logger.With().
logLogger := logger.With().
Str("image", step.Image).
Str("workflowID", workflow.ID).
Logger()
Expand All @@ -40,14 +40,14 @@ func (r *Runner) createLogger(logger zerolog.Logger, uploads *sync.WaitGroup, wo
secrets = append(secrets, secret.Value)
}

loglogger.Debug().Msg("log stream opened")
logLogger.Debug().Msg("log stream opened")

logStream := rpc.NewLineWriter(r.client, step.UUID, secrets...)
if _, err := io.Copy(logStream, rc); err != nil {
log.Error().Err(err).Msg("copy limited logStream part")
}

loglogger.Debug().Msg("log stream copied, close ...")
logLogger.Debug().Msg("log stream copied, close ...")
uploads.Done()

return nil
Expand Down
10 changes: 5 additions & 5 deletions agent/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (r *Runner) Run(runnerCtx context.Context) error { //nolint:contextcheck
log.Debug().Msg("request next execution")

meta, _ := metadata.FromOutgoingContext(runnerCtx)
ctxmeta := metadata.NewOutgoingContext(context.Background(), meta)
ctxMeta := metadata.NewOutgoingContext(context.Background(), meta)

// get the next workflow from the queue
work, err := r.client.Next(runnerCtx, r.filter)
Expand Down Expand Up @@ -89,7 +89,7 @@ func (r *Runner) Run(runnerCtx context.Context) error { //nolint:contextcheck

logger.Debug().Msg("received execution")

workflowCtx, cancel := context.WithTimeout(ctxmeta, timeout)
workflowCtx, cancel := context.WithTimeout(ctxMeta, timeout)
defer cancel()

// Add sigterm support for internal context.
Expand All @@ -103,9 +103,9 @@ func (r *Runner) Run(runnerCtx context.Context) error { //nolint:contextcheck
go func() {
logger.Debug().Msg("listen for cancel signal")

if werr := r.client.Wait(workflowCtx, work.ID); werr != nil {
if err := r.client.Wait(workflowCtx, work.ID); err != nil {
canceled.SetTo(true)
logger.Warn().Err(werr).Msg("cancel signal received")
logger.Warn().Err(err).Msg("cancel signal received")

cancel()
} else {
Expand Down Expand Up @@ -144,7 +144,7 @@ func (r *Runner) Run(runnerCtx context.Context) error { //nolint:contextcheck
pipeline.WithContext(workflowCtx),
pipeline.WithTaskUUID(fmt.Sprint(work.ID)),
pipeline.WithLogger(r.createLogger(logger, &uploads, work)),
pipeline.WithTracer(r.createTracer(ctxmeta, logger, work)),
pipeline.WithTracer(r.createTracer(ctxMeta, logger, work)),
pipeline.WithBackend(*r.backend),
pipeline.WithDescription(map[string]string{
"ID": work.ID,
Expand Down
14 changes: 7 additions & 7 deletions agent/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import (
"go.woodpecker-ci.org/woodpecker/v2/pipeline/rpc"
)

func (r *Runner) createTracer(ctxmeta context.Context, logger zerolog.Logger, workflow *rpc.Workflow) 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().
stepLogger := logger.With().
Str("image", state.Pipeline.Step.Image).
Str("workflowID", workflow.ID).
Err(state.Process.Error).
Expand All @@ -48,15 +48,15 @@ func (r *Runner) createTracer(ctxmeta context.Context, logger zerolog.Logger, wo
}

defer func() {
steplogger.Debug().Msg("update step status")
stepLogger.Debug().Msg("update step status")

if uerr := r.client.Update(ctxmeta, workflow.ID, stepState); uerr != nil {
steplogger.Debug().
Err(uerr).
if err := r.client.Update(ctxMeta, workflow.ID, stepState); err != nil {
stepLogger.Debug().
Err(err).
Msg("update step status error")
}

steplogger.Debug().Msg("update step status complete")
stepLogger.Debug().Msg("update step status complete")
}()
if state.Process.Exited {
return nil
Expand Down
6 changes: 3 additions & 3 deletions cli/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ func deploy(c *cli.Context) error {
var number int64
if pipelineArg == "last" {
// Fetch the pipeline number from the last pipeline
pipelines, berr := client.PipelineList(repoID)
if berr != nil {
return berr
pipelines, err := client.PipelineList(repoID)
if err != nil {
return err
}
for _, pipeline := range pipelines {
if branch != "" && pipeline.Branch != branch {
Expand Down
Loading