mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-31 19:24:33 +02:00
Merge branch 'ci/force_based_on_commit_v4.4' into 'release/v4.4'
ci: support one pipeline must based on commmits (v4.4) See merge request espressif/esp-idf!17920
This commit is contained in:
@@ -88,6 +88,7 @@ variables:
|
|||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- source tools/ci/utils.sh
|
- source tools/ci/utils.sh
|
||||||
|
- is_based_on_commits $REQUIRED_ANCESTOR_COMMITS
|
||||||
- source tools/ci/setup_python.sh
|
- source tools/ci/setup_python.sh
|
||||||
- add_gitlab_ssh_keys
|
- add_gitlab_ssh_keys
|
||||||
- source tools/ci/configure_ci_environment.sh
|
- source tools/ci/configure_ci_environment.sh
|
||||||
@@ -99,6 +100,7 @@ before_script:
|
|||||||
before_script:
|
before_script:
|
||||||
- echo "Not setting up GitLab key, not fetching submodules"
|
- echo "Not setting up GitLab key, not fetching submodules"
|
||||||
- source tools/ci/utils.sh
|
- source tools/ci/utils.sh
|
||||||
|
- is_based_on_commits $REQUIRED_ANCESTOR_COMMITS
|
||||||
- source tools/ci/setup_python.sh
|
- source tools/ci/setup_python.sh
|
||||||
- source tools/ci/configure_ci_environment.sh
|
- source tools/ci/configure_ci_environment.sh
|
||||||
|
|
||||||
@@ -106,10 +108,12 @@ before_script:
|
|||||||
before_script:
|
before_script:
|
||||||
- echo "Only load utils.sh"
|
- echo "Only load utils.sh"
|
||||||
- source tools/ci/utils.sh
|
- source tools/ci/utils.sh
|
||||||
|
- is_based_on_commits $REQUIRED_ANCESTOR_COMMITS
|
||||||
|
|
||||||
.before_script_macos:
|
.before_script_macos:
|
||||||
before_script:
|
before_script:
|
||||||
- source tools/ci/utils.sh
|
- source tools/ci/utils.sh
|
||||||
|
- is_based_on_commits $REQUIRED_ANCESTOR_COMMITS
|
||||||
- export IDF_TOOLS_PATH="${HOME}/.espressif_runner_${CI_RUNNER_ID}_${CI_CONCURRENT_ID}"
|
- export IDF_TOOLS_PATH="${HOME}/.espressif_runner_${CI_RUNNER_ID}_${CI_CONCURRENT_ID}"
|
||||||
- $IDF_PATH/tools/idf_tools.py install-python-env
|
- $IDF_PATH/tools/idf_tools.py install-python-env
|
||||||
# On macOS, these tools need to be installed
|
# On macOS, these tools need to be installed
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
image: "$CI_DOCKER_REGISTRY/esp-idf-pre-commit:1"
|
image: "$CI_DOCKER_REGISTRY/esp-idf-pre-commit:1"
|
||||||
before_script:
|
before_script:
|
||||||
- source tools/ci/utils.sh
|
- source tools/ci/utils.sh
|
||||||
|
- is_based_on_commits $REQUIRED_ANCESTOR_COMMITS
|
||||||
- export PYTHONPATH="$CI_PROJECT_DIR/tools:$CI_PROJECT_DIR/tools/ci/python_packages:$PYTHONPATH"
|
- export PYTHONPATH="$CI_PROJECT_DIR/tools:$CI_PROJECT_DIR/tools/ci/python_packages:$PYTHONPATH"
|
||||||
|
|
||||||
check_pre_commit_master_release:
|
check_pre_commit_master_release:
|
||||||
|
@@ -65,6 +65,7 @@ check_pylint:
|
|||||||
name: $SONARQUBE_SCANNER_IMAGE
|
name: $SONARQUBE_SCANNER_IMAGE
|
||||||
before_script:
|
before_script:
|
||||||
- source tools/ci/utils.sh
|
- source tools/ci/utils.sh
|
||||||
|
- is_based_on_commits $REQUIRED_ANCESTOR_COMMITS
|
||||||
- export PYTHONPATH="$CI_PROJECT_DIR/tools:$CI_PROJECT_DIR/tools/ci/python_packages:$PYTHONPATH"
|
- export PYTHONPATH="$CI_PROJECT_DIR/tools:$CI_PROJECT_DIR/tools/ci/python_packages:$PYTHONPATH"
|
||||||
- fetch_submodules
|
- fetch_submodules
|
||||||
# Exclude the submodules, all paths ends with /**
|
# Exclude the submodules, all paths ends with /**
|
||||||
|
@@ -114,11 +114,53 @@ function retry_failed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function internal_pip_install() {
|
function internal_pip_install() {
|
||||||
project=$1
|
project=$1
|
||||||
package=$2
|
package=$2
|
||||||
token_name=${3:-${BOT_TOKEN_NAME}}
|
token_name=${3:-${BOT_TOKEN_NAME}}
|
||||||
token=${4:-${BOT_TOKEN}}
|
token=${4:-${BOT_TOKEN}}
|
||||||
python=${5:-python}
|
python=${5:-python}
|
||||||
|
|
||||||
$python -m pip install --index-url https://${token_name}:${token}@${GITLAB_HTTPS_HOST}/api/v4/projects/${project}/packages/pypi/simple --force-reinstall --no-deps ${package}
|
$python -m pip install --index-url https://${token_name}:${token}@${GITLAB_HTTPS_HOST}/api/v4/projects/${project}/packages/pypi/simple --force-reinstall --no-deps ${package}
|
||||||
|
}
|
||||||
|
|
||||||
|
function join_by {
|
||||||
|
local d=${1-} f=${2-}
|
||||||
|
if shift 2; then
|
||||||
|
printf %s "$f" "${@/#/$d}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function is_based_on_commits() {
|
||||||
|
# This function would accept space-separated args as multiple commits.
|
||||||
|
# The return value would be 0 if current HEAD is based on any of the specified commits.
|
||||||
|
#
|
||||||
|
# In our CI, we use environment variable $REQUIRED_ANCESTOR_COMMITS to declare the ancestor commits.
|
||||||
|
# Please remember to set one commit for each release branch.
|
||||||
|
|
||||||
|
commits=$*
|
||||||
|
if [[ -z $commits ]]; then
|
||||||
|
info "Not specifying commits that branches should be based on, skipping check..."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
commits_str="$(join_by " or " $commits)" # no doublequotes here, passing array
|
||||||
|
|
||||||
|
info "Checking if current branch is based on $commits_str..."
|
||||||
|
for i in $commits; do
|
||||||
|
if git merge-base --is-ancestor "$i" HEAD >/dev/null 2>&1; then
|
||||||
|
info "Current branch is based on $i"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
info "Current branch is not based on $i"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
error "The base commit of your branch is too old."
|
||||||
|
error "The branch should be more recent than either of the following commits:"
|
||||||
|
error " $commits_str"
|
||||||
|
error "To fix the issue:"
|
||||||
|
error " - If your merge request is 'Draft', or has conflicts with the target branch, rebase it to the latest master or release branch"
|
||||||
|
error " - Otherwise, simply run a new pipeline."
|
||||||
|
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user