diff --git a/.github/workflows/npc_db_validation.yml b/.github/workflows/npc_db_validation.yml new file mode 100644 index 0000000000..8d55928d59 --- /dev/null +++ b/.github/workflows/npc_db_validation.yml @@ -0,0 +1,79 @@ +name: Validate NPC Scripts and DB Changes +# npc_db_validation.yml + +# For NPC and DB validation we only need two builds: one of Renewal and one for Pre-Renewal checks. +# NPC scripts and database files are not platform dependent, so we can achieve this validation using only a simple linux setup. + +on: + push: + paths: + # Always trigger all Github Actions if an action or something CI related was changed + - '.github/workflows/**' + - 'tools/ci/**' + # This workflow should run when a file in either the db/ or npc/ directory has been modified. + - 'db/**' + - 'npc/**' + +jobs: + build: + # Github Actions checks for '[ci skip]', '[skip ci]', '[no ci]', '[skip actions]', or '[actions skip]' but not a hyphenated version. + # It's a catch-all incase a Pull Request has been opened and someone is on auto-pilot. + if: "!contains(github.event.head_commit.message, 'ci-skip')" + runs-on: ${{ matrix.os }} + strategy: + matrix: + # The ubuntu-latest label currently points to ubuntu-18.04. + # Available: ubuntu-20.04, ubuntu-18.04 + os: [ubuntu-latest] + # Only a single version of GCC is required for validating NPC scripts and database changes. + gcc: ['10'] + # We run build checks for both Renewal and PRE-Renewal + mode: ['PRE', 'RE'] + + steps: + - uses: actions/checkout@v2 + + # A simple 'yes' and 'no' can be confusing, so we use names to display in the current job then convert them for use in the compiler. + - name: Variable Parsing - PRE + if: ${{ matrix.mode == 'PRE' }} + run: | + echo "PRERE=yes" >> $GITHUB_ENV + - name: Variable Parsing - RE + if: ${{ matrix.mode == 'RE' }} + run: | + echo "PRERE=no" >> $GITHUB_ENV + + - name: Update & Install packages + # Ubuntu runners already have most of the packages rAthena requires to build. + # https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md + run: | + sudo apt update + sudo apt install zlib1g-dev libpcre3-dev gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }} + + - name: Start MySQL + run: sudo systemctl start mysql.service + + - name: Setup Database and import table data + run: ./tools/ci/sql.sh + + - name: Command - configure + env: + CONFIGURE_FLAGS: 'CC=gcc-${{ matrix.gcc }} CXX=g++-${{ matrix.gcc }} --enable-prere=${{ env.PRERE }} --enable-buildbot=yes' + run: ./configure $CONFIGURE_FLAGS + + # npc.sh enables all NPC scripts in the custom and test folders. + - name: Enable All NPCs for Testing + run: ./tools/ci/npc.sh + + - name: Command - make clean + run: make clean + + # Create import directories + - name: Command - make import + run: make import + + - name: Command - make map + run: make map + + - name: Run Once - map-server + run: ./map-server --run-once diff --git a/tools/ci/import_sql.sh b/tools/ci/import_sql.sh deleted file mode 100755 index 933457b3d6..0000000000 --- a/tools/ci/import_sql.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash -# import_sql.sh -# This file is used by Github Actions - -function aborterror { - echo $@ - exit 1 -} - -DB_ROOT=root -DB_ROOTPW=root -DB_NAME=ragnarok -mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/main.sql || aborterror "Unable to import main database." -mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/logs.sql || aborterror "Unable to import logs database." -mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/item_cash_db.sql || aborterror "Unable to import cash item table." -mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/item_cash_db2.sql || aborterror "Unable to import cash item 2 table." -mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/item_db.sql || aborterror "Unable to import pre-renewal item table structure." -mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/item_db_usable.sql || aborterror "Unable to import pre-renewal usable item table." -mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/item_db_equip.sql || aborterror "Unable to import pre-renewal equip item table." -mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/item_db_etc.sql || aborterror "Unable to import pre-renewal etc item table." -mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/item_db2.sql || aborterror "Unable to import pre-renewal item 2 table." -mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/item_db_re.sql || aborterror "Unable to import renewal item table structure." -mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/item_db_re_usable.sql || aborterror "Unable to import renewal usable item table." -mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/item_db_re_equip.sql || aborterror "Unable to import renewal equip item table." -mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/item_db_re_etc.sql || aborterror "Unable to import renewal etc item table." -mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/item_db2_re.sql || aborterror "Unable to import renewal item 2 table." -mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/mob_db.sql || aborterror "Unable to import pre-renewal monster table." -mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/mob_db2.sql || aborterror "Unable to import pre-renewal monster 2 table." -mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/mob_db_re.sql || aborterror "Unable to import renewal monster table." -mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/mob_db2_re.sql || aborterror "Unable to import renewal monster 2 table." -mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/mob_skill_db.sql || aborterror "Unable to import pre-renewal monster skill table." -mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/mob_skill_db2.sql || aborterror "Unable to import pre-renewal monster skill 2 table." -mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/mob_skill_db_re.sql || aborterror "Unable to import renewal monster skill table." -mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/mob_skill_db2_re.sql || aborterror "Unable to import renewal monster skill 2 table." -mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/roulette_default_data.sql || aborterror "Unable to import roulette table." diff --git a/tools/ci/sql.sh b/tools/ci/sql.sh index d0f0918c91..b3ac493351 100755 --- a/tools/ci/sql.sh +++ b/tools/ci/sql.sh @@ -5,28 +5,38 @@ function aborterror { exit 1 } -mysql -u $DB_ROOT -e "CREATE DATABASE $DB_NAME;" || aborterror "Unable to create database." -mysql -u $DB_ROOT $DB_NAME < sql-files/main.sql || aborterror "Unable to import main database." -mysql -u $DB_ROOT $DB_NAME < sql-files/logs.sql || aborterror "Unable to import logs database." -mysql -u $DB_ROOT $DB_NAME < sql-files/item_cash_db.sql || aborterror "Unable to import cash item table." -mysql -u $DB_ROOT $DB_NAME < sql-files/item_cash_db2.sql || aborterror "Unable to import cash item 2 table." -mysql -u $DB_ROOT $DB_NAME < sql-files/item_db.sql || aborterror "Unable to import pre-renewal item table structure." -mysql -u $DB_ROOT $DB_NAME < sql-files/item_db_usable.sql || aborterror "Unable to import pre-renewal usable item table." -mysql -u $DB_ROOT $DB_NAME < sql-files/item_db_equip.sql || aborterror "Unable to import pre-renewal equip item table." -mysql -u $DB_ROOT $DB_NAME < sql-files/item_db_etc.sql || aborterror "Unable to import pre-renewal etc item table." -mysql -u $DB_ROOT $DB_NAME < sql-files/item_db2.sql || aborterror "Unable to import pre-renewal item 2 table." -mysql -u $DB_ROOT $DB_NAME < sql-files/item_db_re.sql || aborterror "Unable to import renewal item table structure." -mysql -u $DB_ROOT $DB_NAME < sql-files/item_db_re_usable.sql || aborterror "Unable to import renewal usable item table." -mysql -u $DB_ROOT $DB_NAME < sql-files/item_db_re_equip.sql || aborterror "Unable to import renewal equip item table." -mysql -u $DB_ROOT $DB_NAME < sql-files/item_db_re_etc.sql || aborterror "Unable to import renewal etc item table." -mysql -u $DB_ROOT $DB_NAME < sql-files/item_db2_re.sql || aborterror "Unable to import renewal item 2 table." -mysql -u $DB_ROOT $DB_NAME < sql-files/mob_db.sql || aborterror "Unable to import pre-renewal monster table." -mysql -u $DB_ROOT $DB_NAME < sql-files/mob_db2.sql || aborterror "Unable to import pre-renewal monster 2 table." -mysql -u $DB_ROOT $DB_NAME < sql-files/mob_db_re.sql || aborterror "Unable to import renewal monster table." -mysql -u $DB_ROOT $DB_NAME < sql-files/mob_db2_re.sql || aborterror "Unable to import renewal monster 2 table." -mysql -u $DB_ROOT $DB_NAME < sql-files/mob_skill_db.sql || aborterror "Unable to import pre-renewal monster skill table." -mysql -u $DB_ROOT $DB_NAME < sql-files/mob_skill_db2.sql || aborterror "Unable to import pre-renewal monster skill 2 table." -mysql -u $DB_ROOT $DB_NAME < sql-files/mob_skill_db_re.sql || aborterror "Unable to import renewal monster skill table." -mysql -u $DB_ROOT $DB_NAME < sql-files/mob_skill_db2_re.sql || aborterror "Unable to import renewal monster skill 2 table." -mysql -u $DB_ROOT $DB_NAME < sql-files/roulette_default_data.sql || aborterror "Unable to import roulette table." -mysql -u $DB_ROOT -e "GRANT SELECT,INSERT,UPDATE,DELETE ON $DB_NAME.* TO '$DB_USER'@'$DB_HOST' IDENTIFIED BY '$DB_PASS';" +# Github Actions default login data +DB_ROOT=root +DB_ROOTPW=root +# rAthena default MySQL data +DB_HOST=localhost +DB_NAME=ragnarok +DB_USER=ragnarok +DB_PASS=ragnarok + +mysql -u $DB_ROOT -p$DB_ROOTPW -e "CREATE DATABASE $DB_NAME;" || aborterror "Unable to create database." +mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/main.sql || aborterror "Unable to import main database." +mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/logs.sql || aborterror "Unable to import logs database." +mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/item_cash_db.sql || aborterror "Unable to import cash item table." +mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/item_cash_db2.sql || aborterror "Unable to import cash item 2 table." +mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/item_db.sql || aborterror "Unable to import pre-renewal item table structure." +mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/item_db_usable.sql || aborterror "Unable to import pre-renewal usable item table." +mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/item_db_equip.sql || aborterror "Unable to import pre-renewal equip item table." +mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/item_db_etc.sql || aborterror "Unable to import pre-renewal etc item table." +mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/item_db2.sql || aborterror "Unable to import pre-renewal item 2 table." +mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/item_db_re.sql || aborterror "Unable to import renewal item table structure." +mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/item_db_re_usable.sql || aborterror "Unable to import renewal usable item table." +mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/item_db_re_equip.sql || aborterror "Unable to import renewal equip item table." +mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/item_db_re_etc.sql || aborterror "Unable to import renewal etc item table." +mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/item_db2_re.sql || aborterror "Unable to import renewal item 2 table." +mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/mob_db.sql || aborterror "Unable to import pre-renewal monster table." +mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/mob_db2.sql || aborterror "Unable to import pre-renewal monster 2 table." +mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/mob_db_re.sql || aborterror "Unable to import renewal monster table." +mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/mob_db2_re.sql || aborterror "Unable to import renewal monster 2 table." +mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/mob_skill_db.sql || aborterror "Unable to import pre-renewal monster skill table." +mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/mob_skill_db2.sql || aborterror "Unable to import pre-renewal monster skill 2 table." +mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/mob_skill_db_re.sql || aborterror "Unable to import renewal monster skill table." +mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/mob_skill_db2_re.sql || aborterror "Unable to import renewal monster skill 2 table." +mysql -u $DB_ROOT -p$DB_ROOTPW $DB_NAME < sql-files/roulette_default_data.sql || aborterror "Unable to import roulette table." +mysql -u $DB_ROOT -p$DB_ROOTPW -e "CREATE USER '$DB_USER'@'$DB_HOST' IDENTIFIED BY '$DB_PASS';" +mysql -u $DB_ROOT -p$DB_ROOTPW -e "GRANT SELECT,INSERT,UPDATE,DELETE ON $DB_NAME.* TO '$DB_USER'@'$DB_HOST';"