1# Summary stage
2#
3# This stage takes coverage reports from test runs for all architectures, and
4# merges it into a single report, with GitLab visualization. There is also an
5# HTML report generated as a separate artifact.
6
7summary:
8  extends: .target:all
9  stage: summary
10  variables:
11    TARGET: linux-amd64
12    COVERAGE_SUMMARY_DIR: ${COVERAGE_BASE_DIR}/summary
13  needs:
14    - job: test:linux-386
15      optional: true
16    - job: test:linux-amd64
17      optional: true
18    - job: test:linux-arm-v7
19      optional: true
20    - job: test:linux-arm64-v8
21      optional: true
22    - job: test:linux-mips64le
23      optional: true
24    - job: test:linux-ppc64le
25      optional: true
26    - job: test:linux-riscv64
27      optional: true
28  script:
29    - echo "Input coverage reports:" && ls ${COVERAGE_BASE_DIR}/*.json || (echo "No coverage reports available." && exit)
30    - |
31      args=( )
32      for f in ${COVERAGE_BASE_DIR}/*.json; do
33        args+=( "-a" "$f" )
34      done
35    - mkdir -p ${COVERAGE_SUMMARY_DIR}
36    - gcovr "${args[@]}"
37        --cobertura-pretty --cobertura ${COVERAGE_SUMMARY_DIR}/coverage.xml
38        --html-details ${COVERAGE_SUMMARY_DIR}/coverage.html
39        --txt --print-summary
40  coverage: '/^TOTAL.*\s+(\d+\%)$/'
41  artifacts:
42    when: always
43    reports:
44      coverage_report:
45        coverage_format: cobertura
46        path: ${COVERAGE_SUMMARY_DIR}/coverage.xml
47    paths:
48      - ${COVERAGE_BASE_DIR}/
49