From e2f196580e9d187e7b2745a7d6cf1877c6235ff4 Mon Sep 17 00:00:00 2001 From: Stoabrogga <38475780+Stoabrogga@users.noreply.github.com> Date: Sat, 16 Mar 2019 15:25:51 +0100 Subject: [PATCH] feat(CI): improve Travis build time (#1573) * feat(CI): improve Travis build time --- .travis.yml | 71 +++++++++++++------ apps/ci/ci-compile.sh | 9 +++ apps/ci/ci-import-db.sh | 9 +++ apps/ci/ci-install.sh | 8 +-- ...ci-script.sh => ci-worldserver-dry-run.sh} | 6 -- 5 files changed, 70 insertions(+), 33 deletions(-) create mode 100755 apps/ci/ci-compile.sh create mode 100755 apps/ci/ci-import-db.sh rename apps/ci/{ci-script.sh => ci-worldserver-dry-run.sh} (83%) diff --git a/.travis.yml b/.travis.yml index a99c46624..5d53e3499 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,26 +16,57 @@ services: git: depth: 1 -env: - - TRAVIS_BUILD_ID="1" - - TRAVIS_BUILD_ID="2" +stages: + - prepare_cache + - run -before_install: - - git config user.email "azerothcorebot@gmail.com" && git config user.name "AzerothCoreBot" - - if [ "$TRAVIS_BUILD_ID" = "1" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then cd bin/; fi - # import pending sql - - if [ "$TRAVIS_BUILD_ID" = "1" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ]; then source acore-db-pendings; fi - - if [ "$TRAVIS_BUILD_ID" = "1" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then cd ..; fi - # push changes to git if any - - if [ "$TRAVIS_BUILD_ID" = "1" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then git fetch --unshallow; fi - - if [ "$TRAVIS_BUILD_ID" = "1" ] && [ "$TRAVIS_PULL_REQUEST" = "false" ]; then git checkout $TRAVIS_BRANCH; fi - - 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..." -m "Referenced commit(s):$COMMIT_HASH" && 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 +jobs: + include: + - stage: prepare_cache + env: TRAVIS_BUILD_ID="1" + before_install: + - git config user.email "azerothcorebot@gmail.com" && git config user.name "AzerothCoreBot" + - if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then cd bin/; fi + # import pending sql + - if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "$TRAVIS_BRANCH" = "master" ]; then source acore-db-pendings; fi + - if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then cd ..; fi + # push changes to git if any + - if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then git fetch --unshallow; fi + - if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then git checkout $TRAVIS_BRANCH; fi + - if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [[ -n "$GITHUB_API_KEY" ]]; then git add -A . && git diff --cached --quiet || git commit -am "Import pending SQL update file..." -m "Referenced commit(s):$COMMIT_HASH" && git push https://$GITHUB_API_KEY@github.com/$TRAVIS_REPO_SLUG.git $TRAVIS_BRANCH; fi + # sync staging with master + - if [ "$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: + - source ./apps/ci/ci-install.sh OFF + script: + - source ./apps/ci/ci-compile.sh -install: - - source ./apps/ci/ci-install.sh + - stage: run + env: TRAVIS_BUILD_ID="1" + before_install: + - source ./apps/ci/ci-before_install.sh + install: + - source ./apps/ci/ci-install.sh ON + - source ./apps/ci/ci-import-db.sh + script: + - source ./apps/ci/ci-compile.sh + - source ./apps/ci/ci-worldserver-dry-run.sh -script: - - source ./apps/ci/ci-script.sh + - stage: prepare_cache + env: TRAVIS_BUILD_ID="2" + before_install: + - source ./apps/ci/ci-before_install.sh + install: + - source ./apps/ci/ci-install.sh OFF + script: + - source ./apps/ci/ci-compile.sh + + - stage: run + env: TRAVIS_BUILD_ID="2" + before_install: + - source ./apps/ci/ci-before_install.sh + install: + - source ./apps/ci/ci-install.sh ON + script: + - source ./apps/ci/ci-compile.sh diff --git a/apps/ci/ci-compile.sh b/apps/ci/ci-compile.sh new file mode 100755 index 000000000..78c6c2e5c --- /dev/null +++ b/apps/ci/ci-compile.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +echo "compile core" +export CCACHE_CPP2=true +ccache -s +timeout 2700 bash ./acore.sh "compiler" "all" +ccache -s diff --git a/apps/ci/ci-import-db.sh b/apps/ci/ci-import-db.sh new file mode 100755 index 000000000..98d6fcf0c --- /dev/null +++ b/apps/ci/ci-import-db.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +if [ "$TRAVIS_BUILD_ID" = "1" ] +then + echo "import DB" + bash ./acore.sh "db-assembler" "import-all" +fi diff --git a/apps/ci/ci-install.sh b/apps/ci/ci-install.sh index 090da4a73..fe40322b6 100755 --- a/apps/ci/ci-install.sh +++ b/apps/ci/ci-install.sh @@ -23,7 +23,7 @@ MTHREADS=$(expr $(grep -c ^processor /proc/cpuinfo) + 2) CWARNINGS=ON CDEBUG=OFF CTYPE=Release -CSCRIPTS=ON +CSCRIPTS=$1 CSERVERS=ON CTOOLS=ON CSCRIPTPCH=OFF @@ -36,9 +36,3 @@ 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 diff --git a/apps/ci/ci-script.sh b/apps/ci/ci-worldserver-dry-run.sh similarity index 83% rename from apps/ci/ci-script.sh rename to apps/ci/ci-worldserver-dry-run.sh index 91e7e0e88..8c7a4929d 100755 --- a/apps/ci/ci-script.sh +++ b/apps/ci/ci-worldserver-dry-run.sh @@ -2,12 +2,6 @@ set -e -echo "compile core" -export CCACHE_CPP2=true -ccache -s -timeout 2700 bash ./acore.sh "compiler" "all" -ccache -s - if [ "$TRAVIS_BUILD_ID" = "1" ] then echo "start worldserver dry-run"