unit_tests:
  rules: !reference [.rules:default, rules]
  stage: test
  image: golang:$GOLANG_VERSION-alpine
  extends:
    - .go-cache
  script:
    - go install gotest.tools/gotestsum@latest
    - gotestsum --junitfile report.xml --format testname -- ./... -coverprofile=profile.cov
    - go tool cover -func profile.cov
  coverage: '/\(statements\)(?:\s+)?(\d+(?:\.\d+)?%)/'
  artifacts:
    when: always
    reports:
      junit: report.xml