Skip to content

Commit 90d7e9d

Browse files
committed
add engine tests
1 parent c2e90ce commit 90d7e9d

2 files changed

Lines changed: 97 additions & 6 deletions

File tree

.github/workflows/ci.yml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,36 @@ jobs:
2222
- name: Run tests
2323
run: TEST_IGNORE_SLUGS=engine_consistency_integration lua ./bin/test.lua
2424

25+
discover-engines:
26+
name: Discover Engines
27+
runs-on: ubuntu-latest
28+
outputs:
29+
engines: ${{ steps.list_engines.outputs.engines }}
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- name: Set up Lua
34+
uses: leafo/gh-actions-lua@v9
35+
with:
36+
luaVersion: "5.4"
37+
buildCache: false
38+
39+
- name: List available engines
40+
id: list_engines
41+
run: |
42+
ENGINES=$(lua bin/engines.lua)
43+
echo "engines=$ENGINES" >> $GITHUB_OUTPUT
44+
lua bin/engines.lua --check
45+
2546
engine-consistency:
2647
name: Engine Consistency (${{ matrix.engine }})
2748
runs-on: ubuntu-latest
49+
needs: discover-engines
50+
if: needs.discover-engines.outputs.engines != '[]'
2851
strategy:
2952
fail-fast: false
3053
matrix:
31-
engine:
32-
- dumbgoblin
33-
- fruit21
34-
- garbochess
35-
- sunfish
54+
engine: ${{ fromJson(needs.discover-engines.outputs.engines) }}
3655
steps:
3756
- uses: actions/checkout@v4
3857

@@ -43,4 +62,4 @@ jobs:
4362
buildCache: false
4463

4564
- name: Run engine consistency tests for ${{ matrix.engine }}
46-
run: ALLOWED_ENGINES=${{ matrix.engine }} lua ./bin/test.lua --only=engine_consistency_integration
65+
run: ALLOWED_ENGINES=${{ matrix.engine }} TEST_ONLY_SLUGS=engine_consistency_integration lua ./bin/test.lua

bin/engines.lua

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/env lua
2+
--[[
3+
Helper script to list all registered engines.
4+
Outputs engine IDs as JSON array for use in CI matrix.
5+
6+
Usage:
7+
lua bin/engines.lua -- outputs JSON array: ["engine1","engine2"]
8+
lua bin/engines.lua --check -- exits 0 if engines found, 1 otherwise
9+
]]
10+
11+
-- Get script directory and set up paths
12+
local scriptPath = debug.getinfo(1, "S").source:match("^@?(.*)[/\\]")
13+
if not scriptPath or scriptPath == "" then scriptPath = "." end
14+
scriptPath = scriptPath:gsub("/", package.config:sub(1, 1))
15+
16+
local sep = package.config:sub(1, 1)
17+
local projectRoot = scriptPath .. sep .. ".." .. sep
18+
19+
-- Set up package paths
20+
package.path = projectRoot .. "lib" .. sep .. "?.lua;" ..
21+
projectRoot .. "src/?.lua;" ..
22+
projectRoot .. "tests/?.lua;" ..
23+
package.path
24+
25+
-- Load DeltaChess modules
26+
require("init")
27+
28+
-- Check command line arguments
29+
local checkMode = false
30+
for _, a in ipairs(arg) do
31+
if a == "--check" then
32+
checkMode = true
33+
end
34+
end
35+
36+
-- Get engine list
37+
local engines = {}
38+
if DeltaChess and DeltaChess.Engines then
39+
local list = DeltaChess.Engines:GetEngineList()
40+
if list then
41+
for _, engine in ipairs(list) do
42+
if engine.id then
43+
table.insert(engines, engine.id)
44+
end
45+
end
46+
end
47+
end
48+
49+
-- Sort engines alphabetically
50+
table.sort(engines)
51+
52+
if checkMode then
53+
-- Check mode: exit 0 if engines found, 1 otherwise
54+
if #engines > 0 then
55+
io.stderr:write("Found " .. #engines .. " engine(s): " .. table.concat(engines, ", ") .. "\n")
56+
os.exit(0)
57+
else
58+
io.stderr:write("No engines found\n")
59+
os.exit(1)
60+
end
61+
end
62+
63+
-- Output JSON array
64+
io.write("[")
65+
for i, engineId in ipairs(engines) do
66+
if i > 1 then io.write(",") end
67+
-- Escape quotes in engine ID (though unlikely to have them)
68+
local escaped = engineId:gsub('"', '\\"')
69+
io.write('"' .. escaped .. '"')
70+
end
71+
io.write("]")
72+
io.write("\n")

0 commit comments

Comments
 (0)