From 936c803ccb7a3c37d30ec3911d68d0dec3af3f81 Mon Sep 17 00:00:00 2001 From: He Yin Ling Date: Tue, 29 Sep 2020 11:20:05 +0800 Subject: [PATCH 1/3] CI: get git describe from annotated tags: we should only parse IDF version from annotated tags --- tools/ci/check_idf_version.sh | 2 +- tools/ci/checkout_project_ref.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/ci/check_idf_version.sh b/tools/ci/check_idf_version.sh index 143acf5924..86a4a44696 100755 --- a/tools/ci/check_idf_version.sh +++ b/tools/ci/check_idf_version.sh @@ -33,7 +33,7 @@ cmake_ver_minor=$(get_ver_from_cmake IDF_VERSION_MINOR) cmake_ver_patch=$(get_ver_from_cmake IDF_VERSION_PATCH) version_from_cmake="${cmake_ver_major}.${cmake_ver_minor}.${cmake_ver_patch}" -git_desc=$(git describe --tags) +git_desc=$(git describe) git_desc_regex="^v([0-9]+)\.([0-9]+)(\.([0-9]+))?.*$" if [[ ! ${git_desc} =~ ${git_desc_regex} ]]; then echo "Could not determine the version from 'git describe' output: ${git_desc}" diff --git a/tools/ci/checkout_project_ref.py b/tools/ci/checkout_project_ref.py index e9c060a1b0..e7d0a8e6aa 100755 --- a/tools/ci/checkout_project_ref.py +++ b/tools/ci/checkout_project_ref.py @@ -35,7 +35,7 @@ def target_branch_candidates(proj_name): pass # branch name read from IDF try: - git_describe = subprocess.check_output(["git", "describe", "--tags", "HEAD"]) + git_describe = subprocess.check_output(["git", "describe", "HEAD"]) match = IDF_GIT_DESCRIBE_PATTERN.search(git_describe.decode()) if match: major_revision = match.group(1) From 6c2bffe53c3a5950b50618d40935fb69c06ae725 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Wed, 7 Oct 2020 09:36:40 +1100 Subject: [PATCH 2/3] build system: Also get IDF version from annotated tags only Builds on previous commit. Note: Getting the project version still pases --tags so still works with plain tags, to keep compatibility for existing projects --- docs/en/versions.rst | 2 +- docs/gen-version-specific-includes.py | 2 +- docs/issue_template.md | 2 +- make/project.mk | 2 +- tools/idf_tools.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/en/versions.rst b/docs/en/versions.rst index 69c955600e..cf4b8e2e6f 100644 --- a/docs/en/versions.rst +++ b/docs/en/versions.rst @@ -70,7 +70,7 @@ Checking The Current Version The local ESP-IDF version can be checked using git:: cd $IDF_PATH - git describe --tags --dirty + git describe --dirty The version is also compiled into the firmware and can be accessed (as a string) via the macro ``IDF_VER``. The default ESP-IDF bootloader will print the version on boot (these versions in code will not always update, it only changes if that particular source file is recompiled). diff --git a/docs/gen-version-specific-includes.py b/docs/gen-version-specific-includes.py index 08b111d651..6bd377c4b1 100755 --- a/docs/gen-version-specific-includes.py +++ b/docs/gen-version-specific-includes.py @@ -198,7 +198,7 @@ def get_version(): # Otherwise, use git to look for a tag try: - tag = subprocess.check_output(["git", "describe", "--tags", "--exact-match"]).strip() + tag = subprocess.check_output(["git", "describe", "--exact-match"]).strip() is_stable = re.match(r"v[0-9\.]+$", tag) is not None return (tag, "tag", is_stable) except subprocess.CalledProcessError: diff --git a/docs/issue_template.md b/docs/issue_template.md index 7bf65e7815..bce83a9693 100644 --- a/docs/issue_template.md +++ b/docs/issue_template.md @@ -27,7 +27,7 @@ If the issue cannot be solved after the steps before, please follow these instru - Development Kit: [ESP32-Wrover-Kit|ESP32-DevKitC|ESP32-PICO-Kit|ESP32-LyraT|ESP32-LyraTD-MSC|none] - Kit version (for WroverKit/PicoKit/DevKitC): [v1|v2|v3|v4] - Module or chip used: [ESP32-WROOM-32|ESP32-WROOM-32D|ESP32-WROOM-32U|ESP32-WROVER|ESP32-WROVER-I|ESP32-WROVER-B|ESP32-WROVER-IB|ESP32-SOLO-1|ESP32-PICO-D4|ESP32] -- IDF version (run ``git describe --tags`` to find it): +- IDF version (run ``git describe`` to find it): // v3.2-dev-1148-g96cd3b75c - Build System: [Make|CMake] - Compiler version (run ``xtensa-esp32-elf-gcc --version`` to find it): diff --git a/make/project.mk b/make/project.mk index 9ae62138af..7c8de9a59b 100644 --- a/make/project.mk +++ b/make/project.mk @@ -270,7 +270,7 @@ endif # If we have `version.txt` then prefer that for extracting IDF version ifeq ("$(wildcard ${IDF_PATH}/version.txt)","") -IDF_VER_T := $(shell cd ${IDF_PATH} && git describe --always --tags --dirty) +IDF_VER_T := $(shell cd ${IDF_PATH} && git describe --always --dirty) else IDF_VER_T := `cat ${IDF_PATH}/version.txt` endif diff --git a/tools/idf_tools.py b/tools/idf_tools.py index 4ccb7a9d20..6341218f79 100755 --- a/tools/idf_tools.py +++ b/tools/idf_tools.py @@ -837,7 +837,7 @@ def get_python_env_path(): with open(version_file_path, "r") as version_file: idf_version_str = version_file.read() else: - idf_version_str = subprocess.check_output(['git', '--work-tree=' + global_idf_path, 'describe', '--tags'], cwd=global_idf_path, env=os.environ).decode() + idf_version_str = subprocess.check_output(['git', '--work-tree=' + global_idf_path, 'describe'], cwd=global_idf_path, env=os.environ).decode() match = re.match(r'^v([0-9]+\.[0-9]+).*', idf_version_str) idf_version = match.group(1) From 111e0361c932e762181b4e1e639d104f1e143bc7 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Wed, 7 Oct 2020 09:54:27 +1100 Subject: [PATCH 3/3] ci: Check version tags are always annotated Closes https://github.com/espressif/esp-idf/issues/3114 --- .gitlab-ci.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f3144f7ad5..ef2e58339b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -796,6 +796,18 @@ check_pipeline_triggered_by_label: # We want to make sure some jobs are always executed to detect regression. - test "$BOT_LABEL_REGULAR_TEST" = "true" || exit -1 +# For release tag pipelines only, make sure the tag was created with 'git tag -a' so it will update +# the version returned by 'git describe' +check_version_tag: + extends: .check_job_template + only: + refs: + - /^v\d+\.\d+(\.\d+)?($|-)/ + variables: + - $BOT_TRIGGER_WITH_LABEL == null + script: + - (git cat-file -t $CI_COMMIT_REF_NAME | grep tag) || echo "ESP-IDF versions must be annotated tags." && exit 1 + assign_test: tags: - assign_test