Skip to content

Commit

Permalink
Merge pull request #4719 from wilzbach/switch_to_circleci
Browse files Browse the repository at this point in the history
Switch to CircleCi
  • Loading branch information
dnadlinger committed Aug 14, 2016
2 parents 41df329 + ba5f55a commit f2210fe
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 38 deletions.
38 changes: 0 additions & 38 deletions .travis.yml

This file was deleted.

15 changes: 15 additions & 0 deletions circle.yml
@@ -0,0 +1,15 @@
dependencies:
pre:
- ./circleci.sh install-deps
cache_directories:
- "~/dlang"

test:
override:
- ./circleci.sh style
- ./circleci.sh setup-repos
- ./circleci.sh coverage:
parallel: true

post:
- bash <(curl -s https://codecov.io/bash)
102 changes: 102 additions & 0 deletions circleci.sh
@@ -0,0 +1,102 @@
#!/bin/bash

set -uexo pipefail

HOST_DMD_VER=2.068.2 # same as in dmd/src/posix.mak
CURL_USER_AGENT="CirleCI $(curl --version | head -n 1)"
N=2

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

for i in {0..4}; do
if curl -fsS -A "$CURL_USER_AGENT" --max-time 5 https://dlang.org/install.sh -O; then
break
elif [ $i -ge 4 ]; then
sleep $((1 << $i))
else
echo 'Failed to download install script' 1>&2
exit 1
fi
done

source "$(CURL_USER_AGENT=\"$CURL_USER_AGENT\" bash install.sh dmd-$HOST_DMD_VER --activate)"
$DC --version
env
}

# clone dmd and druntime
clone() {
local url="$1"
local path="$2"
local branch="$3"
for i in {0..4}; do
if git clone --depth=1 --branch "$branch" "$url" "$path"; then
break
elif [ $i -lt 4 ]; then
sleep $((1 << $i))
else
echo "Failed to clone: ${url}"
exit 1
fi
done
}

# setup dmd and druntime
setup_repos()
{
# set a default in case we run into rate limit restrictions
local base_branch="master"
if [ -n "${CIRCLE_PR_NUMBER:-}" ]; then
base_branch=$(curl -fsSL https://api.github.com/repos/dlang/dmd/pulls/$CIRCLE_PR_NUMBER | jq -r '.base.ref')
else
base_branch=$CIRCLE_BRANCH
fi

clone https://github.com/dlang/dmd.git ../dmd $base_branch
clone https://github.com/dlang/druntime.git ../druntime $base_branch

# load environment for bootstrap compiler
source "$(CURL_USER_AGENT=\"$CURL_USER_AGENT\" bash ~/dlang/install.sh dmd-$HOST_DMD_VER --activate)"

# build dmd and druntime
make -j$N -C ../dmd/src -f posix.mak MODEL=$MODEL HOST_DMD=$DMD all
make -j$N -C ../druntime -f posix.mak MODEL=$MODEL HOST_DMD=$DMD
}

# verify style guide
style()
{
# load dmd to build dscanner
source "$(CURL_USER_AGENT=\"$CURL_USER_AGENT\" bash ~/dlang/install.sh dmd-$HOST_DMD_VER --activate)"
make -f posix.mak style
}

# run unittest with coverage
coverage()
{
make -f posix.mak clean
# remove all existing coverage files (just in case)
rm -rf $(find -name '*.lst')

# currently using the test_runner yields wrong code coverage results
# see https://github.com/dlang/phobos/pull/4719 for details
#ENABLE_COVERAGE="1" make -f posix.mak MODEL=$MODEL unittest-debug

# instead we run all tests individually
make -f posix.mak $(find std etc -name "*.d" | sed "s/[.]d$/.test/" | grep -vE '(std.algorithm.sorting|std.encoding|net.curl)' )
}

case $1 in
install-deps) install_deps ;;
coverage) coverage ;;
setup-repos) setup_repos ;;
esac
35 changes: 35 additions & 0 deletions posix.mak
Expand Up @@ -111,6 +111,10 @@ else
DFLAGS += -O -release
endif

ifdef ENABLE_COVERAGE
DFLAGS += -cov
endif

# Set DOTOBJ and DOTEXE
ifeq (,$(findstring win,$(OS)))
DOTOBJ:=.o
Expand Down Expand Up @@ -471,6 +475,37 @@ checkwhitespace: $(LIB)
$(DMD) $(DFLAGS) -defaultlib= -debuglib= $(LIB) -run ../dmd/src/checkwhitespace.d $(CWS_TOCHECK)

#############################
# Submission to Phobos are required to conform to the DStyle
# The tests below automate some, but not all parts of the DStyle guidelines.
# See also: http://dlang.org/dstyle.html
#############################

../dscanner:
git clone https://github.com/Hackerpilot/Dscanner ../dscanner
git -C ../dscanner checkout tags/v0.4.0-alpha.8
git -C ../dscanner submodule update --init --recursive

../dscanner/dsc: ../dscanner
# debug build is faster, but disable 'missing import' messages (missing core from druntime)
sed 's/dparse_verbose/StdLoggerDisableWarning/' -i ../dscanner/makefile
make -C ../dscanner githash debug

style: ../dscanner/dsc
@echo "Check for trailing whitespace"
grep -nr '[[:blank:]]$$' etc std ; test $$? -eq 1

@echo "Enforce whitespace before opening parenthesis"
grep -nrE "(for|foreach|foreach_reverse|if|while|switch|catch)\(" $$(find . -name '*.d') ; test $$? -eq 1

@echo "Enforce whitespace between colon(:) for import statements (doesn't catch everything)"
grep -nr 'import [^/,=]*:.*;' $$(find . -name '*.d') | grep -vE "import ([^ ]+) :\s"; test $$? -eq 1

@echo "Enforce Allman style"
grep -nrE '(if|for|foreach|foreach_reverse|while|unittest|switch|else|version) .*{$$' $$(find . -name '*.d'); test $$? -eq 1

# at the moment libdparse has problems to parse some modules (->excludes)
@echo "Running DScanner"
../dscanner/dsc --config .dscanner.ini --styleCheck $$(find etc std -type f -name '*.d' | grep -vE 'std/traits.d|std/typecons.d|std/conv.d') -I.

.PHONY : auto-tester-build
auto-tester-build: all checkwhitespace
Expand Down

0 comments on commit f2210fe

Please sign in to comment.