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

ci: update gitlab ci config #811

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Changes from all commits
Commits
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
52 changes: 26 additions & 26 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,57 @@ include:
- project: cloud/integrations/ci
file:
- default.yml
- workflows/feature-branches.yml

variables:
COVERAGE_FILE: .testCoverage.txt
GOMODCACHE: $CI_PROJECT_DIR/.cache/go-mod
GOCACHE: $CI_PROJECT_DIR/.cache/go-build

workflow:
rules:
- # Do not execute on main branch
if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: never
- # Do not execute on tag
if: $CI_COMMIT_TAG != null
when: never
- # Avoid duplicate pipelines in MRs
if: $CI_PIPELINE_SOURCE == 'merge_request_event'
when: never
- when: always
cache:
key:
files:
- go.mod
- go.sum
paths:
- $GOMODCACHE

test:golangci-lint:
build:
stage: build
image: golang:1.21
script:
- go env
- go mod download

test:lint:
stage: test
image: golangci/golangci-lint:v1.59.1
image: golangci/golangci-lint:v1.59
script:
- golangci-lint run -v

test:go-mod-tidy:
test:tidy:
stage: test
image: golang:1.21
script:
- go mod tidy -v
- git diff --exit-code

test:go-generate:
test:generate:
stage: test
image: golang:1.21
script:
- go generate ./...
- git diff --exit-code

test:tests:
test:unit:
stage: test
image: golang:1.21
script:
- |
go test -v \
-race \
-coverprofile=$COVERAGE_FILE \
./...
- go tool cover -func=$COVERAGE_FILE | tail -n1
- go run github.com/boumenot/gocover-cobertura < $COVERAGE_FILE > coverage.xml

- go test -v -coverprofile=coverage.txt -covermode count ./...
- go get github.com/boumenot/gocover-cobertura
- go run github.com/boumenot/gocover-cobertura < coverage.txt > coverage.xml
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
coverage: "/coverage: \\d+.\\d+% of statements/"