xref: /openbmc/qemu/.gitlab-ci.d/buildtest-template.yml (revision c94bee4cd6693c1c65ba43bb8970cf909dec378b)
16cd5251bSPhilippe Mathieu-Daudé.native_build_job_template:
2e312d1fdSDaniel P. Berrangé  extends: .base_job_template
36cd5251bSPhilippe Mathieu-Daudé  stage: build
4d4c7a565SDaniel P. Berrangé  image: $CI_REGISTRY_IMAGE/qemu/$IMAGE:$QEMU_CI_CONTAINER_TAG
52f7350cdSDaniel P. Berrangé  cache:
62f7350cdSDaniel P. Berrangé    paths:
72f7350cdSDaniel P. Berrangé      - ccache
82f7350cdSDaniel P. Berrangé    key: "$CI_JOB_NAME"
92f7350cdSDaniel P. Berrangé    when: always
106cd5251bSPhilippe Mathieu-Daudé  before_script:
11dc05b262SPeter Maydell    - source scripts/ci/gitlab-ci-section
12dc05b262SPeter Maydell    - section_start setup "Pre-script setup"
136cd5251bSPhilippe Mathieu-Daudé    - JOBS=$(expr $(nproc) + 1)
14b86a4698SDaniel P. Berrangé    - cat /packages.txt
15dc05b262SPeter Maydell    - section_end setup
166cd5251bSPhilippe Mathieu-Daudé  script:
172f7350cdSDaniel P. Berrangé    - export CCACHE_BASEDIR="$(pwd)"
182f7350cdSDaniel P. Berrangé    - export CCACHE_DIR="$CCACHE_BASEDIR/ccache"
192f7350cdSDaniel P. Berrangé    - export CCACHE_MAXSIZE="500M"
202f7350cdSDaniel P. Berrangé    - export PATH="$CCACHE_WRAPPERSDIR:$PATH"
219837697bSAlex Bennée    - du -sh .git
226cd5251bSPhilippe Mathieu-Daudé    - mkdir build
236cd5251bSPhilippe Mathieu-Daudé    - cd build
242f7350cdSDaniel P. Berrangé    - ccache --zero-stats
25dc05b262SPeter Maydell    - section_start configure "Running configure"
26eda2321dSThomas Huth    - ../configure --enable-werror --disable-docs --enable-fdt=system
2766e2c6cbSJohn Snow          ${TARGETS:+--target-list="$TARGETS"}
2822ebcba0SThomas Huth          $CONFIGURE_ARGS ||
2922ebcba0SThomas Huth      { cat config.log meson-logs/meson-log.txt && exit 1; }
306cd5251bSPhilippe Mathieu-Daudé    - if test -n "$LD_JOBS";
316cd5251bSPhilippe Mathieu-Daudé      then
3266e2c6cbSJohn Snow        pyvenv/bin/meson configure . -Dbackend_max_links="$LD_JOBS" ;
336cd5251bSPhilippe Mathieu-Daudé      fi || exit 1;
34dc05b262SPeter Maydell    - section_end configure
35dc05b262SPeter Maydell    - section_start build "Building QEMU"
36c53f7a10SDaniel P. Berrangé    - $MAKE -j"$JOBS"
37dc05b262SPeter Maydell    - section_end build
38dc05b262SPeter Maydell    - section_start test "Running tests"
396cd5251bSPhilippe Mathieu-Daudé    - if test -n "$MAKE_CHECK_ARGS";
406cd5251bSPhilippe Mathieu-Daudé      then
41c53f7a10SDaniel P. Berrangé        $MAKE -j"$JOBS" $MAKE_CHECK_ARGS ;
426cd5251bSPhilippe Mathieu-Daudé      fi
43dc05b262SPeter Maydell    - section_end test
442f7350cdSDaniel P. Berrangé    - ccache --show-stats
456cd5251bSPhilippe Mathieu-Daudé
4688b19e4eSAlex Bennée# We jump some hoops in common_test_job_template to avoid
4788b19e4eSAlex Bennée# rebuilding all the object files we skip in the artifacts
4888b19e4eSAlex Bennée.native_build_artifact_template:
4988b19e4eSAlex Bennée  artifacts:
50cef63308SDaniel P. Berrangé    when: on_success
5188b19e4eSAlex Bennée    expire_in: 2 days
5288b19e4eSAlex Bennée    paths:
5388b19e4eSAlex Bennée      - build
5488b19e4eSAlex Bennée      - .git-submodule-status
5588b19e4eSAlex Bennée    exclude:
5688b19e4eSAlex Bennée      - build/**/*.p
5788b19e4eSAlex Bennée      - build/**/*.a.p
5888b19e4eSAlex Bennée      - build/**/*.c.o
5988b19e4eSAlex Bennée      - build/**/*.c.o.d
6088b19e4eSAlex Bennée
6129a49376SDaniel P. Berrangé.common_test_job_template:
62e312d1fdSDaniel P. Berrangé  extends: .base_job_template
636cd5251bSPhilippe Mathieu-Daudé  stage: test
64d4c7a565SDaniel P. Berrangé  image: $CI_REGISTRY_IMAGE/qemu/$IMAGE:$QEMU_CI_CONTAINER_TAG
656cd5251bSPhilippe Mathieu-Daudé  script:
66dc05b262SPeter Maydell    - source scripts/ci/gitlab-ci-section
67dc05b262SPeter Maydell    - section_start buildenv "Setting up to run tests"
681f468152SPaolo Bonzini    - scripts/git-submodule.sh update roms/SLOF
69*cf434463SPaolo Bonzini    - build/pyvenv/bin/meson subprojects download $(cd build/subprojects && echo *)
706cd5251bSPhilippe Mathieu-Daudé    - cd build
716cd5251bSPhilippe Mathieu-Daudé    - find . -type f -exec touch {} +
726cd5251bSPhilippe Mathieu-Daudé    # Avoid recompiling by hiding ninja with NINJA=":"
736d62722eSThomas Huth    # We also have to pre-cache the functional tests manually in this case
746d62722eSThomas Huth    - if [ "x${QEMU_TEST_CACHE_DIR}" != "x" ]; then
756d62722eSThomas Huth        $MAKE precache-functional ;
766d62722eSThomas Huth      fi
77dc05b262SPeter Maydell    - section_end buildenv
78dc05b262SPeter Maydell    - section_start test "Running tests"
79c53f7a10SDaniel P. Berrangé    - $MAKE NINJA=":" $MAKE_CHECK_ARGS
80dc05b262SPeter Maydell    - section_end test
816cd5251bSPhilippe Mathieu-Daudé
8229a49376SDaniel P. Berrangé.native_test_job_template:
8329a49376SDaniel P. Berrangé  extends: .common_test_job_template
8429a49376SDaniel P. Berrangé  artifacts:
8529a49376SDaniel P. Berrangé    name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
86cef63308SDaniel P. Berrangé    when: always
8729a49376SDaniel P. Berrangé    expire_in: 7 days
8829a49376SDaniel P. Berrangé    paths:
8929a49376SDaniel P. Berrangé      - build/meson-logs/testlog.txt
90861dca37SMarc-André Lureau    reports:
91861dca37SMarc-André Lureau      junit: build/meson-logs/testlog.junit.xml
9229a49376SDaniel P. Berrangé
936d62722eSThomas Huth.functional_test_job_template:
9429a49376SDaniel P. Berrangé  extends: .common_test_job_template
956cd5251bSPhilippe Mathieu-Daudé  cache:
966cd5251bSPhilippe Mathieu-Daudé    key: "${CI_JOB_NAME}-cache"
976cd5251bSPhilippe Mathieu-Daudé    paths:
986cd5251bSPhilippe Mathieu-Daudé      - ${CI_PROJECT_DIR}/avocado-cache
996d62722eSThomas Huth      - ${CI_PROJECT_DIR}/functional-cache
1006cd5251bSPhilippe Mathieu-Daudé    policy: pull-push
1016cd5251bSPhilippe Mathieu-Daudé  artifacts:
1026cd5251bSPhilippe Mathieu-Daudé    name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
103cef63308SDaniel P. Berrangé    when: always
104f230dba7SPhilippe Mathieu-Daudé    expire_in: 7 days
1056cd5251bSPhilippe Mathieu-Daudé    paths:
1066cd5251bSPhilippe Mathieu-Daudé      - build/tests/results/latest/results.xml
1076cd5251bSPhilippe Mathieu-Daudé      - build/tests/results/latest/test-results
1086d62722eSThomas Huth      - build/tests/functional/*/*/*.log
1096cd5251bSPhilippe Mathieu-Daudé    reports:
1106cd5251bSPhilippe Mathieu-Daudé      junit: build/tests/results/latest/results.xml
1116cd5251bSPhilippe Mathieu-Daudé  before_script:
1126cd5251bSPhilippe Mathieu-Daudé    - mkdir -p ~/.config/avocado
1136cd5251bSPhilippe Mathieu-Daudé    - echo "[datadir.paths]" > ~/.config/avocado/avocado.conf
1146cd5251bSPhilippe Mathieu-Daudé    - echo "cache_dirs = ['${CI_PROJECT_DIR}/avocado-cache']"
1156cd5251bSPhilippe Mathieu-Daudé           >> ~/.config/avocado/avocado.conf
1166cd5251bSPhilippe Mathieu-Daudé    - echo -e '[job.output.testlogs]\nstatuses = ["FAIL", "INTERRUPT"]'
1176cd5251bSPhilippe Mathieu-Daudé           >> ~/.config/avocado/avocado.conf
1186cd5251bSPhilippe Mathieu-Daudé    - if [ -d ${CI_PROJECT_DIR}/avocado-cache ]; then
1196d62722eSThomas Huth        du -chs ${CI_PROJECT_DIR}/*-cache ;
1206cd5251bSPhilippe Mathieu-Daudé      fi
1216cd5251bSPhilippe Mathieu-Daudé    - export AVOCADO_ALLOW_UNTRUSTED_CODE=1
1226d62722eSThomas Huth    - export QEMU_TEST_ALLOW_UNTRUSTED_CODE=1
1236d62722eSThomas Huth    - export QEMU_TEST_CACHE_DIR=${CI_PROJECT_DIR}/functional-cache
1246cd5251bSPhilippe Mathieu-Daudé  after_script:
1256cd5251bSPhilippe Mathieu-Daudé    - cd build
1266d62722eSThomas Huth    - du -chs ${CI_PROJECT_DIR}/*-cache
127e312d1fdSDaniel P. Berrangé  variables:
128e312d1fdSDaniel P. Berrangé    QEMU_JOB_AVOCADO: 1
129