mirror of
https://github.com/espressif/esp-idf.git
synced 2026-08-18 06:35:35 +03:00
Merge branch 'ci/optimize_ats_ci_flow_v4.4' into 'release/v4.4'
CI: optimize ATS ci flow (v4.4) See merge request espressif/esp-idf!20175
This commit is contained in:
@@ -10,7 +10,22 @@ import re
|
||||
import subprocess
|
||||
|
||||
IDF_GIT_DESCRIBE_PATTERN = re.compile(r'^v(\d)\.(\d)')
|
||||
RETRY_COUNT = 3
|
||||
|
||||
|
||||
def _idf_version_from_cmake():
|
||||
version_path = os.path.join(os.environ['IDF_PATH'], 'tools/cmake/version.cmake')
|
||||
regex = re.compile(r'^\s*set\s*\(\s*IDF_VERSION_([A-Z]{5})\s+(\d+)')
|
||||
try:
|
||||
ver = {}
|
||||
with open(version_path) as f:
|
||||
for line in f:
|
||||
m = regex.match(line)
|
||||
if m:
|
||||
ver[m.group(1)] = m.group(2)
|
||||
return (int(ver['MAJOR']), int(ver['MINOR']))
|
||||
except (KeyError, OSError):
|
||||
print('WARNING: Cannot find ESP-IDF version in version.cmake')
|
||||
return (0, 0)
|
||||
|
||||
|
||||
def get_customized_project_revision(proj_name):
|
||||
@@ -44,20 +59,12 @@ def target_branch_candidates(proj_name):
|
||||
candidates.insert(0, customized_candidate)
|
||||
|
||||
# branch name read from IDF
|
||||
try:
|
||||
git_describe = subprocess.check_output(['git', 'describe', 'HEAD'])
|
||||
match = IDF_GIT_DESCRIBE_PATTERN.search(git_describe.decode())
|
||||
if match:
|
||||
major_revision = match.group(1)
|
||||
minor_revision = match.group(2)
|
||||
# release branch
|
||||
candidates.append('release/v{}.{}'.format(major_revision, minor_revision))
|
||||
# branch to match all major branches, like v3.x or v3
|
||||
candidates.append('release/v{}.x'.format(major_revision))
|
||||
candidates.append('release/v{}'.format(major_revision))
|
||||
except subprocess.CalledProcessError:
|
||||
# this should not happen as IDF should have describe message
|
||||
pass
|
||||
major_revision, minor_revision = _idf_version_from_cmake()
|
||||
# release branch
|
||||
candidates.append('release/v{}.{}'.format(major_revision, minor_revision))
|
||||
# branch to match all major branches, like v3.x or v3
|
||||
candidates.append('release/v{}.x'.format(major_revision))
|
||||
candidates.append('release/v{}'.format(major_revision))
|
||||
|
||||
return [c for c in candidates if c] # filter out null value
|
||||
|
||||
@@ -100,16 +107,10 @@ if __name__ == '__main__':
|
||||
continue
|
||||
|
||||
if ref_to_use:
|
||||
for _ in range(RETRY_COUNT):
|
||||
# Add retry for projects with git-lfs
|
||||
try:
|
||||
subprocess.check_call(['git', 'checkout', '-f', ref_to_use], stdout=subprocess.PIPE) # not print the stdout
|
||||
print('CI using ref {} for project {}'.format(ref_to_use, args.project))
|
||||
break
|
||||
except subprocess.CalledProcessError:
|
||||
pass
|
||||
else:
|
||||
print('Failed to use ref {} for project {}'.format(ref_to_use, args.project))
|
||||
exit(1)
|
||||
try:
|
||||
subprocess.check_call(['git', 'checkout', '-f', ref_to_use], stdout=subprocess.PIPE) # not print the stdout
|
||||
print('CI using ref {} for project {}'.format(ref_to_use, args.project))
|
||||
except subprocess.CalledProcessError:
|
||||
pass
|
||||
else:
|
||||
print('using default branch')
|
||||
|
||||
Reference in New Issue
Block a user