name: build

on:
  push:
  pull_request:

jobs:

  AC-Eluna:
    strategy:
      fail-fast: false
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: recursive
          repository: azerothcore/azerothcore-wotlk
          ref: 'master'
      - uses: actions/checkout@v2
        with:
          submodules: false
          repository: azerothcore/mod-eluna-lua-engine
          path: modules/mod-eluna-lua-engine
      - uses: actions/checkout@v2
        with:
          path: modules/mod-eluna-lua-engine/LuaEngine
      - name: Configure OS
        run: |
          # Copy paste of https://github.com/azerothcore/azerothcore-wotlk/blob/master/apps/ci/ci-install.sh

          cat >>conf/config.sh <<CONFIG_SH
          MTHREADS=4
          CWARNINGS=ON
          CDEBUG=OFF
          CTYPE=Release
          CSCRIPTS=static
          CUNIT_TESTS=ON
          CSERVERS=ON
          CTOOLS=ON
          CSCRIPTPCH=ON
          CCOREPCH=ON
          CCUSTOMOPTIONS='-DCMAKE_C_FLAGS="-Werror" -DCMAKE_CXX_FLAGS="-Werror"'
          DB_CHARACTERS_CONF="MYSQL_USER='root'; MYSQL_PASS='root'; MYSQL_HOST='localhost';"
          DB_AUTH_CONF="MYSQL_USER='root'; MYSQL_PASS='root'; MYSQL_HOST='localhost';"
          DB_WORLD_CONF="MYSQL_USER='root'; MYSQL_PASS='root'; MYSQL_HOST='localhost';"
          CONFIG_SH

          time sudo apt-get update -y
          # time sudo apt-get upgrade -y
          time sudo apt-get install -y git lsb-release sudo ccache
          time ./acore.sh install-deps

          time sudo apt-get install -y clang-11
          echo "CCOMPILERC=\"clang-11\"" >> ./conf/config.sh
          echo "CCOMPILERCXX=\"clang++-11\"" >> ./conf/config.sh
      - name: Import db
        run: source ./apps/ci/ci-import-db.sh
      - name: Build
        run: source ./apps/ci/ci-compile.sh
      - name: Dry run
        run: source ./apps/ci/ci-worldserver-dry-run.sh
      - name: Check startup errors
        run: source ./apps/ci/ci-error-check.sh
