1.native_build_job_template:
2  extends: .base_job_template
3  stage: build
4  image: $CI_REGISTRY_IMAGE/qemu/$IMAGE:$QEMU_CI_CONTAINER_TAG
5  cache:
6    paths:
7      - ccache
8    key: "$CI_JOB_NAME"
9    when: always
10  before_script:
11    - source scripts/ci/gitlab-ci-section
12    - section_start setup "Pre-script setup"
13    - JOBS=$(expr $(nproc) + 1)
14    - cat /packages.txt
15    - section_end setup
16  script:
17    - export CCACHE_BASEDIR="$(pwd)"
18    - export CCACHE_DIR="$CCACHE_BASEDIR/ccache"
19    - export CCACHE_MAXSIZE="500M"
20    - export PATH="$CCACHE_WRAPPERSDIR:$PATH"
21    - du -sh .git
22    - mkdir build
23    - cd build
24    - ccache --zero-stats
25    - section_start configure "Running configure"
26    - ../configure --enable-werror --disable-docs --enable-fdt=system
27          ${TARGETS:+--target-list="$TARGETS"}
28          $CONFIGURE_ARGS ||
29      { cat config.log meson-logs/meson-log.txt && exit 1; }
30    - if test -n "$LD_JOBS";
31      then
32        pyvenv/bin/meson configure . -Dbackend_max_links="$LD_JOBS" ;
33      fi || exit 1;
34    - section_end configure
35    - section_start build "Building QEMU"
36    - $MAKE -j"$JOBS"
37    - section_end build
38    - section_start test "Running tests"
39    - if test -n "$MAKE_CHECK_ARGS";
40      then
41        $MAKE -j"$JOBS" $MAKE_CHECK_ARGS ;
42      fi
43    - section_end test
44    - ccache --show-stats
45
46# We jump some hoops in common_test_job_template to avoid
47# rebuilding all the object files we skip in the artifacts
48.native_build_artifact_template:
49  artifacts:
50    when: on_success
51    expire_in: 2 days
52    paths:
53      - build
54      - .git-submodule-status
55    exclude:
56      - build/**/*.p
57      - build/**/*.a.p
58      - build/**/*.c.o
59      - build/**/*.c.o.d
60
61.common_test_job_template:
62  extends: .base_job_template
63  stage: test
64  image: $CI_REGISTRY_IMAGE/qemu/$IMAGE:$QEMU_CI_CONTAINER_TAG
65  script:
66    - source scripts/ci/gitlab-ci-section
67    - section_start buildenv "Setting up to run tests"
68    - scripts/git-submodule.sh update roms/SLOF
69    - build/pyvenv/bin/meson subprojects download $(cd build/subprojects && echo *)
70    - cd build
71    - find . -type f -exec touch {} +
72    # Avoid recompiling by hiding ninja with NINJA=":"
73    # We also have to pre-cache the functional tests manually in this case
74    - if [ "x${QEMU_TEST_CACHE_DIR}" != "x" ]; then
75        $MAKE precache-functional ;
76      fi
77    - section_end buildenv
78    - section_start test "Running tests"
79    - $MAKE NINJA=":" $MAKE_CHECK_ARGS
80    - section_end test
81
82.native_test_job_template:
83  extends: .common_test_job_template
84  artifacts:
85    name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
86    when: always
87    expire_in: 7 days
88    paths:
89      - build/meson-logs/testlog.txt
90    reports:
91      junit: build/meson-logs/testlog.junit.xml
92
93.functional_test_job_template:
94  extends: .common_test_job_template
95  cache:
96    key: "${CI_JOB_NAME}-cache"
97    paths:
98      - ${CI_PROJECT_DIR}/avocado-cache
99      - ${CI_PROJECT_DIR}/functional-cache
100    policy: pull-push
101  artifacts:
102    name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
103    when: always
104    expire_in: 7 days
105    paths:
106      - build/tests/results/latest/results.xml
107      - build/tests/results/latest/test-results
108      - build/tests/functional/*/*/*.log
109    reports:
110      junit: build/tests/results/latest/results.xml
111  before_script:
112    - mkdir -p ~/.config/avocado
113    - echo "[datadir.paths]" > ~/.config/avocado/avocado.conf
114    - echo "cache_dirs = ['${CI_PROJECT_DIR}/avocado-cache']"
115           >> ~/.config/avocado/avocado.conf
116    - echo -e '[job.output.testlogs]\nstatuses = ["FAIL", "INTERRUPT"]'
117           >> ~/.config/avocado/avocado.conf
118    - if [ -d ${CI_PROJECT_DIR}/avocado-cache ]; then
119        du -chs ${CI_PROJECT_DIR}/*-cache ;
120      fi
121    - export AVOCADO_ALLOW_UNTRUSTED_CODE=1
122    - export QEMU_TEST_ALLOW_UNTRUSTED_CODE=1
123    - export QEMU_TEST_CACHE_DIR=${CI_PROJECT_DIR}/functional-cache
124  after_script:
125    - cd build
126    - du -chs ${CI_PROJECT_DIR}/*-cache
127  variables:
128    QEMU_JOB_AVOCADO: 1
129