From 543e66acc2b2727ecfa4c35946cce5d49fabcbd2 Mon Sep 17 00:00:00 2001 From: overweight Date: Sat, 28 Oct 2023 09:21:13 +0800 Subject: [PATCH] ci: downgrade pre-commit version --- .pre-commit-config.yaml | 5 +---- ci/00-pre.sh | 20 ++++++++++++++++++-- ci/01-pre-commit.sh | 5 ++--- ci/common_function | 2 +- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 346040e6..280c98df 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 c40cc82e..ceba18ac 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 b5c9deed..39fc581b 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 3ba4c19b..f948cba9 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 -- Gitee