Skip to content

Commit ba5f55a

Browse files
committed
Switch to CircleCi
1 parent 41a1d2b commit ba5f55a

File tree

4 files changed

+152
-38
lines changed

4 files changed

+152
-38
lines changed

.travis.yml

-38
This file was deleted.

circle.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
dependencies:
2+
pre:
3+
- ./circleci.sh install-deps
4+
cache_directories:
5+
- "~/dlang"
6+
7+
test:
8+
override:
9+
- ./circleci.sh style
10+
- ./circleci.sh setup-repos
11+
- ./circleci.sh coverage:
12+
parallel: true
13+
14+
post:
15+
- bash <(curl -s https://codecov.io/bash)

circleci.sh

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
#!/bin/bash
2+
3+
set -uexo pipefail
4+
5+
HOST_DMD_VER=2.068.2 # same as in dmd/src/posix.mak
6+
CURL_USER_AGENT="CirleCI $(curl --version | head -n 1)"
7+
N=2
8+
9+
case $CIRCLE_NODE_INDEX in
10+
0) MODEL=64 ;;
11+
1) MODEL=32 ;;
12+
esac
13+
14+
install_deps() {
15+
if [ $MODEL -eq 32 ]; then
16+
sudo apt-get update
17+
sudo apt-get install g++-multilib
18+
fi
19+
20+
for i in {0..4}; do
21+
if curl -fsS -A "$CURL_USER_AGENT" --max-time 5 https://dlang.org/install.sh -O; then
22+
break
23+
elif [ $i -ge 4 ]; then
24+
sleep $((1 << $i))
25+
else
26+
echo 'Failed to download install script' 1>&2
27+
exit 1
28+
fi
29+
done
30+
31+
source "$(CURL_USER_AGENT=\"$CURL_USER_AGENT\" bash install.sh dmd-$HOST_DMD_VER --activate)"
32+
$DC --version
33+
env
34+
}
35+
36+
# clone dmd and druntime
37+
clone() {
38+
local url="$1"
39+
local path="$2"
40+
local branch="$3"
41+
for i in {0..4}; do
42+
if git clone --depth=1 --branch "$branch" "$url" "$path"; then
43+
break
44+
elif [ $i -lt 4 ]; then
45+
sleep $((1 << $i))
46+
else
47+
echo "Failed to clone: ${url}"
48+
exit 1
49+
fi
50+
done
51+
}
52+
53+
# setup dmd and druntime
54+
setup_repos()
55+
{
56+
# set a default in case we run into rate limit restrictions
57+
local base_branch="master"
58+
if [ -n "${CIRCLE_PR_NUMBER:-}" ]; then
59+
base_branch=$(curl -fsSL https://api.github.com/repos/dlang/dmd/pulls/$CIRCLE_PR_NUMBER | jq -r '.base.ref')
60+
else
61+
base_branch=$CIRCLE_BRANCH
62+
fi
63+
64+
clone https://github.com/dlang/dmd.git ../dmd $base_branch
65+
clone https://github.com/dlang/druntime.git ../druntime $base_branch
66+
67+
# load environment for bootstrap compiler
68+
source "$(CURL_USER_AGENT=\"$CURL_USER_AGENT\" bash ~/dlang/install.sh dmd-$HOST_DMD_VER --activate)"
69+
70+
# build dmd and druntime
71+
make -j$N -C ../dmd/src -f posix.mak MODEL=$MODEL HOST_DMD=$DMD all
72+
make -j$N -C ../druntime -f posix.mak MODEL=$MODEL HOST_DMD=$DMD
73+
}
74+
75+
# verify style guide
76+
style()
77+
{
78+
# load dmd to build dscanner
79+
source "$(CURL_USER_AGENT=\"$CURL_USER_AGENT\" bash ~/dlang/install.sh dmd-$HOST_DMD_VER --activate)"
80+
make -f posix.mak style
81+
}
82+
83+
# run unittest with coverage
84+
coverage()
85+
{
86+
make -f posix.mak clean
87+
# remove all existing coverage files (just in case)
88+
rm -rf $(find -name '*.lst')
89+
90+
# currently using the test_runner yields wrong code coverage results
91+
# see https://github.com/dlang/phobos/pull/4719 for details
92+
#ENABLE_COVERAGE="1" make -f posix.mak MODEL=$MODEL unittest-debug
93+
94+
# instead we run all tests individually
95+
make -f posix.mak $(find std etc -name "*.d" | sed "s/[.]d$/.test/" | grep -vE '(std.algorithm.sorting|std.encoding|net.curl)' )
96+
}
97+
98+
case $1 in
99+
install-deps) install_deps ;;
100+
coverage) coverage ;;
101+
setup-repos) setup_repos ;;
102+
esac

posix.mak

+35
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ else
111111
DFLAGS += -O -release
112112
endif
113113

114+
ifdef ENABLE_COVERAGE
115+
DFLAGS += -cov
116+
endif
117+
114118
# Set DOTOBJ and DOTEXE
115119
ifeq (,$(findstring win,$(OS)))
116120
DOTOBJ:=.o
@@ -471,6 +475,37 @@ checkwhitespace: $(LIB)
471475
$(DMD) $(DFLAGS) -defaultlib= -debuglib= $(LIB) -run ../dmd/src/checkwhitespace.d $(CWS_TOCHECK)
472476

473477
#############################
478+
# Submission to Phobos are required to conform to the DStyle
479+
# The tests below automate some, but not all parts of the DStyle guidelines.
480+
# See also: http://dlang.org/dstyle.html
481+
#############################
482+
483+
../dscanner:
484+
git clone https://github.com/Hackerpilot/Dscanner ../dscanner
485+
git -C ../dscanner checkout tags/v0.4.0-alpha.8
486+
git -C ../dscanner submodule update --init --recursive
487+
488+
../dscanner/dsc: ../dscanner
489+
# debug build is faster, but disable 'missing import' messages (missing core from druntime)
490+
sed 's/dparse_verbose/StdLoggerDisableWarning/' -i ../dscanner/makefile
491+
make -C ../dscanner githash debug
492+
493+
style: ../dscanner/dsc
494+
@echo "Check for trailing whitespace"
495+
grep -nr '[[:blank:]]$$' etc std ; test $$? -eq 1
496+
497+
@echo "Enforce whitespace before opening parenthesis"
498+
grep -nrE "(for|foreach|foreach_reverse|if|while|switch|catch)\(" $$(find . -name '*.d') ; test $$? -eq 1
499+
500+
@echo "Enforce whitespace between colon(:) for import statements (doesn't catch everything)"
501+
grep -nr 'import [^/,=]*:.*;' $$(find . -name '*.d') | grep -vE "import ([^ ]+) :\s"; test $$? -eq 1
502+
503+
@echo "Enforce Allman style"
504+
grep -nrE '(if|for|foreach|foreach_reverse|while|unittest|switch|else|version) .*{$$' $$(find . -name '*.d'); test $$? -eq 1
505+
506+
# at the moment libdparse has problems to parse some modules (->excludes)
507+
@echo "Running DScanner"
508+
../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.
474509

475510
.PHONY : auto-tester-build
476511
auto-tester-build: all checkwhitespace

0 commit comments

Comments
 (0)