.coverage_job:
  extends:
  - .rules:merge_request_pipelines:no_docs:always
  stage: coverage

test coverage report:
  extends:
  - .coverage_job
  coverage: /regular total:\s+\(statements\)\s+\d+.\d+\%/
  needs:
  - unit test
  - integration test
  script:
  - source ci/touch_make_dependencies
  - make parallel_test_coverage_report cobertura_report
  artifacts:
    reports:
      coverage_report:
        coverage_format: cobertura
        path: out/cobertura/cobertura-coverage.xml
    paths:
    - out/coverage/
    expire_in: 7d
    expose_as: 'Code Coverage'

integration test coverage report:
  extends:
  - .coverage_job
  needs:
  - integration test
  script:
  - source ci/touch_make_dependencies
  - make parallel_test_coverage_report
  artifacts:
    paths:
    - out/coverage/
    expire_in: 7d
    expose_as: 'Integration Test Code Coverage'

test junit report:
  extends:
  - .coverage_job
  image: $CI_IMAGE
  needs:
  - unit test
  - integration test
  script:
  - source ci/touch_make_dependencies
  - make parallel_test_junit_report
  artifacts:
    reports:
      junit: out/junit/report.xml

race conditions detector:
  extends:
  - .coverage_job
  needs:
  - unit test with race
  - integration test with race
  script:
  - source ci/touch_make_dependencies
  - make check_race_conditions

# Disable this for now since
# https://gitlab.com/gitlab-org/gitlab/-/issues/365885 block us from upgrading
# to go 1.18.x. Re-enable this when the above ticket is fixed.
#code navigation: # See https://docs.gitlab.com/ee/user/project/code_intelligence.html#configuration
  #extends:
  #- .coverage_job
  #allow_failure: true # recommended
  #needs:
  #- prepare done
  #image: sourcegraph/lsif-go:v1.9.0
  #script:
  #- lsif-go
  #artifacts:
    #reports:
      #lsif: dump.lsif

check race unexpected test failures:
  extends:
  - .rules:merge_request_pipelines:no_docs:always
  stage: coverage
  needs:
  - unit test with race
  - integration test with race
  script:
  - ./scripts/check_unexpected_test_failures

.check windows unexpected test failures:
  stage: coverage
  script:
  - ./scripts/check_unexpected_test_failures

check windows 1809 unexpected unit test failures:
  extends:
  - .check windows unexpected test failures
  - .rules:merge_request_pipelines:no_docs:always
  needs:
  - windows 1809 unit tests

check windows 1809 unexpected integration test failures:
  extends:
  - .check windows unexpected test failures
  - .rules:merge_request_pipelines:no_docs:always
  needs:
  - windows 1809 integration tests

check windows 21H1 unexpected unit test failures:
  extends:
  - .check windows unexpected test failures
  - .rules:merge_request_pipelines:no_docs:no-community-mr
  needs:
    - windows 21H1 unit tests

check windows 21H1 unexpected integration test failures:
  extends:
  - .check windows unexpected test failures
  - .rules:merge_request_pipelines:no_docs:no-community-mr
  needs:
    - windows 21H1 integration tests

.check windows test failures:
  stage: coverage
  script:
  - ./scripts/check_windows_failures
  artifacts:
    paths:
    - .test-failures.*.txt.updated
    expire_in: 7d

# Only test the oldest supported version in merge requests,
# but test all versions in the default branch.
check windows 1809 unit test failures:
  extends:
  - .check windows test failures
  - .windows1809_variables
  - .rules:merge_request_pipelines:no_docs
  needs:
  - windows 1809 unit tests

check windows 21H1 unit test failures:
  extends:
  - .check windows test failures
  - .windows21H1_variables
  - .rules:merge_request_pipelines:no_docs:no-community-mr
  needs:
    - windows 21H1 unit tests

check windows 1809 integration test failures:
  extends:
  - .check windows test failures
  - .windows1809_variables
  - .rules:merge_request_pipelines:no_docs
  needs:
  - windows 1809 integration tests

check windows 2004 integration test failures:
  extends:
  - .check windows test failures
  - .windows2004_variables
  - .rules:merge_request_pipelines:no_docs:no-community-mr
  needs:
  - windows 2004 integration tests

check windows 20H2 integration test failures:
  extends:
  - .check windows test failures
  - .windows20H2_variables
  - .rules:merge_request_pipelines:no_docs:no-community-mr
  needs:
  - windows 20H2 integration tests

check windows 21H1 integration test failures:
  extends:
  - .check windows test failures
  - .windows21H1_variables
  - .rules:merge_request_pipelines:no_docs:no-community-mr
  needs:
  - windows 21H1 integration tests
