xref: /qemu/.gitlab-ci.d/buildtest-template.yml (revision 70ce076fa6dff60585c229a4b641b13e64bf03cf)
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    - export RUST_BACKTRACE=1
67    - source scripts/ci/gitlab-ci-section
68    - section_start buildenv "Setting up to run tests"
69    - scripts/git-submodule.sh update roms/SLOF
70    - build/pyvenv/bin/meson subprojects download $(cd build/subprojects && echo *)
71    - cd build
72    - find . -type f -exec touch {} +
73    # Avoid recompiling by hiding ninja with NINJA=":"
74    # We also have to pre-cache the functional tests manually in this case
75    - if [ "x${QEMU_TEST_CACHE_DIR}" != "x" ]; then
76        $MAKE precache-functional ;
77      fi
78    - section_end buildenv
79    - section_start test "Running tests"
80    - $MAKE NINJA=":" $MAKE_CHECK_ARGS
81    - section_end test
82
83.native_test_job_template:
84  extends: .common_test_job_template
85  artifacts:
86    name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
87    when: always
88    expire_in: 7 days
89    paths:
90      - build/meson-logs/testlog.txt
91    reports:
92      junit: build/meson-logs/testlog.junit.xml
93
94.functional_test_job_template:
95  extends: .common_test_job_template
96  cache:
97    key: "${CI_JOB_NAME}-cache"
98    paths:
99      - ${CI_PROJECT_DIR}/avocado-cache
100      - ${CI_PROJECT_DIR}/functional-cache
101    policy: pull-push
102  artifacts:
103    name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
104    when: always
105    expire_in: 7 days
106    paths:
107      - build/tests/results/latest/results.xml
108      - build/tests/results/latest/test-results
109      - build/tests/functional/*/*/*.log
110    reports:
111      junit: build/tests/results/latest/results.xml
112  before_script:
113    - mkdir -p ~/.config/avocado
114    - echo "[datadir.paths]" > ~/.config/avocado/avocado.conf
115    - echo "cache_dirs = ['${CI_PROJECT_DIR}/avocado-cache']"
116           >> ~/.config/avocado/avocado.conf
117    - echo -e '[job.output.testlogs]\nstatuses = ["FAIL", "INTERRUPT"]'
118           >> ~/.config/avocado/avocado.conf
119    - if [ -d ${CI_PROJECT_DIR}/avocado-cache ]; then
120        du -chs ${CI_PROJECT_DIR}/*-cache ;
121      fi
122    - export AVOCADO_ALLOW_UNTRUSTED_CODE=1
123    - export QEMU_TEST_ALLOW_UNTRUSTED_CODE=1
124    - export QEMU_TEST_CACHE_DIR=${CI_PROJECT_DIR}/functional-cache
125  after_script:
126    - cd build
127    - du -chs ${CI_PROJECT_DIR}/*-cache
128  variables:
129    QEMU_JOB_AVOCADO: 1
130