From 9e20c7ae3d6951cab3ed8dc66a0467da5bf37f16 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 31 Jan 2020 16:54:48 +0100 Subject: [PATCH] CI: Add checks to build against different IDF releases --- .gitlab-ci.yml | 67 ++++++++++--------- ci/build_examples.sh | 21 ++++++ .../modify_for_legacy_idf.sh | 0 ci/set_idf.sh | 19 ++++++ ci/set_mqtt.sh | 16 +++++ 5 files changed, 91 insertions(+), 32 deletions(-) create mode 100755 ci/build_examples.sh rename modify_for_legacy_idf.sh => ci/modify_for_legacy_idf.sh (100%) create mode 100755 ci/set_idf.sh create mode 100755 ci/set_mqtt.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1a5c9c9..46c8509 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,8 +20,10 @@ before_script: - curl -sSL ${CIT_LOADER_URL} | sh - source citools/import_functions - PATH=$CI_PROJECT_DIR/esp-idf/tools:$PATH + - export IDF_PATH=$CI_PROJECT_DIR/esp-idf + - export MQTT_PATH=$CI_PROJECT_DIR -build_with_older_idf: +build_with_idf_v3: stage: build image: ${CI_DOCKER_REGISTRY}/esp32-ci-env tags: @@ -29,16 +31,21 @@ build_with_older_idf: dependencies: [] script: - cit_add_ssh_key "${GITLAB_KEY}" - - git clone "${IDF_REPO}" && cd esp-idf && git checkout ${OLDER_IDF} - - ./tools/ci/mirror-submodule-update.sh - - export IDF_PATH=$(pwd) - - cd $CI_PROJECT_DIR - - ./modify_for_legacy_idf.sh ${RECENT_IDF} || true - - cd $CI_PROJECT_DIR/examples/tcp - - make defconfig - - make + - git clone "${IDF_REPO}" + # build with IDFv3.2 + - $MQTT_PATH/ci/set_idf.sh release/v3.2 + - $MQTT_PATH/ci/set_mqtt.sh $CI_COMMIT_SHA + - $MQTT_PATH/ci/build_examples.sh make + # build with IDFv3.3 + - $MQTT_PATH/ci/set_idf.sh release/v3.3 + - $MQTT_PATH/ci/set_mqtt.sh $CI_COMMIT_SHA + - $MQTT_PATH/ci/build_examples.sh make + # simple build with IDFv3.1 (buiding directly in mqtt repo) + - $MQTT_PATH/ci/set_idf.sh release/v3.1 + - cd $MQTT_PATH && ./ci/modify_for_legacy_idf.sh ${RECENT_IDF} || true + - cd $MQTT_PATH/examples/tcp && rm -rf build && make defconfig && make -build_with_idf: +build_with_idf_v4: stage: build image: ${CI_DOCKER_REGISTRY}/esp32-ci-env tags: @@ -52,14 +59,9 @@ build_with_idf: script: - cit_add_ssh_key "${GITLAB_KEY}" - git clone "${IDF_REPO}" - - cd esp-idf - - tools/idf_tools.py --non-interactive install && eval "$(tools/idf_tools.py --non-interactive export)" || exit 1 - - ./tools/ci/mirror-submodule-update.sh - - export IDF_PATH=$(pwd) - - cd $IDF_PATH/components/mqtt/esp-mqtt - - rm -rf .git - - cp -r $CI_PROJECT_DIR/.git . - - git reset --hard $CI_COMMIT_SHA + - $MQTT_PATH/ci/set_idf.sh master + - cd $IDF_PATH && tools/idf_tools.py --non-interactive install && eval "$(tools/idf_tools.py --non-interactive export)" + - $MQTT_PATH/ci/set_mqtt.sh $CI_COMMIT_SHA # capture compile commands/flags for static analysis - cd $IDF_PATH/examples/protocols/mqtt/tcp - mkdir -p tidybuild && cd tidybuild @@ -69,11 +71,17 @@ build_with_idf: - export PEDANTIC_CFLAGS="-Werror -Werror=deprecated-declarations -Werror=unused-variable -Werror=unused-but-set-variable -Werror=unused-function" - export EXTRA_CFLAGS=${PEDANTIC_CFLAGS} && export EXTRA_CXXFLAGS=${EXTRA_CFLAGS} # build other examples - - cd $IDF_PATH/examples/protocols/mqtt/tcp && idf.py build - - cd $IDF_PATH/examples/protocols/mqtt/ssl && idf.py build - - cd $IDF_PATH/examples/protocols/mqtt/ssl_mutual_auth && idf.py build - - cd $IDF_PATH/examples/protocols/mqtt/ws && idf.py build - - cd $IDF_PATH/examples/protocols/mqtt/wss && idf.py build + - $MQTT_PATH/ci/build_examples.sh + # rebuild with IDFv4.1 + - $MQTT_PATH/ci/set_idf.sh release/v4.1 + - cd $IDF_PATH && tools/idf_tools.py --non-interactive install && eval "$(tools/idf_tools.py --non-interactive export)" + - $MQTT_PATH/ci/set_mqtt.sh $CI_COMMIT_SHA + - $MQTT_PATH/ci/build_examples.sh + # rebuild with IDFv4.0 + - $MQTT_PATH/ci/set_idf.sh release/v4.0 + - cd $IDF_PATH && tools/idf_tools.py --non-interactive install && eval "$(tools/idf_tools.py --non-interactive export)" + - $MQTT_PATH/ci/set_mqtt.sh $CI_COMMIT_SHA + - $MQTT_PATH/ci/build_examples.sh build_and_test_qemu: stage: build @@ -85,14 +93,9 @@ build_and_test_qemu: script: - cit_add_ssh_key "${GITLAB_KEY}" - git clone "${IDF_REPO}" - - cd esp-idf - - tools/idf_tools.py --non-interactive install && eval "$(tools/idf_tools.py --non-interactive export)" || exit 1 - - ./tools/ci/mirror-submodule-update.sh - - export IDF_PATH=$(pwd) - - cd $IDF_PATH/components/mqtt/esp-mqtt - - rm -rf .git - - cp -r $CI_PROJECT_DIR/.git . - - git reset --hard $CI_COMMIT_SHA + - $MQTT_PATH/ci/set_idf.sh master + - cd $IDF_PATH && tools/idf_tools.py --non-interactive install && eval "$(tools/idf_tools.py --non-interactive export)" + - $MQTT_PATH/ci/set_mqtt.sh $CI_COMMIT_SHA # build publish stress test - cd $IDF_PATH/examples/protocols/mqtt/publish_test && cat sdkconfig.qemu | $IDF_PATH/tools/ci/envsubst.py >> sdkconfig.defaults && idf.py build - source /opt/pyenv/activate && pyenv global 2.7.15 && python --version @@ -109,7 +112,7 @@ clang_tidy_check: tags: - host_test dependencies: - - build_with_idf + - build_with_idf_v4 artifacts: reports: junit: esp-idf/examples/protocols/mqtt/tcp/tidybuild/output.xml diff --git a/ci/build_examples.sh b/ci/build_examples.sh new file mode 100755 index 0000000..2de91e4 --- /dev/null +++ b/ci/build_examples.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +# build mqtt examples with make if $1=="make", with cmake otherwise +set -o errexit # Exit if command failed. + +if [ -z $IDF_PATH ] ; then + echo "Mandatory variables undefined" + exit 1; +fi; + +examples="tcp ssl ssl_mutual_auth ws wss" +for i in $examples; do + echo "Building MQTT example $i" + cd $IDF_PATH/examples/protocols/mqtt/$i + if [[ "$1" = "make" ]]; then + make defconfig + make -j 4 + else + idf.py build + fi; +done diff --git a/modify_for_legacy_idf.sh b/ci/modify_for_legacy_idf.sh similarity index 100% rename from modify_for_legacy_idf.sh rename to ci/modify_for_legacy_idf.sh diff --git a/ci/set_idf.sh b/ci/set_idf.sh new file mode 100755 index 0000000..4de46d7 --- /dev/null +++ b/ci/set_idf.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +# sets up the IDF repo incl submodules with specified version as $1 +set -o errexit # Exit if command failed. + +if [ -z $IDF_PATH ] || [ -z $MQTT_PATH ] || [ -z $1 ] ; then + echo "Mandatory variables undefined" + exit 1; +fi; + +echo "Checking out IDF version $1" +cd $IDF_PATH +# Cleans out the untracked files in the repo, so the next "git checkout" doesn't fail +git clean -f +git checkout $1 +# Removes the mqtt submodule, not the next submodule update doesn't fail +rm -rf $IDF_PATH/components/mqtt/esp-mqtt +./tools/ci/mirror-submodule-update.sh + diff --git a/ci/set_mqtt.sh b/ci/set_mqtt.sh new file mode 100755 index 0000000..8c70b66 --- /dev/null +++ b/ci/set_mqtt.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +# sets the mqtt in IDF tree as a submodule with the version specified as $1 +set -o errexit # Exit if command failed. + +if [ -z $IDF_PATH ] || [ -z $MQTT_PATH ] || [ -z $1 ] ; then + echo "Mandatory variables undefined" + exit 1; +fi; + +echo "Checking out MQTT version to $1" +# exchange remotes of mqtt submodules with plain copy +cd $IDF_PATH/components/mqtt/esp-mqtt +rm -rf .git # removes the actual IDF referenced version +cp -r $MQTT_PATH/.git . # replaces with the MQTT_PATH (CI checked tree) +git reset --hard $1 # sets the requested version