good morning!!!!

Skip to content
Snippets Groups Projects
.gitlab-ci.yml 1.65 KiB
Newer Older
a's avatar
a committed
.go-cache:
  variables:
    GOPATH: $CI_PROJECT_DIR/.go
  before_script:
    - mkdir -p .go
  cache:
    paths:
      - .go/pkg/mod/

stages:
  - test

a's avatar
ok  
a committed
test:
a's avatar
a committed
  image: golang:1.21-alpine
a's avatar
a committed
  stage: test
  extends: .go-cache
  script:
a's avatar
a committed
    - CGO_ENABLED=1 go test -race ./...
a's avatar
a committed
    - apk add alpine-sdk
a's avatar
a committed

lint:
  image: registry.gitlab.com/gitlab-org/gitlab-build-images:golangci-lint-alpine
a's avatar
ok  
a committed
  stage: test
a's avatar
a committed
  extends: .go-cache
  script:
    # Use default .golangci.yml file from the image if one is not present in the project root.
    - "[ -e .golangci.yml ] || cp /golangci/.golangci.yml ."
    # Write the code coverage report to gl-code-quality-report.json
    # and print linting issues to stdout in the format: path/to/file:line description
    # remove `--issues-exit-code 0` or set to non-zero to fail the job if linting issues are detected
    - golangci-lint run --issues-exit-code 0 --print-issued-lines=false --out-format code-climate:gl-code-quality-report.json,line-number
  artifacts:
    when: always
    reports:
      codequality: gl-code-quality-report.json
    paths:
      - gl-code-quality-report.json

coverage:
  stage: test
a's avatar
a committed
  image: golang:1.21-alpine
a's avatar
a committed
  coverage: '/\(statements\)(?:\s+)?(\d+(?:\.\d+)?%)/'
  extends: .go-cache
  script:
    - go run gotest.tools/gotestsum@latest --junitfile report.xml --format testname -- -coverprofile=coverage.txt -covermode count ./...
a's avatar
a committed
    - sed -i '/jrpctest/d' coverage.txt
a's avatar
a committed
    - go tool cover -func=coverage.txt
    - go run github.com/boumenot/gocover-cobertura@master < coverage.txt > coverage.xml
  artifacts:
    reports:
      junit: report.xml
      coverage_report:
        coverage_format: cobertura
        path: coverage.xml