diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 346040e66d637d97816cc633f573511cc7cdc2fd..280c98dfbb28f8adbdb6dd98f84838ae18990c20 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,13 +1,10 @@ fail_fast: true repos: - repo: "https://github.com/pre-commit/pre-commit-hooks.git" - rev: v4.5.0 + rev: v4.4.0 hooks: - id: check-added-large-files args: ['--maxkb=100'] - - id: check-byte-order-marker - - id: check-case-conflict - - id: check-merge-conflict - id: check-symlinks - id: check-toml - id: end-of-file-fixer diff --git a/ci/00-pre.sh b/ci/00-pre.sh index c40cc82e8ef657b0f524108e905beaeeaf4b3eb5..ceba18aca616df664a625e423b98ca3eca742387 100755 --- a/ci/00-pre.sh +++ b/ci/00-pre.sh @@ -1,9 +1,17 @@ #!/usr/bin/env bash SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source $SCRIPT_DIR/common_function +flag_file="$SCRIPT_DIR/../.git/sysmaster-first-build.flag" + +function finish() { + echo "failed run, delete flag file" + rm -rf $flag_file +} + +trap finish SIGINT SIGTERM SIGKILL # 定义标志文件的路径 -flag_file="$SCRIPT_DIR/../.git/sysmaster-first-build.flag" + # 检查标志文件是否存在 if [ -e "$flag_file" ]; then @@ -86,7 +94,15 @@ sources=("https://521github.com/" "https://gitclone.com/github.com/" "https://gh url=$(test_fasturl ${sources[@]}) git config --global url."${url}".insteadOf "https://github.com/" -rm -rf ~/.cargo/.package-cache + +pipurls=("https://pypi.tuna.tsinghua.edu.cn/simple" "http://mirrors.aliyun.com/pypi/simple/" "https://pypi.mirrors.ustc.edu.cn/simple/" "http://pypi.hustunique.com/" "http://pypi.sdutlinux.org/" "http://pypi.douban.com/simple/") +url=$(test_fasturl ${pipurls[@]}) + +if [[ $url =~ ^https?://([^/]+) ]]; then + domain="${BASH_REMATCH[1]}" + pip config set global.index-url $url + pip config set global.trusted-host $domain +fi ##拉取代码 #rm -rf sysmaster diff --git a/ci/01-pre-commit.sh b/ci/01-pre-commit.sh index b5c9deed3891ecdc312044e27ed0a5a317a7952d..39fc581b0cf9eb8e553bd1efde616a6d7b99a7d2 100755 --- a/ci/01-pre-commit.sh +++ b/ci/01-pre-commit.sh @@ -21,9 +21,8 @@ do done export PATH="$PATH:/home/jenkins/.local/bin" -files="pre-commit codespell ruamel.yaml" -pip3 install $files -i https://pypi.mirrors.ustc.edu.cn/simple || pip3 install -i http://pypi.douban.com/simple/ $files || pip3 install $files - +files="pre-commit codespell" +pip3 install $files ## one PR ? Commit # oldnum=`git rev-list origin/master --no-merges --count` # newnum=`git rev-list HEAD --no-merges --count` diff --git a/ci/common_function b/ci/common_function index 3ba4c19bdfff922d36767b3189043ef6902d0cd9..f948cba94a2e517f3675b66f30bc1797b8b032b7 100644 --- a/ci/common_function +++ b/ci/common_function @@ -15,7 +15,7 @@ function test_fasturl() for url in "${urls[@]}"; do # Send an HTTP request to get crate information and measure the execution time start_time=$(date +%s%N) - response=$(curl -s -o /dev/null --connect-timeout 1 -w "%{time_total}" "$url" > /dev/null 2>&1) + response=$(curl -s -o /dev/null --connect-timeout 1 -m 10 -w "%{time_total}" "$url" > /dev/null 2>&1) if [ $? -ne 0 ]; then continue fi