Loading jobs/go_unit_test/go_unit_test.yml 0 → 100644 +31 −0 Original line number Diff line number Diff line stages: - static_tests unit-tests: stage: static_tests image: golang:latest variables: UT_WORK_DIR: $CI_PROJECT_DIR script: # Switch to working directory - cd "$UT_WORK_DIR" # Install job dependencies - go get -u github.com/jstemmer/go-junit-report github.com/t-yuki/gocover-cobertura # Execute Unit tests to get both the junit report and a coverage file - go test -v -coverprofile=coverage.out ./... 2>&1 | go-junit-report -set-exit-code > report.xml # Output the coverage to stdout for coverage regex to read - go tool cover -func=coverage.out # Capture coverage in cobertura format for MR highlighting - gocover-cobertura < coverage.out > cobertura.xml # Capture coverage in HTML format for humans - go tool cover -html=coverage.out -o code-coverage.html # Regex below tells gitlab what to capture from job's stdout as a coverage figure coverage: '/total:\s+\(statements\)\s+(\d+.\d+%)/' artifacts: paths: - report.xml - code-coverage.html when: always reports: junit: report.xml cobertura: cobertura.xml Loading
jobs/go_unit_test/go_unit_test.yml 0 → 100644 +31 −0 Original line number Diff line number Diff line stages: - static_tests unit-tests: stage: static_tests image: golang:latest variables: UT_WORK_DIR: $CI_PROJECT_DIR script: # Switch to working directory - cd "$UT_WORK_DIR" # Install job dependencies - go get -u github.com/jstemmer/go-junit-report github.com/t-yuki/gocover-cobertura # Execute Unit tests to get both the junit report and a coverage file - go test -v -coverprofile=coverage.out ./... 2>&1 | go-junit-report -set-exit-code > report.xml # Output the coverage to stdout for coverage regex to read - go tool cover -func=coverage.out # Capture coverage in cobertura format for MR highlighting - gocover-cobertura < coverage.out > cobertura.xml # Capture coverage in HTML format for humans - go tool cover -html=coverage.out -o code-coverage.html # Regex below tells gitlab what to capture from job's stdout as a coverage figure coverage: '/total:\s+\(statements\)\s+(\d+.\d+%)/' artifacts: paths: - report.xml - code-coverage.html when: always reports: junit: report.xml cobertura: cobertura.xml