Skip to content

Cache not lowering lint time in ci/cd #4220

@asaid997

Description

@asaid997

Welcome

Description of the problem

We are using gitlab ci/cd caching system to store the cache files in GCS and basically the issue is that once we download those cache files in a new pipeline run and setup the env as mentioned in the document we would expect the run to drop from 1+ mins to 5-10 seconds which is what happens when we run the lint command two times in a row

gitlab ci/cd job:

lint-test:
  image: golang:bullseye
  cache:
    key: one-key-to-rule-them-all
    paths:
      - $CI_PROJECT_DIR/go_cache
  script:
    - export GOLANGCI_LINT_CACHE=$CI_PROJECT_DIR/go_cache
    - time golangci-lint run --timeout 5m0s
    - time golangci-lint run --timeout 5m0s

when downloading the file directly from GCS -> unzipping it and then running locally its also takes the full time while a second run right away takes 5-10 seconds

Version of golangci-lint

golangci-lint has version 1.52.2 built with go1.20.2 from da04413 on 2023-03-25T18:11:28Z

Configuration

Go environment

go version go1.21.4 linux/amd64
----
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.4'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/builds/imubit-dlpc/task-force/model-analysis-service/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build[332](https://imugit.imubit.com/imubit-dlpc/task-force/model-analysis-service/-/jobs/2573828#L332)0886986=/tmp/go-build -gno-record-gcc-switches'

Verbose output of running

$ golangci-lint run -v
level=info msg="[config_reader] Config search paths: [./ /builds/imubit-dlpc/task-force/model-analysis-service /builds/imubit-dlpc/task-force /builds/imubit-dlpc /builds / /root]"
level=info msg="[config_reader] Used config file .golangci.yml"
level=info msg="[lintersdb] Active 17 linters: [bidichk bodyclose durationcheck errcheck exhaustive gocheckcompilerdirectives gofmt goimports gosimple govet ineffassign makezero musttag nilerr nosprintfhostport staticcheck unused]"
level=info msg="[loader] Go packages loading at mode 575 (deps|exports_file|name|types_sizes|compiled_files|files|imports) took 1m22.003416453s"
level=info msg="[runner/filename_unadjuster] Pre-built 0 adjustments in 118.555446ms"
level=info msg="[linters_context/goanalysis] analyzers took 0s with no stages"
level=info msg="[runner] Issues before processing: 8, after processing: 0"
level=info msg="[runner] Processors filtering stat (out/in): filename_unadjuster: 8/8, skip_dirs: 8/8, nolint: 0/2, path_prettifier: 8/8, identifier_marker: 8/8, cgo: 8/8, skip_files: 8/8, autogenerated_exclude: 8/8, exclude: 8/8, exclude-rules: 2/8"
level=info msg="[runner] processing took 2.112805ms with stages: nolint: 1.034808ms, path_prettifier: 304.231µs, autogenerated_exclude: 249.507µs, identifier_marker: 241.971µs, exclude-rules: 142.435µs, skip_dirs: 125.316µs, cgo: 4.835µs, filename_unadjuster: 2.581µs, max_same_issues: 1.289µs, fixer: 947ns, skip_files: 812ns, exclude: 749ns, source_code: 548ns, sort_results: 509ns, severity-rules: 471ns, uniq_by_line: 454ns, diff: 419ns, max_from_linter: 319ns, path_shortener: 270ns, path_prefixer: 180ns, max_per_file_from_linter: 154ns"
level=info msg="[runner] linters took 924.748704ms with stages: goanalysis_metalinter: 921.88422ms"
level=info msg="File cache stats: 0 entries of total size 0B"
level=info msg="Memory: 832 samples, avg is 27.0MB, max is 68.1MB"
level=info msg="Execution took 1m23.057849994s"

A minimal reproducible example or link to a public repository

its a private repo and there is no specific piece of code that i can attach here as the issue is with the caching mechanism

if there is still a need ill try and provide more info

Validation

  • Yes, I've included all information above (version, config, etc.).

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions