# 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/ # 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_BASE="${CI_PROJECT_DIR}/zephyr/main" - mkdir -p "${ZEPHYR_BASE}" - test -d "${ZEPHYR_BASE}/.git" || git clone --depth 1 -b main https://chromium.googlesource.com/chromiumos/third_party/zephyr "${ZEPHYR_BASE}" - 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 packaging - export BUILD_DIR=build - 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/ policy: push script: - ls "${MODULES_DIR}" "${ZEPHYR_BASE}" # 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-base "${ZEPHYR_BASE}" --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" # Builds the project with coverage enabled, removes the non-ec files. # Then merges with the tests, excludes all files not used by this project, # and generates a report. .coverage_template: &coverage_template stage: test needs: ["merged_coverage", "zephyr_coverage"] script: - zmake --zephyr-base "${ZEPHYR_BASE}" --modules-dir "${MODULES_DIR}" -l DEBUG configure -b --coverage -B "${BUILD_DIR}/${PROJECT}" -t ${TOOLCHAIN:-zephyr} "${PROJECT}" - lcov -o "${BUILD_DIR}/${PROJECT}/merged.info" -a "${BUILD_DIR}/${PROJECT}/lcov.info" -a build/merged.info - lcov -o "${BUILD_DIR}/${PROJECT}/no_zephyr.info" -r "${BUILD_DIR}/${PROJECT}/lcov.info" "${ZEPHYR_BASE}/**" "${MODULES_DIR}/*" "zephyr/drivers/*" '/usr/include/x86_64-linux-gnu/*' - lcov -o "${BUILD_DIR}/${PROJECT}/merged_no_zephyr.info" -r "${BUILD_DIR}/${PROJECT}/merged.info" "${ZEPHYR_BASE}/**" "${MODULES_DIR}/*" "zephyr/drivers/*" '/usr/include/x86_64-linux-gnu/*' - grep "SF:" "${BUILD_DIR}/${PROJECT}/no_zephyr.info" | sort -u | sed -e 's|^SF:||' | xargs lcov -o "${BUILD_DIR}/${PROJECT}/filtered_no_zephyr.info" -e "${BUILD_DIR}/${PROJECT}/merged_no_zephyr.info" - /usr/bin/genhtml -q -o "${BUILD_DIR}/${PROJECT}/filtered_no_zephyr_rpt" -t "${PROJECT} coverage w/o zephyr" -p ${EC_DIR} -s "${BUILD_DIR}/${PROJECT}/filtered_no_zephyr.info" artifacts: paths: - build/${PROJECT}/*.info - build/${PROJECT}/*_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-base "${ZEPHYR_BASE}" --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_BASE}/**" "${MODULES_DIR}/**" 'zephyr/drivers/**' 'zephyr/include/drivers/**' 'zephyr/shim/chip/**' 'zephyr/shim/core/**' '/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-base "${ZEPHYR_BASE}" --modules-dir "${MODULES_DIR}" -l DEBUG testall