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