feat(CI): improve Travis configuration (#1486)

- use random DB names in order to detect statements which address a specific DB
- split compilation and DB check (DB check and dry run only have to run once)
- use separate shell scripts for easier module Travis integration
This commit is contained in:
Stoabrogga
2019-02-19 16:21:52 +01:00
committed by GitHub
parent 3a39aaeed5
commit e1c3433afc
5 changed files with 88 additions and 53 deletions

View File

@@ -16,29 +16,9 @@ services:
git:
depth: 1
matrix:
include:
- os: linux
addons:
apt:
packages:
- clang-3.8
env:
- TRAVIS_BUILD_ID="1"
- CCOMPILERC="clang-3.8"
- CCOMPILERCXX="clang++-3.8"
- os: linux
addons:
apt:
sources:
- llvm-toolchain-xenial-7
packages:
- clang-7
env:
- TRAVIS_BUILD_ID="2"
- CCOMPILERC="clang-7"
- CCOMPILERCXX="clang++-7"
env:
- TRAVIS_BUILD_ID="1"
- TRAVIS_BUILD_ID="2"
before_install:
- git config user.email "azerothcorebot@gmail.com" && git config user.name "AzerothCoreBot"
@@ -52,37 +32,10 @@ before_install:
- if [ "$TRAVIS_BUILD_ID" = "1" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ] && [[ -n "$GITHUB_API_KEY" ]]; then git add -A . && git diff --cached --quiet || git commit -am "Import pending SQL update file" && git push https://$GITHUB_API_KEY@github.com/$TRAVIS_REPO_SLUG.git $TRAVIS_BRANCH; fi
# sync staging with master
- if [ "$TRAVIS_BUILD_ID" = "1" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ] && [[ -n "$GITHUB_API_KEY" ]]; then git fetch origin staging:staging && git checkout staging && git merge --no-edit master && git push https://$GITHUB_API_KEY@github.com/$TRAVIS_REPO_SLUG.git staging; git checkout master; fi
- source ./apps/ci/ci-before_install.sh
install:
# install OS deps (apt-get)
- bash ./acore.sh "install-deps"
# create config file
- echo "CCOMPILERC=$CCOMPILERC" >> conf/config.sh
- echo "CCOMPILERCXX=$CCOMPILERCXX" >> conf/config.sh
- echo "MTHREADS=4" >> conf/config.sh
- echo "CWARNINGS=ON" >> conf/config.sh
- echo "CDEBUG=OFF" >> conf/config.sh
- echo "CTYPE=Release" >> conf/config.sh
- echo "CSCRIPTS=ON" >> conf/config.sh
- echo "CSERVERS=ON" >> conf/config.sh
- echo "CTOOLS=ON" >> conf/config.sh
- echo "CSCRIPTPCH=OFF" >> conf/config.sh
- echo "CCOREPCH=OFF" >> conf/config.sh
- echo "CCUSTOMOPTIONS='-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_FLAGS=\"-Werror\" -DCMAKE_CXX_FLAGS=\"-Werror\"'" >> conf/config.sh
- echo "DB_CHARACTERS_CONF=\"MYSQL_USER='root'; MYSQL_PASS=''; MYSQL_HOST='127.0.0.1';\"" >> conf/config.sh
- echo "DB_AUTH_CONF=\"MYSQL_USER='root'; MYSQL_PASS=''; MYSQL_HOST='127.0.0.1';\"" >> conf/config.sh
- echo "DB_WORLD_CONF=\"MYSQL_USER='root'; MYSQL_PASS=''; MYSQL_HOST='127.0.0.1';\"" >> conf/config.sh
# create and import mysql
- mysql -e "SET GLOBAL sql_mode = '';" # this is necessary because of mysql 5.7
- bash ./acore.sh "db-assembler" "import-all"
- source ./apps/ci/ci-install.sh
script:
# compile
- export CCACHE_CPP2=true
- ccache -s
- timeout 2580 bash ./acore.sh "compiler" "all"
- ccache -s
- git clone --depth=1 --branch=master --single-branch https://github.com/ac-data/ac-data.git /home/travis/build/azerothcore/azerothcore-wotlk/env/dist/data
- cp ./data/travis/worldserver.conf ./env/dist/etc/worldserver.conf
- ./env/dist/bin/worldserver --dry-run
- ./apps/ci-error-check.sh
- source ./apps/ci/ci-script.sh

24
apps/ci/ci-before_install.sh Executable file
View File

@@ -0,0 +1,24 @@
#!/bin/bash
if [ "$TRAVIS_BUILD_ID" = "1" ]
then
export CCOMPILERC="clang-3.8"
export CCOMPILERCXX="clang++-3.8"
echo "set root password"
export DB_RND_NAME=$(cat /dev/urandom | tr -dc 'a-z' | fold -w 5 | head -n 1)
sudo mysql -e "use mysql; update user set authentication_string=PASSWORD('$DB_RND_NAME') where User='root'; update user set plugin='mysql_native_password';FLUSH PRIVILEGES;"
sudo mysql_upgrade -u root -p$DB_RND_NAME
sudo service mysql restart
printf "[client]\npassword=%s" "$DB_RND_NAME" >~/.my.cnf
chmod 400 ~/.my.cnf
elif [ "$TRAVIS_BUILD_ID" = "2" ]
then
export CCOMPILERC="clang-7"
export CCOMPILERCXX="clang++-7"
echo "add custom APT repository llvm-toolchain-xenial-7"
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main" | sudo tee -a /etc/apt/sources.list
sudo apt-get update -qq
fi

42
apps/ci/ci-install.sh Executable file
View File

@@ -0,0 +1,42 @@
#!/bin/bash
echo "install OS deps (apt-get)"
bash ./acore.sh "install-deps"
if [ "$TRAVIS_BUILD_ID" = "1" ]
then
echo "install clang-3.8"
sudo apt-get install clang-3.8
elif [ "$TRAVIS_BUILD_ID" = "2" ]
then
echo "install clang-7"
sudo apt-get install clang-7
fi
echo "create config.sh"
cat >>conf/config.sh <<CONFIG_SH
CCOMPILERC=$CCOMPILERC
CCOMPILERCXX=$CCOMPILERCXX
MTHREADS=4
CWARNINGS=ON
CDEBUG=OFF
CTYPE=Release
CSCRIPTS=ON
CSERVERS=ON
CTOOLS=ON
CSCRIPTPCH=OFF
CCOREPCH=OFF
CCUSTOMOPTIONS='-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_C_FLAGS="-Werror" -DCMAKE_CXX_FLAGS="-Werror"'
DB_CHARACTERS_CONF="MYSQL_USER='root'; MYSQL_PASS='$DB_RND_NAME'; MYSQL_HOST='localhost';"
DB_AUTH_CONF="MYSQL_USER='root'; MYSQL_PASS='$DB_RND_NAME'; MYSQL_HOST='localhost';"
DB_WORLD_CONF="MYSQL_USER='root'; MYSQL_PASS='$DB_RND_NAME'; MYSQL_HOST='localhost';"
DB_AUTH_NAME=auth_$DB_RND_NAME
DB_CHARACTERS_NAME=characters_$DB_RND_NAME
DB_WORLD_NAME=world_$DB_RND_NAME
CONFIG_SH
if [ "$TRAVIS_BUILD_ID" = "1" ]
then
echo "import DB"
bash ./acore.sh "db-assembler" "import-all"
fi

16
apps/ci/ci-script.sh Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
echo "compile core"
export CCACHE_CPP2=true
ccache -s
timeout 2580 bash ./acore.sh "compiler" "all"
ccache -s
if [ "$TRAVIS_BUILD_ID" = "1" ]
then
echo "start worldserver dry-run"
git clone --depth=1 --branch=master --single-branch https://github.com/ac-data/ac-data.git /home/travis/build/azerothcore/azerothcore-wotlk/env/dist/data
sed -e "s/;;acore_auth/;$DB_RND_NAME;auth_$DB_RND_NAME/" -e "s/;;acore_world/;$DB_RND_NAME;world_$DB_RND_NAME/" -e "s/;;acore_characters/;$DB_RND_NAME;characters_$DB_RND_NAME/" ./data/travis/worldserver.conf >./env/dist/etc/worldserver.conf
./env/dist/bin/worldserver --dry-run
./apps/ci/ci-error-check.sh
fi