-
-
Notifications
You must be signed in to change notification settings - Fork 988
/
docker.sh
executable file
·154 lines (136 loc) · 5.28 KB
/
docker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
echo "Using docker:"
echo "BRANCH: $BRANCH"
echo "IMAGE: $IMAGE"
echo "NLS: $NLS"
echo "TOOL: $TOOL"
echo "CC: $CC"
echo "CXX: $CXX"
echo "CXX_STD: $CXX_STD"
echo "CFG: $CFG"
echo "LTO: $LTO"
echo "CACHE_DIR: $CACHE_DIR"
# set the fake display for unit tests
export DISPLAY=:99.0
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1024x768x24
error() { printf '%s\n' "$*"; }
die() { error "$*"; exit 1; }
# print given message ($1) and execute given command; sets EXIT_VAL on failure
execute() {
local message=$1; shift
printf 'Executing %s\n' "$message"
if "$@"; then
: # success
else
EXIT_VAL=$?
error "$message failed! ($*)"
fi
}
checkindent() {
make -C data/tools reindent &&
git diff-index --quiet HEAD
}
EXIT_VAL=-1
if [ "$NLS" == "only" ]; then
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
./utils/CI/check_utf8.sh || exit 1
./utils/CI/utf8_bom_dog.sh || exit 1
echo "Checked for invalod characters"
cmake -DENABLE_NLS=true -DENABLE_GAME=false -DENABLE_SERVER=false -DENABLE_CAMPAIGN_SERVER=false -DENABLE_TESTS=false -DENABLE_POT_UPDATE_TARGET=TRUE
make update-po4a-man || exit 1
echo "Ran umake pdate-po4a-man"
make update-po4a-manual || exit 1
echo "Ran make update-po4a-manual"
make pot-update || exit 1
echo "Ran make pot-update"
make mo-update || exit 1
echo "Ran make mo-update"
make clean
scons translations build=release --debug=time nls=true jobs=2 || exit 1
echo "Ran scons translations"
scons pot-update || exit 1
echo "Ran scons pot-update"
scons update-po4a || exit 1
echo "Ran scons update-po4a"
scons manual || exit 1
exit 0
elif [ "$IMAGE" == "flatpak" ]; then
# docker's --volume means the directory is on a separate filesystem
# flatpak-builder doesn't support this
# therefore manually move stuff between where flatpak needs it and where CI caching can see it
rm -R .flatpak-builder/*
cp -R "$CACHE_DIR"/. .flatpak-builder/
jq '.modules[2].sources[0]={"type":"dir","path":"/home/wesnoth-CI"} | ."build-options".env.FLATPAK_BUILDER_N_JOBS="2"' packaging/flatpak/org.wesnoth.Wesnoth.json > utils/dockerbuilds/CI/org.wesnoth.Wesnoth.json
flatpak-builder --ccache --force-clean --disable-rofiles-fuse wesnoth-app utils/dockerbuilds/CI/org.wesnoth.Wesnoth.json
EXIT_VAL=$?
rm -R "$CACHE_DIR"/*
cp -R .flatpak-builder/. "$CACHE_DIR"/
chmod -R 777 "$CACHE_DIR"/
exit $EXIT_VAL
elif [ "$IMAGE" == "mingw" ]; then
scons wesnoth wesnothd build="$CFG" \
cxx_std=$CXX_STD strict=false \
nls=false enable_lto="$LTO" jobs=2 --debug=time \
arch=x86-64 prefix=/windows/mingw64 gtkdir=/windows/mingw64 host=x86_64-w64-mingw32
EXIT_VAL=$?
exit $EXIT_VAL
elif [ "$IMAGE" == "steamrt" ]; then
scons ctool=$CC cxxtool=$CXX boostdir=/usr/local/include boostlibdir=/usr/local/lib extra_flags_config=-lrt \
cxx_std=$CXX_STD strict=true nls="$NLS" enable_lto="$LTO" jobs=2 --debug=time \
build="$CFG"
EXIT_VAL=$?
exit $EXIT_VAL
else
if [ "$TOOL" == "cmake" ]; then
export CCACHE_MAXSIZE=3000M
export CCACHE_COMPILERCHECK=content
export CCACHE_DIR="$CACHE_DIR"
cmake -DCMAKE_BUILD_TYPE="$CFG" -DENABLE_GAME=true -DENABLE_SERVER=true -DENABLE_CAMPAIGN_SERVER=true -DENABLE_TESTS=true -DENABLE_NLS="$NLS" \
-DEXTRA_FLAGS_CONFIG="-pipe" -DENABLE_STRICT_COMPILATION=true -DENABLE_LTO="$LTO" -DLTO_JOBS=2 -DENABLE_MYSQL=true \
-DCXX_STD="$CXX_STD" -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache && \
make VERBOSE=1 -j2
EXIT_VAL=$?
ccache -s
ccache -z
# remove once 1804 isn't used anymore
elif [ "$IMAGE" == "1804" ]; then
scons wesnoth wesnothd campaignd boost_unit_tests build="$CFG" \
ctool="$CC" cxxtool="$CXX" cxx_std="$CXX_STD" \
extra_flags_config="-pipe" strict=true forum_user_handler=false \
nls="$NLS" enable_lto="$LTO" jobs=2 --debug=time
EXIT_VAL=$?
else
scons wesnoth wesnothd campaignd boost_unit_tests build="$CFG" \
ctool="$CC" cxxtool="$CXX" cxx_std="$CXX_STD" \
extra_flags_config="-pipe" strict=true forum_user_handler=true \
nls="$NLS" enable_lto="$LTO" jobs=2 --debug=time
EXIT_VAL=$?
fi
fi
if [ $EXIT_VAL != 0 ]; then
exit $EXIT_VAL
fi
# rename debug executables to what the tests expect
if [ "$CFG" == "debug" ]; then
mv wesnoth-debug wesnoth
mv wesnothd-debug wesnothd
mv campaignd-debug campaignd
mv boost_unit_tests-debug boost_unit_tests
fi
execute "WML validation" ./utils/CI/schema_validation.sh
execute "WML indentation check" checkindent
if [ "$IMAGE" != "1804" ]; then
execute "Doxygen check" ./utils/CI/doxygen-check.sh
fi
execute "WML tests" ./run_wml_tests -g -v -c -t 20
execute "Play tests" ./utils/CI/play_test_executor.sh
execute "Boost unit tests" ./utils/CI/test_executor.sh
if [ -f "errors.log" ]; then
error $'\n*** \n*\n* Errors reported in wml unit tests, here is errors.log...\n*\n*** \n'
cat errors.log
fi
mv wesnoth "$CACHE_DIR"/wesnoth
mv wesnothd "$CACHE_DIR"/wesnothd
exit $EXIT_VAL