gitlab: Extract default build/test jobs templates
[qemu/ar7.git] / .gitlab-ci.d / buildtest-template.yml
blob530d30746c70c2df803e0e1a833e253a5af29cb5
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
29 .native_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
40 .acceptance_test_job_template:
41   extends: .native_test_job_template
42   cache:
43     key: "${CI_JOB_NAME}-cache"
44     paths:
45       - ${CI_PROJECT_DIR}/avocado-cache
46     policy: pull-push
47   artifacts:
48     name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
49     when: always
50     expire_in: 2 days
51     paths:
52       - build/tests/results/latest/results.xml
53       - build/tests/results/latest/test-results
54     reports:
55       junit: build/tests/results/latest/results.xml
56   before_script:
57     - mkdir -p ~/.config/avocado
58     - echo "[datadir.paths]" > ~/.config/avocado/avocado.conf
59     - echo "cache_dirs = ['${CI_PROJECT_DIR}/avocado-cache']"
60            >> ~/.config/avocado/avocado.conf
61     - echo -e '[job.output.testlogs]\nstatuses = ["FAIL", "INTERRUPT"]'
62            >> ~/.config/avocado/avocado.conf
63     - if [ -d ${CI_PROJECT_DIR}/avocado-cache ]; then
64         du -chs ${CI_PROJECT_DIR}/avocado-cache ;
65       fi
66     - export AVOCADO_ALLOW_UNTRUSTED_CODE=1
67   after_script:
68     - cd build
69     - du -chs ${CI_PROJECT_DIR}/avocado-cache