Skip to content
Snippets Groups Projects
Unverified Commit 3e6b3e39 authored by Andrew Newdigate's avatar Andrew Newdigate
Browse files

feat: add go-unittests template

parent 0ebce0d0
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -291,3 +291,27 @@ include:
- project: 'gitlab-com/gl-infra/common-ci-tasks'
file: renovate-bot.yml
```
### [`go-unittests`](./go-unittests.yml)
Runs unit tests to ensure and emits a JUnit XML report for GitLab.
1. Ensure that the `GL_ASDF_GOLANG_VERSION` version for Go is configured.
```yaml
stages:
- validate
# Not needed if .gitlab-ci-asdf-versions.yml is included...
variables:
GL_ASDF_GOLANG_VERSION: ...
include:
# Not required, but recommended
- local: .gitlab-ci-asdf-versions.yml
# Runs Go unit tests
# see https://gitlab.com/gitlab-com/gl-infra/common-ci-tasks/-/blob/main/README.md#go-unittests
- project: 'gitlab-com/gl-infra/common-ci-tasks'
file: go-unittests.yml
```
go_unittests:
image: golang:${GL_ASDF_GOLANG_VERSION}
stage: validate
needs: []
script:
- go get gotest.tools/gotestsum
- gotestsum --junitfile report.xml --format testname
artifacts:
when: always
reports:
junit: report.xml
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment