From d198b68d97d8044f4690ae72b15af47624d040a3 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Sun, 25 Dec 2016 09:51:50 +0100 Subject: [PATCH 1/3] CircleCi: use master as fallback for DMD --- circle.yml | 1 + circleci.sh | 26 ++++++++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/circle.yml b/circle.yml index 5977d59a63..75ce6ddb19 100644 --- a/circle.yml +++ b/circle.yml @@ -7,6 +7,7 @@ dependencies: test: override: - make -f posix.mak style + - ./circleci.sh setup-repos - ./circleci.sh coverage: parallel: true timeout: 1200 diff --git a/circleci.sh b/circleci.sh index ca85a114ce..198d47de33 100755 --- a/circleci.sh +++ b/circleci.sh @@ -19,7 +19,8 @@ install_deps() { fi for i in {0..4}; do - if curl -fsS -A "$CURL_USER_AGENT" --max-time 5 https://dlang.org/install.sh -O; then + if curl -fsS -A "$CURL_USER_AGENT" --max-time 5 https://dlang.org/install.sh -O || + curl -fsS -A "$CURL_USER_AGENT" --max-time 5 https://nightlies.dlang.org/install.sh -O ; then break elif [ $i -ge 4 ]; then sleep $((1 << $i)) @@ -51,12 +52,15 @@ clone() { done } -coverage() { +setup_repos() { + # set a default in case we run into rate limit restrictions + local base_branch="" if [ -n "${CIRCLE_PR_NUMBER:-}" ]; then - local base_branch=$(curl -fsSL https://api.github.com/repos/dlang/$CIRCLE_PROJECT_REPONAME/pulls/$CIRCLE_PR_NUMBER | jq -r '.base.ref') + base_branch=$((curl -fsSL https://api.github.com/repos/dlang/$CIRCLE_PROJECT_REPONAME/pulls/$CIRCLE_PR_NUMBER || echo) | jq -r '.base.ref') else - local base_branch=$CIRCLE_BRANCH + base_branch=$CIRCLE_BRANCH fi + base_branch=${base_branch:-"master"} # merge upstream branch with changes, s.t. we check with the latest changes if [ -n "${CIRCLE_PR_NUMBER:-}" ]; then @@ -69,9 +73,18 @@ coverage() { git merge -m "Automatic merge" $current_branch fi + for proj in dmd ; do + if [ $base_branch != master ] && [ $base_branch != stable ] && + ! git ls-remote --exit-code --heads https://github.com/dlang/$proj.git $base_branch > /dev/null; then + # use master as fallback for other repos to test feature branches + clone https://github.com/dlang/$proj.git ../$proj master --depth 1 + else + clone https://github.com/dlang/$proj.git ../$proj $base_branch --depth 1 + fi + done +} - clone https://github.com/dlang/dmd.git ../dmd $base_branch --depth 1 - +coverage() { # load environment for bootstrap compiler source "$(CURL_USER_AGENT=\"$CURL_USER_AGENT\" bash ~/dlang/install.sh dmd-$HOST_DMD_VER --activate)" @@ -83,5 +96,6 @@ coverage() { case $1 in install-deps) install_deps ;; + setup-repos) setup_repos ;; coverage) coverage ;; esac From 71b8a6f5b75413801466cdc06d300ad1fd8a85c4 Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Thu, 16 Feb 2017 14:47:08 +0100 Subject: [PATCH 2/3] Set bootstrap DMD version to 2.072.2 --- circleci.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circleci.sh b/circleci.sh index 198d47de33..4780a521aa 100755 --- a/circleci.sh +++ b/circleci.sh @@ -2,7 +2,7 @@ set -uexo pipefail -HOST_DMD_VER=2.068.2 # same as in dmd/src/posix.mak +HOST_DMD_VER=2.072.2 # same as in dmd/src/posix.mak CURL_USER_AGENT="CirleCI $(curl --version | head -n 1)" N=2 CIRCLE_NODE_INDEX=${CIRCLE_NODE_INDEX:-0} From 190001d27b381b0cde77fe95d6b499a0c39d4b7f Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Thu, 16 Feb 2017 15:25:24 +0100 Subject: [PATCH 3/3] Add fallback for CodeCov --- circle.yml | 4 +--- circleci.sh | 49 +++++++++++++++++++++++++++++++++---------------- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/circle.yml b/circle.yml index 75ce6ddb19..1f6682064d 100644 --- a/circle.yml +++ b/circle.yml @@ -13,6 +13,4 @@ test: timeout: 1200 post: - # CodeCov gets confused by stored .lst files - - rm -rf test/coverage/generated - - bash <(curl -s https://codecov.io/bash) + - ./circleci.sh codecov diff --git a/circleci.sh b/circleci.sh index 4780a521aa..d20cad3df8 100755 --- a/circleci.sh +++ b/circleci.sh @@ -6,29 +6,37 @@ HOST_DMD_VER=2.072.2 # same as in dmd/src/posix.mak CURL_USER_AGENT="CirleCI $(curl --version | head -n 1)" N=2 CIRCLE_NODE_INDEX=${CIRCLE_NODE_INDEX:-0} +CIRCLE_PROJECT_REPONAME=${CIRCLE_PROJECT_REPONAME:-druntime} case $CIRCLE_NODE_INDEX in 0) MODEL=64 ;; 1) MODEL=32 ;; esac -install_deps() { - if [ $MODEL -eq 32 ]; then - sudo apt-get update - sudo apt-get install g++-multilib - fi - +download() { + local url="$1" + local fallbackurl="$2" + local outputfile="$3" for i in {0..4}; do - if curl -fsS -A "$CURL_USER_AGENT" --max-time 5 https://dlang.org/install.sh -O || - curl -fsS -A "$CURL_USER_AGENT" --max-time 5 https://nightlies.dlang.org/install.sh -O ; then + if curl -fsS -A "$CURL_USER_AGENT" --max-time 5 "$url" -o "$outputfile" || + curl -fsS -A "$CURL_USER_AGENT" --max-time 5 "$fallbackurl" -o "$outputfile" ; then break elif [ $i -ge 4 ]; then sleep $((1 << $i)) else - echo 'Failed to download install script' 1>&2 + echo "Failed to download script ${outputfile}" 1>&2 exit 1 fi done +} + +install_deps() { + if [ $MODEL -eq 32 ]; then + sudo apt-get update + sudo apt-get install g++-multilib + fi + + download "https://dlang.org/install.sh" "https://nightlies.dlang.org/install.sh" "install.sh" source "$(CURL_USER_AGENT=\"$CURL_USER_AGENT\" bash install.sh dmd-$HOST_DMD_VER --activate)" $DC --version @@ -64,13 +72,13 @@ setup_repos() { # merge upstream branch with changes, s.t. we check with the latest changes if [ -n "${CIRCLE_PR_NUMBER:-}" ]; then - local current_branch=$(git rev-parse --abbrev-ref HEAD) - git config user.name dummyuser - git config user.email dummyuser@dummyserver.com - git remote add upstream https://github.com/dlang/druntime.git - git fetch upstream - git checkout -f upstream/$base_branch - git merge -m "Automatic merge" $current_branch + local head=$(git rev-parse HEAD) + git fetch https://github.com/dlang/$CIRCLE_PROJECT_REPONAME.git $base_branch + git checkout -f FETCH_HEAD + local base=$(git rev-parse HEAD) + git config user.name 'CI' + git config user.email '<>' + git merge -m "Merge $head into $base" $head fi for proj in dmd ; do @@ -94,8 +102,17 @@ coverage() { TEST_COVERAGE="1" make -j$N -C . -f posix.mak MODEL=$MODEL unittest-debug } +codecov() +{ + # CodeCov gets confused by lst files which it can't matched + rm -rf test/runnable/extra-files + download "https://codecov.io/bash" "https://raw.githubusercontent.com/codecov/codecov-bash/master/codecov" "codecov.sh" + bash codecov.sh +} + case $1 in install-deps) install_deps ;; setup-repos) setup_repos ;; coverage) coverage ;; + codecov) codecov ;; esac