# Copyright 2021 The Chromium OS Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. image: jbettis/ubuntu-29sep21 # You can update that image using this repo: # https://gitlab.com/zephyr-ec/gitlab-ci-runner/-/tree/main # Change pip's cache directory to be inside the project directory since we can # only cache local items. variables: PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip" # Pip's cache doesn't store the python packages # https://pip.pypa.io/en/stable/reference/pip_install/#caching # # If you want to also cache the installed packages, you have to install # them in a virtualenv and cache it as well. cache: key: ${CI_COMMIT_SHA} policy: pull paths: - .cache/pip - venv/ - modules/ - zephyr/main # The directory structure is: # # /zephyr # /builds/zephyr-ec/ec EC_DIR before_script: - export MODULES_DIR="$CI_PROJECT_DIR/modules" - mkdir -p "${MODULES_DIR}" - export ZEPHYR_ROOT="$CI_PROJECT_DIR/zephyr/main" - mkdir -p "${ZEPHYR_ROOT}" - test -d "${ZEPHYR_ROOT}/v2.6" || git clone --depth 1 -b chromeos-v2.6 https://chromium.googlesource.com/chromiumos/third_party/zephyr "${ZEPHYR_ROOT}/v2.6" - test -d "${ZEPHYR_ROOT}/v2.7" || git clone --depth 1 -b chromeos-v2.7 https://chromium.googlesource.com/chromiumos/third_party/zephyr "${ZEPHYR_ROOT}/v2.7" - test -d "${ZEPHYR_ROOT}/v2.8" || git clone --depth 1 -b chromeos-v2.8 https://chromium.googlesource.com/chromiumos/third_party/zephyr "${ZEPHYR_ROOT}/v2.8" - test -d "${MODULES_DIR}/cmsis" || git clone --depth 1 -b chromeos-main https://chromium.googlesource.com/chromiumos/third_party/zephyr/cmsis "${MODULES_DIR}/cmsis" - test -d "${MODULES_DIR}/hal_stm32" || git clone --depth 1 -b chromeos-main https://chromium.googlesource.com/chromiumos/third_party/zephyr/hal_stm32 "${MODULES_DIR}/hal_stm32" - test -d "${MODULES_DIR}/nanopb" || git clone --depth 1 -b main https://chromium.googlesource.com/chromiumos/third_party/zephyr/nanopb "${MODULES_DIR}/nanopb" - test -d "${MODULES_DIR}/cryptoc" || git clone --depth 1 -b main https://chromium.googlesource.com/chromiumos/third_party/cryptoc "${MODULES_DIR}/cryptoc" - ln -s "$(pwd)" "${MODULES_DIR}/ec" - python3 -V # Print out python version for debugging - python3 -m pip install zephyr/zmake --user - python3 -m pip install pyyaml - export BUILD_DIR=build - export ZEPHYR_DIR=/zephyr - export PATH="$PATH:$HOME/.local/bin" - export PYTHONIOENCODING=utf-8 - export EC_DIR=/builds/zephyr-ec/ec seed_cache: stage: build needs: [] cache: key: ${CI_COMMIT_SHA} paths: - .cache/pip - venv/ - modules/ - zephyr/main policy: push script: - ls "${MODULES_DIR}" "${ZEPHYR_ROOT}" # Users of this template must set: # $PROJECT to the project to build. E.g., "lazor" .build_template: &build_template stage: build needs: ["seed_cache"] script: - zmake --zephyr-root "${ZEPHYR_ROOT}" --modules-dir "${MODULES_DIR}" -l DEBUG configure -b -B "${BUILD_DIR}/${PROJECT}" -t ${TOOLCHAIN:-zephyr} "${PROJECT}" - for b in "${BUILD_DIR}/${PROJECT}"/build-* ; do bdir=$(basename ${b}) ; ninja -C ${b} ram_report >"${BUILD_DIR}/${PROJECT}/output/${bdir}_ram_report.txt" ; cp ${b}/ram.json "${BUILD_DIR}/${PROJECT}/output/${bdir}_ram.json" ; ninja -C ${b} rom_report >"${BUILD_DIR}/${PROJECT}/output/${bdir}_rom_report.txt" ; cp ${b}/rom.json "${BUILD_DIR}/${PROJECT}/output/${bdir}_rom.json" ; done - ls "${BUILD_DIR}/${PROJECT}" "${BUILD_DIR}/${PROJECT}/output" artifacts: paths: - build/${PROJECT}/output/* expire_in: 1 week # Users of this template must set: # $PROJECT to the project to build. E.g., "lazor" .coverage_template: &coverage_template stage: test needs: ["merged_coverage", "zephyr_coverage"] script: - grep "SF:" "build/zcoverage/${PROJECT}.info" | sort -u | sed -e 's|^SF:||' | xargs lcov -o build/no_zephyr_${PROJECT}.info -e build/merged_no_zephyr.info - /usr/bin/genhtml -q -o build/no_zephyr_${PROJECT}_rpt -t "${PROJECT} coverage w/o zephyr" -p ${EC_DIR} -s build/no_zephyr_${PROJECT}.info artifacts: paths: - build/*.info - build/*_rpt expire_in: 1 week coverage: '/lines\.*: \d+\.\d+%/' delbin: variables: PROJECT: "delbin" <<: *build_template hayato: variables: PROJECT: "hayato" <<: *build_template hayato_coverage: variables: PROJECT: "hayato" <<: *coverage_template herobrine_npcx9: variables: PROJECT: "herobrine_npcx9" <<: *build_template herobrine_npcx9_coverage: variables: PROJECT: "herobrine_npcx9" <<: *coverage_template it8xxx2_evb: variables: PROJECT: "it8xxx2_evb" <<: *build_template lazor: variables: PROJECT: "lazor" <<: *build_template native_posix: variables: PROJECT: "posix-ec" TOOLCHAIN: "host" <<: *build_template volteer: variables: PROJECT: "volteer" <<: *build_template ec_coverage: stage: test needs: ["seed_cache"] script: - make -j8 CRYPTOC_DIR="${MODULES_DIR}/cryptoc" HOSTGCOV='gcov' CROSS_COMPILE_arm=/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi- test-coverage artifacts: paths: - build/coverage/coverage_rpt/* - build/coverage/lcov.info expire_in: 1 week coverage: '/lines\.*: \d+\.\d+%/' zephyr_coverage: stage: test needs: ["seed_cache"] script: - zmake --zephyr-root "${ZEPHYR_ROOT}" --modules-dir "${MODULES_DIR}" -l DEBUG coverage "${BUILD_DIR}/zcoverage" artifacts: paths: - build/zcoverage/coverage_rpt/* - build/zcoverage/*.info expire_in: 1 week coverage: '/lines\.*: \d+\.\d+%/' merged_coverage: stage: test needs: ["ec_coverage", "zephyr_coverage"] script: - lcov -o build/merged.info -a build/coverage/lcov.info -a build/zcoverage/lcov.info - lcov -o build/merged_no_zephyr.info -r build/merged.info "${ZEPHYR_ROOT}/*" "${MODULES_DIR}/*" "zephyr/drivers/*" '/usr/include/x86_64-linux-gnu/*' artifacts: paths: - build/*.info - build/*_rpt expire_in: 1 week coverage: '/lines\.*: \d+\.\d+%/' testall: stage: test needs: ["seed_cache"] script: - zmake --zephyr-root "${ZEPHYR_ROOT}" --modules-dir "${MODULES_DIR}" -l DEBUG testall