test: add coverage to gitlab ci

This commit is contained in:
pataar 2022-10-04 19:30:12 +00:00 committed by Gary Holtz
parent 81dbe93cea
commit bcc83d2ffd
2 changed files with 18 additions and 0 deletions

View File

@ -27,6 +27,17 @@ include:
- template: Security/Dependency-Scanning.gitlab-ci.yml
- template: Security/Secret-Detection.gitlab-ci.yml
# From: https://docs.gitlab.com/ee/ci/caching/#cache-go-dependencies
.go-cache:
variables:
GOPATH: $CI_PROJECT_DIR/.go
before_script:
- mkdir -p .go
cache:
paths:
- .go/pkg/mod/
code_navigation:
stage: test
image: golang:latest
@ -40,6 +51,7 @@ code_navigation:
run_tests:
stage: test
extends: .go-cache
before_script:
## Adding private SSH key to the executor, more information: https://docs.gitlab.com/ee/ci/ssh_keys/#ssh-keys-when-using-the-docker-executor
- mkdir -p ~/.ssh
@ -54,6 +66,11 @@ run_tests:
# the GITLAB_TOKEN_TEST with less privilege used for testing and the GITLAB_TOKEN_RELEASE token
- GITLAB_TOKEN=$GITLAB_TOKEN_TEST make test
coverage: '/coverage: \d+.\d+% of statements/'
artifacts:
reports:
junit: coverage.xml
secret_detection:
rules:
- if: $SECRET_DETECTION_DISABLED

View File

@ -4,6 +4,7 @@
[![Go Report Card](https://goreportcard.com/badge/gitlab.com/gitlab-org/cli)](https://goreportcard.com/report/gitlab.com/gitlab-org/cli)
[![Gitter](https://badges.gitter.im/glabcli/community.svg)](https://gitter.im/glabcli/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![Coverage](https://gitlab.com/gitlab-org/cli/badges/main/coverage.svg)](https://gitlab.com/gitlab-org/cli/badges/main)
[![Reddit](https://img.shields.io/reddit/subreddit-subscribers/glab_cli?style=social)](https://reddit.com/r/glab_cli)
[![Twitter Follow](https://img.shields.io/twitter/follow/glab_cli?style=social)](https://twitter.com/glab_cli)
[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go#version-control)