CI: optimize ATS ci flow

This commit is contained in:
Chen Yudong 2022-09-14 02:43:40 +08:00
parent 16dbb8f249
commit bfa96bc597
3 changed files with 43 additions and 43 deletions

View File

@ -100,12 +100,13 @@ assign_integration_test:
INTEGRATION_TEST_CASE_PATH: "${CI_PROJECT_DIR}/auto_test_script/TestCaseFiles" INTEGRATION_TEST_CASE_PATH: "${CI_PROJECT_DIR}/auto_test_script/TestCaseFiles"
ASSIGN_TEST_CASE_SCRIPT: "${CI_PROJECT_DIR}/auto_test_script/bin/CIAssignTestCases.py" ASSIGN_TEST_CASE_SCRIPT: "${CI_PROJECT_DIR}/auto_test_script/bin/CIAssignTestCases.py"
PYTHONPATH: ${CI_PROJECT_DIR}/auto_test_script/packages PYTHONPATH: ${CI_PROJECT_DIR}/auto_test_script/packages
GIT_LFS_SKIP_SMUDGE: 1
script: script:
- add_gitlab_ssh_keys - add_gitlab_ssh_keys
# clone test script to assign tests # clone test script to assign tests
# can not retry if downing git lfs files failed, so using empty_branch first. - retry_failed git clone ${CI_AUTO_TEST_SCRIPT_REPO_URL} auto_test_script
- retry_failed git clone ${CI_AUTO_TEST_SCRIPT_REPO_URL} -b empty_branch - python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script
- retry_failed git -C auto_test_script checkout -f ${CI_AUTO_TEST_SCRIPT_REPO_BRANCH} - cd auto_test_script
- python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script --customized_only - ./tools/ci/setup_idfci.sh
# assign integration test cases # assign integration test cases
- python ${ASSIGN_TEST_CASE_SCRIPT} -t ${INTEGRATION_TEST_CASE_PATH} -c $CI_TARGET_TEST_CONFIG_FILE -b ${BUILD_DIR} -o $TEST_DIR/test_configs - python ${ASSIGN_TEST_CASE_SCRIPT} -t ${INTEGRATION_TEST_CASE_PATH} -c $CI_TARGET_TEST_CONFIG_FILE -b ${BUILD_DIR} -o $TEST_DIR/test_configs

View File

@ -1129,8 +1129,8 @@ UT_S3_FLASH:
CI_RUNNER_SCRIPT: "${CI_PROJECT_DIR}/auto_test_script/bin/CIRunner.py" CI_RUNNER_SCRIPT: "${CI_PROJECT_DIR}/auto_test_script/bin/CIRunner.py"
PREPARE_TEST_BIN_SCRIPT: "${CI_PROJECT_DIR}/tools/ci/integration_test/prepare_test_bins.py" PREPARE_TEST_BIN_SCRIPT: "${CI_PROJECT_DIR}/tools/ci/integration_test/prepare_test_bins.py"
PYTHONPATH: "${CI_PROJECT_DIR}/auto_test_script/packages:${CI_PROJECT_DIR}/tools/ci/python_packages:${PYTHONPATH}" PYTHONPATH: "${CI_PROJECT_DIR}/auto_test_script/packages:${CI_PROJECT_DIR}/tools/ci/python_packages:${PYTHONPATH}"
SETUP_SCRIPT: "${CI_PROJECT_DIR}/auto_test_script/tools/ci/setup_idfci.sh"
INITIAL_CONDITION_RETRY_COUNT: "1" INITIAL_CONDITION_RETRY_COUNT: "1"
GIT_LFS_SKIP_SMUDGE: 1
script: script:
- *define_config_file_name - *define_config_file_name
# first test if config file exists, if not exist, exit 0 # first test if config file exists, if not exist, exit 0
@ -1140,11 +1140,11 @@ UT_S3_FLASH:
- retry_failed git clone $TEST_ENV_CONFIG_REPO - retry_failed git clone $TEST_ENV_CONFIG_REPO
- python $CHECKOUT_REF_SCRIPT ci-test-runner-configs ci-test-runner-configs - python $CHECKOUT_REF_SCRIPT ci-test-runner-configs ci-test-runner-configs
# clone test bench # clone test bench
# can not retry if downing git lfs files failed, so using empty_branch first. - retry_failed git clone ${CI_AUTO_TEST_SCRIPT_REPO_URL} auto_test_script
- retry_failed git clone ${CI_AUTO_TEST_SCRIPT_REPO_URL} -b empty_branch - python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script
- retry_failed git -C auto_test_script checkout -f ${CI_AUTO_TEST_SCRIPT_REPO_BRANCH} - cd auto_test_script
- python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script --customized_only - ./tools/ci/setup_idfci.sh
- if [ -f ${SETUP_SCRIPT} ]; then ${SETUP_SCRIPT}; fi # Merge known issues
- cat ${KNOWN_ISSUE_FILE} >> ${TEST_CASE_FILE_PATH}/KnownIssues - cat ${KNOWN_ISSUE_FILE} >> ${TEST_CASE_FILE_PATH}/KnownIssues
# run test # run test
- python ${PREPARE_TEST_BIN_SCRIPT} $CONFIG_FILE - python ${PREPARE_TEST_BIN_SCRIPT} $CONFIG_FILE
@ -1176,13 +1176,11 @@ nvs_compatible_test:
- retry_failed git clone $TEST_ENV_CONFIG_REPO - retry_failed git clone $TEST_ENV_CONFIG_REPO
- python $CHECKOUT_REF_SCRIPT ci-test-runner-configs ci-test-runner-configs - python $CHECKOUT_REF_SCRIPT ci-test-runner-configs ci-test-runner-configs
# clone test bench # clone test bench
# can not retry if downing git lfs files failed, so using empty_branch first. - retry_failed git clone ${CI_AUTO_TEST_SCRIPT_REPO_URL} auto_test_script
- retry_failed git clone ${CI_AUTO_TEST_SCRIPT_REPO_URL} -b empty_branch - python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script
- retry_failed git -C auto_test_script checkout -f ${CI_AUTO_TEST_SCRIPT_REPO_BRANCH}
- if [ -f ${SETUP_SCRIPT} ]; then ${SETUP_SCRIPT}; fi
- python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script --customized_only
# prepare nvs bins
- cd auto_test_script - cd auto_test_script
- ./tools/ci/setup_idfci.sh
# prepare nvs bins
- ./tools/prepare_nvs_bin.sh - ./tools/prepare_nvs_bin.sh
# run test # run test
- python ${PREPARE_TEST_BIN_SCRIPT} $CONFIG_FILE - python ${PREPARE_TEST_BIN_SCRIPT} $CONFIG_FILE

View File

@ -10,10 +10,25 @@ import json
import os import os
import re import re
import subprocess import subprocess
from typing import List from typing import List, Tuple
IDF_GIT_DESCRIBE_PATTERN = re.compile(r'^v(\d)\.(\d)') IDF_GIT_DESCRIBE_PATTERN = re.compile(r'^v(\d)\.(\d)')
RETRY_COUNT = 3
def _idf_version_from_cmake() -> Tuple[int, int]:
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: str) -> str: def get_customized_project_revision(proj_name: str) -> str:
@ -47,20 +62,12 @@ def target_branch_candidates(proj_name: str) -> List:
candidates.insert(0, customized_candidate) candidates.insert(0, customized_candidate)
# branch name read from IDF # branch name read from IDF
try: major_revision, minor_revision = _idf_version_from_cmake()
git_describe = subprocess.check_output(['git', 'describe', 'HEAD']) # release branch
match = IDF_GIT_DESCRIBE_PATTERN.search(git_describe.decode()) candidates.append('release/v{}.{}'.format(major_revision, minor_revision))
if match: # branch to match all major branches, like v3.x or v3
major_revision = match.group(1) candidates.append('release/v{}.x'.format(major_revision))
minor_revision = match.group(2) candidates.append('release/v{}'.format(major_revision))
# 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
return [c for c in candidates if c] # filter out null value return [c for c in candidates if c] # filter out null value
@ -103,16 +110,10 @@ if __name__ == '__main__':
continue continue
if ref_to_use: if ref_to_use:
for _ in range(RETRY_COUNT): try:
# Add retry for projects with git-lfs subprocess.check_call(['git', 'checkout', '-f', ref_to_use], stdout=subprocess.PIPE) # not print the stdout
try: print('CI using ref {} for project {}'.format(ref_to_use, args.project))
subprocess.check_call(['git', 'checkout', '-f', ref_to_use], stdout=subprocess.PIPE) # not print the stdout except subprocess.CalledProcessError:
print('CI using ref {} for project {}'.format(ref_to_use, args.project)) pass
break
except subprocess.CalledProcessError:
pass
else:
print('Failed to use ref {} for project {}'.format(ref_to_use, args.project))
exit(1)
else: else:
print('using default branch') print('using default branch')