1spec:
2  inputs:
3    target:
4      description:
5        Build target in form of "OS-ARCH" pair (e.g., linux-amd64). Mostly the
6        same as platform string for Docker but with a hyphen instead of slash.
7    toolchain:
8      description:
9        An array of toolchains to test with. Each toolchain should have an
10        appropriate Meson cross file.
11      type: array
12      default: [gnu, llvm]
13    qemu_cpu:
14      description:
15        An array of QEMU_CPU environmental variables used as a job matrix
16        variable, and in turn by Docker (which uses QEMU underneath). It is not
17        used by x86 targets, as they are executed natively on the host.
18      type: array
19      default: [""]
20    pixman_disable:
21      description:
22        An array of PIXMAN_DISABLE targets used as a job matrix variable.
23      type: array
24      default: [""]
25    timeout:
26      description:
27        GitLab job timeout property. May need to be increased for slow
28        targets.
29      default: 1h
30    test_timeout_multiplier:
31      description:
32        Test timeout multiplier flag used for Meson test execution. May need to
33        be increased for slow targets.
34      type: number
35      default: 20
36    meson_testthreads:
37      description:
38        Sets MESON_TESTTHREADS environmental variable. For some platforms, the
39        tests should be executed one by one (without multithreading) to prevent
40        gcovr errors.
41      type: number
42      default: 0
43    gcovr_flags:
44      description:
45        Additional flags passed to gcovr tool.
46      default: ""
47    job_name_prefix:
48      description:
49        Additional prefix for the job name. Can be used to disable a job with a
50        "." prefix.
51      default: ""
52    job_name_suffix:
53      description:
54        Additional suffix for the job name. Can be used to prevent job
55        duplication for jobs for the same target.
56      default: ""
57    allow_failure:
58      description:
59        Set the `allow_failure` flag for jobs that are expected to fail.
60        Remember to set `retry` argument to 0 to prevent unnecessary retries.
61      type: boolean
62      default: false
63    retry:
64      description:
65        Set the `retry` flag for a job. Usually used together with
66        `allow_failure`.
67      type: number
68      default: 1
69    runner_tags:
70      description: List of GitLab runner tags for this job.
71      type: array
72      default: []
73---
74
75"$[[ inputs.job_name_prefix ]]test:$[[ inputs.target ]]$[[ inputs.job_name_suffix ]]":
76  extends: .target:all
77  tags: $[[ inputs.runner_tags ]]
78  stage: test
79  allow_failure: $[[ inputs.allow_failure ]]
80  retry: $[[ inputs.retry ]]
81  timeout: $[[ inputs.timeout ]]
82  needs:
83    - job: build:$[[ inputs.target ]]
84      parallel:
85        matrix:
86          - TOOLCHAIN: $[[ inputs.toolchain ]]
87  variables:
88    TARGET: $[[ inputs.target ]]
89    TEST_TIMEOUT_MULTIPLIER: $[[ inputs.test_timeout_multiplier ]]
90    MESON_ARGS: -t ${TEST_TIMEOUT_MULTIPLIER} --no-rebuild -v ${TEST_NAME}
91    MESON_TESTTHREADS: $[[ inputs.meson_testthreads ]]
92  parallel:
93    matrix:
94      - TOOLCHAIN: $[[ inputs.toolchain ]]
95        PIXMAN_DISABLE: $[[ inputs.pixman_disable ]]
96        QEMU_CPU: $[[ inputs.qemu_cpu ]]
97  script:
98    - meson test -C ${BUILD_DIR} ${MESON_ARGS}
99
100    # Generate coverage report.
101    - mkdir -p ${COVERAGE_OUT}
102    - if [ -f "${BUILD_DIR}/.coverage-enable" ]; then
103        gcovr $[[ inputs.gcovr_flags ]] -r ./ ${BUILD_DIR} -e ./subprojects
104          --json ${COVERAGE_OUT}.json
105          --html-details ${COVERAGE_OUT}/coverage.html
106          --print-summary;
107      fi
108  artifacts:
109    when: always
110    paths:
111      - ${BUILD_DIR}/meson-logs/testlog.txt
112      - ${COVERAGE_BASE_DIR}/
113    reports:
114      junit:
115        - ${BUILD_DIR}/meson-logs/testlog.junit.xml
116