From 4b17811c8679f2d16b5d8c09a10f244408da4409 Mon Sep 17 00:00:00 2001 From: Fu Hanxi Date: Tue, 5 Mar 2024 14:51:22 +0100 Subject: [PATCH] ci: use full fetch while checking git tags --- .gitlab/ci/common.yml | 25 ++++++++----------------- .gitlab/ci/pre_check.yml | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/.gitlab/ci/common.yml b/.gitlab/ci/common.yml index e4d4e0f3a6..698f2b50f6 100644 --- a/.gitlab/ci/common.yml +++ b/.gitlab/ci/common.yml @@ -20,8 +20,14 @@ variables: MAKEFLAGS: "-j5 --no-keep-going" # GitLab-CI environment - - # now we have pack-objects cache, so clone strategy is faster than fetch + # Thanks to pack-objects cache, clone strategy should behave faster than fetch + # so we pick "clone" as default git strategy + # Shiny runners by default remove the CI_PROJECT_DIR every time at the beginning of one job + # and clone with a --depth=1 + # Brew runners will fetch from locally mirror first, and cache the local CI_PROJECT_DIR + # In conclusion + # - set GIT_STRATEGY: "clone" to shiny runners + # - set GIT_STRATEGY: "fetch" to brew runners GIT_STRATEGY: clone # we will download archive for each submodule instead of clone. # we don't do "recursive" when fetch submodule as they're not used in CI now. @@ -299,21 +305,6 @@ variables: - *setup_tools_and_idf_python_venv - add_gitlab_ssh_keys -# git describe requires commit history until the latest tag -.before_script:fetch:git_describe: - variables: - GIT_STRATEGY: none - before_script: - - *git_init - - *git_fetch_from_mirror_url_if_exists - - git fetch origin refs/tags/"${LATEST_GIT_TAG}":refs/tags/"${LATEST_GIT_TAG}" --depth=1 - - git repack -d - - git fetch origin $PIPELINE_COMMIT_SHA --shallow-since=$(git log -1 --format=%as "${LATEST_GIT_TAG}") - - *git_checkout_fetch_head - - *common-before_scripts - - *setup_tools_and_idf_python_venv - - add_gitlab_ssh_keys - # target test runners may locate in different places # for runners set git mirror, we fetch from the mirror first, then fetch the HEAD commit .before_script:fetch:target_test: diff --git a/.gitlab/ci/pre_check.yml b/.gitlab/ci/pre_check.yml index ed86a0b04c..8183b1d3cd 100644 --- a/.gitlab/ci/pre_check.yml +++ b/.gitlab/ci/pre_check.yml @@ -11,7 +11,13 @@ check_version: extends: - .pre_check_template - .rules:protected - - .before_script:fetch:git_describe + tags: [ brew, github_sync ] + variables: + # need a full clone to get the latest tag + # the --shallow-since=$(git log -1 --format=%as $LATEST_GIT_TAG) option is not accurate + GIT_STRATEGY: fetch + SUBMODULES_TO_FETCH: "none" + GIT_DEPTH: 0 script: - export IDF_PATH=$PWD - tools/ci/check_idf_version.sh @@ -106,7 +112,13 @@ check_version_tag: extends: - .pre_check_template - .rules:tag:release - - .before_script:fetch:git_describe + tags: [ brew, github_sync ] + variables: + # need a full clone to get the latest tag + # the --shallow-since=$(git log -1 --format=%as $LATEST_GIT_TAG) option is not accurate + GIT_STRATEGY: fetch + SUBMODULES_TO_FETCH: "none" + GIT_DEPTH: 0 script: - (git cat-file -t $CI_COMMIT_REF_NAME | grep tag) || (echo "ESP-IDF versions must be annotated tags." && exit 1)