1.native_build_job_template:
2  stage: build
3  image: $CI_REGISTRY_IMAGE/qemu/$IMAGE:latest
4  before_script:
5    - JOBS=$(expr $(nproc) + 1)
6  script:
7    - if test -n "$LD_JOBS";
8      then
9        scripts/git-submodule.sh update meson ;
10      fi
11    - mkdir build
12    - cd build
13    - if test -n "$TARGETS";
14      then
15        ../configure --enable-werror --disable-docs ${LD_JOBS:+--meson=git} $CONFIGURE_ARGS --target-list="$TARGETS" ;
16      else
17        ../configure --enable-werror --disable-docs ${LD_JOBS:+--meson=git} $CONFIGURE_ARGS ;
18      fi || { cat config.log meson-logs/meson-log.txt && exit 1; }
19    - if test -n "$LD_JOBS";
20      then
21        ../meson/meson.py configure . -Dbackend_max_links="$LD_JOBS" ;
22      fi || exit 1;
23    - make -j"$JOBS"
24    - if test -n "$MAKE_CHECK_ARGS";
25      then
26        make -j"$JOBS" $MAKE_CHECK_ARGS ;
27      fi
28
29.common_test_job_template:
30  stage: test
31  image: $CI_REGISTRY_IMAGE/qemu/$IMAGE:latest
32  script:
33    - scripts/git-submodule.sh update
34        $(sed -n '/GIT_SUBMODULES=/ s/.*=// p' build/config-host.mak)
35    - cd build
36    - find . -type f -exec touch {} +
37    # Avoid recompiling by hiding ninja with NINJA=":"
38    - make NINJA=":" $MAKE_CHECK_ARGS
39
40.native_test_job_template:
41  extends: .common_test_job_template
42  artifacts:
43    name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
44    expire_in: 7 days
45    paths:
46      - build/meson-logs/testlog.txt
47
48.avocado_test_job_template:
49  extends: .common_test_job_template
50  cache:
51    key: "${CI_JOB_NAME}-cache"
52    paths:
53      - ${CI_PROJECT_DIR}/avocado-cache
54    policy: pull-push
55  artifacts:
56    name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
57    when: on_failure
58    expire_in: 7 days
59    paths:
60      - build/tests/results/latest/results.xml
61      - build/tests/results/latest/test-results
62    reports:
63      junit: build/tests/results/latest/results.xml
64  before_script:
65    - mkdir -p ~/.config/avocado
66    - echo "[datadir.paths]" > ~/.config/avocado/avocado.conf
67    - echo "cache_dirs = ['${CI_PROJECT_DIR}/avocado-cache']"
68           >> ~/.config/avocado/avocado.conf
69    - echo -e '[job.output.testlogs]\nstatuses = ["FAIL", "INTERRUPT"]'
70           >> ~/.config/avocado/avocado.conf
71    - if [ -d ${CI_PROJECT_DIR}/avocado-cache ]; then
72        du -chs ${CI_PROJECT_DIR}/avocado-cache ;
73      fi
74    - export AVOCADO_ALLOW_UNTRUSTED_CODE=1
75  after_script:
76    - cd build
77    - du -chs ${CI_PROJECT_DIR}/avocado-cache
78  rules:
79    # Only run these jobs if running on the mainstream namespace,
80    # or if the user set the QEMU_CI_AVOCADO_TESTING variable (either
81    # in its namespace setting or via git-push option, see documentation
82    # in /.gitlab-ci.yml of this repository).
83    - if: '$CI_PROJECT_NAMESPACE == "qemu-project"'
84      when: on_success
85    - if: '$QEMU_CI_AVOCADO_TESTING'
86      when: on_success
87    # Otherwise, set to manual (the jobs are created but not run).
88    - when: manual
89      allow_failure: true
90