|
| 1 | +name: E2E OpenBW Linux |
| 2 | + |
| 3 | +on: |
| 4 | + - pull_request |
| 5 | + |
| 6 | +jobs: |
| 7 | + e2e: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + timeout-minutes: 10 |
| 10 | + |
| 11 | + steps: |
| 12 | + - uses: actions/checkout@v4 |
| 13 | + |
| 14 | + - name: Set up JDK 8 |
| 15 | + uses: actions/setup-java@v4 |
| 16 | + with: |
| 17 | + java-version: '8' |
| 18 | + distribution: 'temurin' |
| 19 | + cache: maven |
| 20 | + |
| 21 | + - name: Cache OpenBW runtime and MPQs |
| 22 | + id: cache-openbw |
| 23 | + uses: actions/cache@v4 |
| 24 | + with: |
| 25 | + path: openbw-runtime |
| 26 | + key: openbw-linux-v1 |
| 27 | + |
| 28 | + - name: Build OpenBW and fetch MPQs |
| 29 | + if: steps.cache-openbw.outputs.cache-hit != 'true' |
| 30 | + run: | |
| 31 | + sudo apt-get update |
| 32 | + sudo apt-get install -y clang libsdl2-dev libsdl2-mixer-dev |
| 33 | +
|
| 34 | + git clone --depth 1 https://github.com/basil-ladder/openbw |
| 35 | + git clone --depth 1 -b linux-client-support https://github.com/basil-ladder/bwapi |
| 36 | + sed -i 's/switch *(command\.type)/switch ((UnitCommandType) command.type)/g' bwapi/bwapi/include/BWAPI/Client/CommandTemp.h |
| 37 | + cmake -S bwapi -B bwapi/build \ |
| 38 | + -DCMAKE_C_COMPILER=clang \ |
| 39 | + -DCMAKE_CXX_COMPILER=clang++ \ |
| 40 | + -DCMAKE_CXX_FLAGS="-include cstdint" \ |
| 41 | + -DCMAKE_BUILD_TYPE=Release \ |
| 42 | + -DOPENBW_DIR="$PWD/openbw" \ |
| 43 | + -DOPENBW_ENABLE_UI=1 \ |
| 44 | + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 |
| 45 | + cmake --build bwapi/build --target BWAPILauncher -j$(nproc) |
| 46 | +
|
| 47 | + mkdir -p openbw-runtime/bin openbw-runtime/lib |
| 48 | + cp bwapi/build/bin/BWAPILauncher openbw-runtime/bin/ |
| 49 | + cp bwapi/build/lib/*.so openbw-runtime/lib/ |
| 50 | + ldd bwapi/build/lib/libOpenBWData.so | awk '/=> \// {print $3}' | grep -vE '/(libc|libm|libdl|libpthread|librt|libgcc_s|libstdc\+\+|ld-linux)' | xargs -r cp -L -t openbw-runtime/lib/ |
| 51 | +
|
| 52 | + git clone --depth 1 https://github.com/dgant/mpqs |
| 53 | + cp mpqs/STARDAT.MPQ openbw-runtime/StarDat.mpq |
| 54 | + cp mpqs/BROODAT.MPQ openbw-runtime/BrooDat.mpq |
| 55 | + cp mpqs/patch_rt.mpq openbw-runtime/Patch_rt.mpq |
| 56 | +
|
| 57 | + - name: Compile JBWAPI and test bots |
| 58 | + run: | |
| 59 | + mvn -B test-compile dependency:build-classpath -Dmdep.outputFile=cp.txt --file pom.xml |
| 60 | + javac -cp "target/classes:$(cat cp.txt)" -d target/test-classes it/bots/SittingDuck/src/main/java/SittingDuck.java |
| 61 | +
|
| 62 | + - name: Run MarineHell vs SittingDuck match |
| 63 | + run: | |
| 64 | + mkdir -p openbw-runtime/maps openbw-runtime/bwapi-data |
| 65 | + cp "it/(2)Destination.scx" "openbw-runtime/maps/(2)Destination.scx" |
| 66 | +
|
| 67 | + cat << 'EOF' > openbw-runtime/bwapi-data/bwapi.ini |
| 68 | + [ai] |
| 69 | + ai = NULL |
| 70 | + ai_dbg = NULL |
| 71 | +
|
| 72 | + [auto_menu] |
| 73 | + auto_menu = LAN |
| 74 | + pause_dbg = OFF |
| 75 | + lan_mode = Local Area Network (UDP) |
| 76 | + auto_restart = OFF |
| 77 | + map = maps/(2)Destination.scx |
| 78 | + mapiteration = Random |
| 79 | + race = Terran |
| 80 | + enemy_count = 1 |
| 81 | + enemy_race = Terran |
| 82 | + game_type = MELEE |
| 83 | + wait_for_min_players = 2 |
| 84 | + wait_for_max_players = 2 |
| 85 | + wait_for_time = 60000 |
| 86 | +
|
| 87 | + [config] |
| 88 | + holiday = OFF |
| 89 | + shared_memory = ON |
| 90 | + show_warnings = YES |
| 91 | + EOF |
| 92 | +
|
| 93 | + BOT_CP="$PWD/target/classes:$PWD/target/test-classes:$(cat cp.txt)" |
| 94 | +
|
| 95 | + cd openbw-runtime |
| 96 | + export LD_LIBRARY_PATH="$PWD/lib:${LD_LIBRARY_PATH:-}" |
| 97 | + rm -rf /tmp/openbw /tmp/bwapi_socket_* /dev/shm/bwapi_shared_memory_* |
| 98 | +
|
| 99 | + BWAPI_CONFIG_AUTO_MENU__CHARACTER_NAME="SittingDuck" OPENBW_ENABLE_UI=0 ./bin/BWAPILauncher > launcher1.log 2>&1 & |
| 100 | + L1_PID=$! |
| 101 | +
|
| 102 | + java -cp "$BOT_CP" SittingDuck > duck.log 2>&1 & |
| 103 | + B1_PID=$! |
| 104 | +
|
| 105 | + for i in $(seq 1 30); do |
| 106 | + if grep -q "Connected" duck.log 2>/dev/null; then |
| 107 | + echo "SittingDuck connected!" |
| 108 | + break |
| 109 | + fi |
| 110 | + sleep 0.5 |
| 111 | + done |
| 112 | +
|
| 113 | + BWAPI_CONFIG_AUTO_MENU__CHARACTER_NAME="MarineHell" OPENBW_ENABLE_UI=0 ./bin/BWAPILauncher > launcher2.log 2>&1 & |
| 114 | + L2_PID=$! |
| 115 | +
|
| 116 | + timeout 120 java -cp "$BOT_CP" marinehell.MarineHell | tee marinehell.log |
| 117 | + kill $L1_PID $L2_PID $B1_PID 2>/dev/null || true |
| 118 | +
|
| 119 | + grep -q "Hello from JBWAPI!" launcher1.log launcher2.log |
| 120 | + grep -q "Game ended! Winner: true" marinehell.log |
0 commit comments