Skip to content

Commit 94086b6

Browse files
author
Jasper Geurtz
committed
Enable lightweight Linux OpenBW E2E GitHub Action (MarineHell vs SittingDuck)
1 parent 68f9514 commit 94086b6

5 files changed

Lines changed: 134 additions & 65 deletions

File tree

‎.github/workflows/e2e-linux.yml‎

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
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

‎.github/workflows/e2e-linux.yml.disabled‎

Lines changed: 0 additions & 50 deletions
This file was deleted.

‎build_with_openbw.md‎

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,11 @@ cmake .. -DCMAKE_BUILD_TYPE=Release -DOPENBW_DIR=../../openbw -DOPENBW_ENABLE_UI
1616
make -j4
1717

1818
# Download runtime deps
19-
curl http://www.cs.mun.ca/~dchurchill/starcraftaicomp/files/Starcraft_1161.zip -o starcraft.zip
20-
unzip starcraft.zip patch_rt.mpq BROODAT.MPQ STARDAT.MPQ
21-
mv patch_rt.mpq Patch_rt.mpq && mv BROODAT.MPQ BrooDat.mpq && mv STARDAT.MPQ StarDat.mpq
19+
git clone --depth 1 https://github.com/dgant/mpqs
20+
cp mpqs/patch_rt.mpq Patch_rt.mpq && cp mpqs/BROODAT.MPQ BrooDat.mpq && cp mpqs/STARDAT.MPQ StarDat.mpq
2221

23-
# Run openbw using the map: Destination 1.1.scx
24-
unzip starcraft.zip "maps/BroodWar/ICCup/ICCup Destination 1.1.scx"
25-
26-
BWAPI_CONFIG_AUTO_MENU__RACE=Terran BWAPI_CONFIG_AUTO_MENU__MAP="maps/BroodWar/ICCup/ICCup Destination 1.1.scx" ./bin/BWAPILauncher
22+
# Run openbw using the map: (2)Destination.scx
23+
BWAPI_CONFIG_AUTO_MENU__RACE=Terran BWAPI_CONFIG_AUTO_MENU__MAP="it/(2)Destination.scx" ./bin/BWAPILauncher
2724
```
2825

2926
Compiling and running openbw on macos with client support:
@@ -42,12 +39,9 @@ cmake .. -DCMAKE_BUILD_TYPE=Release -DOPENBW_DIR=../../openbw -DOPENBW_ENABLE_UI
4239
make -j4
4340

4441
# Download runtime deps
45-
curl -L "https://web.archive.org/web/20250823150201id_/https://www.cs.mun.ca/~dchurchill/starcraftaicomp/files/Starcraft_1161.zip" -o starcraft.zip
46-
unzip starcraft.zip patch_rt.mpq BROODAT.MPQ STARDAT.MPQ
47-
mv patch_rt.mpq Patch_rt.mpq && mv BROODAT.MPQ BrooDat.mpq && mv STARDAT.MPQ StarDat.mpq
48-
49-
# Run openbw using the map: Destination 1.1.scx
50-
unzip starcraft.zip "maps/BroodWar/ICCup/ICCup Destination 1.1.scx"
42+
git clone --depth 1 https://github.com/dgant/mpqs
43+
cp mpqs/patch_rt.mpq Patch_rt.mpq && cp mpqs/BROODAT.MPQ BrooDat.mpq && cp mpqs/STARDAT.MPQ StarDat.mpq
5144

52-
BWAPI_CONFIG_AUTO_MENU__RACE=Terran BWAPI_CONFIG_AUTO_MENU__MAP="maps/BroodWar/ICCup/ICCup Destination 1.1.scx" OPENBW_ENABLE_UI=1 ./bin/BWAPILauncher
53-
```
45+
# Run openbw using the map: (2)Destination.scx
46+
BWAPI_CONFIG_AUTO_MENU__RACE=Terran BWAPI_CONFIG_AUTO_MENU__MAP="it/(2)Destination.scx" OPENBW_ENABLE_UI=1 ./bin/BWAPILauncher
47+
```

‎it/(2)Destination.scx‎

75.2 KB
Binary file not shown.

‎src/test/java/marinehell/MarineHell.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,11 @@ public void onFrame() {
399399
// game.drawTextScreen(10, 25, units.toString());
400400
}
401401

402+
@Override
403+
public void onEnd(boolean isWinner) {
404+
System.out.println("Game ended! Winner: " + isWinner);
405+
}
406+
402407
public static void main(String[] args) {
403408
new MarineHell().run();
404409
}

0 commit comments

Comments
 (0)