generate.sh 2.11 KB
Newer Older
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
#!/bin/sh

apt-get update
apt-get upgrade -y
apt-get install -y \
	build-essential \
	dbus \
	dbus-x11 \
	git \
	libcairo2-dev \
	libgirepository1.0-dev \
	libglib2.0-dev \
	libgtk-3-dev \
	libreadline-dev \
	libxml2 \
	libxml2-dev \
	nettle-dev \
	parallel \
	pkg-config \
	valgrind

VERSION=$(cat dist/version)

cp dist/tarot-$VERSION.tar.gz . || exit 1
tar xf tarot-$VERSION.tar.gz || exit 1
mkdir build || exit 1
cd build/
../tarot-$VERSION/configure \
    --enable-silent-rules=yes \
    --enable-valgrind=yes \
    || (cat config.log; exit 1)
make -j 16 || exit 1
make install || exit 1

export PATH="/usr/local/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH"

mkdir /root/.ssh || exit 1
echo "$SSH_KEY" > /root/.ssh/id_rsa || exit 1
echo "$SSH_KEY_PUB" > /root/.ssh/id_rsa.pub || exit 1
echo "$SSH_KNOWN_HOSTS" > /root/.ssh/known_hosts || exit 1
chmod go-rwx /root/.ssh/id_rsa || exit 1
git config --global user.email "vivien@planete-kraus.eu" || exit 1
git config --global user.name "Gitlab CI for the tarot package" || exit 1
git clone git@framagit.org:play-tarot/datasets.git dataset/ || exit 1

rm -rf dataset/generated/mcts
rm -rf dataset/generated/stacking

mkdir -p dataset/generated/mcts || exit 1
mkdir -p dataset/generated/stacking || exit 1

seq 1 100 | parallel ../tarot-$VERSION/ci/generate-seed.sh {}

if test "x$CI_COMMIT_TAG" != "x" \
	|| test "x$CI_COMMIT_REF_NAME" = "xmaster" \
	|| test "x$CI_COMMIT_REF_NAME" = "xdevelop"
then
    cd dataset
    git checkout -b "update-generated-from-$VERSION" || exit 1
    if git add .
    then
	git commit -m"Add the generated datasets from version $VERSION" || exit 1
	git push origin "update-generated-from-$VERSION" || exit 1
    fi
    DATA=$(cat <<EOF
{
  "id": $CI_PROJECT_ID,
  "source_branch": "update-generated-from-$VERSION",
  "target_branch": "master",
  "title": "Update with the generated games for version $VERSION",
  "remove_source_branch": true
}
EOF
	   )
    curl \
	--request POST \
	--header "Content-Type: application/json" \
	--header "PRIVATE-TOKEN: $PRIVATE_TOKEN" \
	--data "$DATA" \
	"$CI_API_V4_URL/projects/46125/merge_requests" \
	|| exit 1
fi