Skip to content

Commit e0623c5

Browse files
committed
add a test workflow
1 parent bb2a4d8 commit e0623c5

File tree

7 files changed

+84
-20
lines changed

7 files changed

+84
-20
lines changed

.clangd

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
InlayHints:
2+
Designators: No
3+
Enabled: Yes
4+
ParameterNames: No
5+
DeducedTypes: No
6+
7+
CompileFlags:
8+
Add: [-std=c++17, -Wall, -Wextra, -Wpedantic, -Werror]
9+
Compiler: clang++

.github/workflows/build.yml

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,53 @@ name: ci
22

33
on:
44
push:
5-
branches: [ "main" ]
5+
branches: [ "main", "add-ci-test" ]
66
pull_request:
7-
branches: [ "main" ]
7+
branches: [ "main", "add-ci-test" ]
88

99
jobs:
1010
build:
11-
runs-on: ${{ matrix.os }}
11+
name: ${{matrix.platform.name}}
12+
runs-on: ${{matrix.platform.os}}
1213

1314
strategy:
15+
fail-fast: false
16+
1417
matrix:
15-
os: [ubuntu-latest, windows-latest]
18+
platform:
19+
# - { name: Windows VS2019, ls: dir, os: windows-2019, disp: type, sample: pgn_samples, testpgn: pgn_samples\\first.pgn, analyzedpgn: .\\pgn_samples\\first.analyzed.pgn, bin: .\\apgn.exe }
20+
# - { name: Windows VS2022, ls: dir, os: windows-2022, disp: type, sample: pgn_samples, testpgn: pgn_samples\\first.pgn, analyzedpgn: .\\pgn_samples\\first.analyzed.pgn, bin: .\\apgn.exe }
21+
# - { name: Windows-Clang, ls: dir, os: windows-latest, disp: type, sample: pgn_samples, testpgn: pgn_samples\\first.pgn, analyzedpgn: .\\pgn_samples\\first.analyzed.pgn, bin: .\\apgn.exe, flags: CC=clang CXX=clang++ }
22+
- { name: Windows-GCC, ls: dir, os: windows-latest, disp: type, sample: pgn_samples, testpgn: pgn_samples\\first.pgn, analyzedpgn: .\\pgn_samples\\first.analyzed.pgn, bin: .\\apgn.exe, flags: CC=gcc CXX=g++ }
23+
- { name: Linux-GCC, ls: ls, os: ubuntu-latest, disp: cat, sample: ./pgn_samples, testpgn: ./pgn_samples/first.pgn, analyzedpgn: ./pgn_samples/first.analyzed.pgn, bin: ./apgn }
24+
- { name: Linux-Clang, ls: ls, os: ubuntu-latest, disp: cat, sample: ./pgn_samples, testpgn: ./pgn_samples/first.pgn, analyzedpgn: ./pgn_samples/first.analyzed.pgn, bin: ./apgn, flags: CC=clang CXX=clang++ }
25+
# - { name: MacOS-XCode, ls: ls, os: macos-latest, disp: cat, sample: ./pgn_samples, testpgn: ./pgn_samples/first.pgn, analyzedpgn: ./pgn_samples/first.analyzed.pgn, bin: ./apgn }
1626

1727
steps:
1828
- uses: actions/checkout@v3
1929

20-
- name: compile and build
21-
run: make -j4
30+
- run: echo "this is a test" > test.log
31+
32+
- name: build for -> ${{matrix.platform.os}}
33+
run: make ${{matrix.platform.flags}} -j4
34+
35+
- name: ready executable for execution
36+
run: chmod a+rx ${{matrix.platform.bin}}
37+
38+
- name: ready first.pgn for reading
39+
run: chmod a+r ${{matrix.platform.testpgn}}
40+
41+
- name: run test
42+
run: ${{matrix.platform.bin}} -depth 5 ${{matrix.platform.testpgn}}
43+
44+
- name: show files in current directory
45+
run: ${{matrix.platform.ls}}
46+
47+
- name: show files in sample pgn folder
48+
run: ${{matrix.platform.ls}} ${{matrix.platform.sample}}
49+
50+
- name: display pgn test subject
51+
run: ${{matrix.platform.disp}} ${{matrix.platform.testpgn}}
52+
53+
- name: display results
54+
run: ${{matrix.platform.disp}} ${{matrix.platform.analyzedpgn}}

Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ all:
2121
mv dependencies/uci-analyser/analyse bin/analyse
2222

2323
ifeq ($(OS), Linux)
24-
chmod +x bin/engines/stockfish
24+
chmod a+rx bin/engines/stockfish
2525
else
26-
chmod +x bin/engines/stockfish.exe
26+
chmod a+rx bin/engines/stockfish.exe
2727
endif
28-
${CXX} ${CXX_FLAGS} main.cpp -o ${EXECUTABLE}
28+
$(CXX) $(CXX_FLAGS) main.cpp -o $(EXECUTABLE)
2929

3030
test:
31-
./${EXECUTABLE} ./pgn_samples/first.pgn W
31+
./$(EXECUTABLE) ./pgn_samples/first.pgn W
3232

3333
test_clean:
3434
ifeq ($(OS), Linux)
@@ -39,15 +39,15 @@ endif
3939

4040
install:
4141
ifeq ($(OS), Linux)
42-
@ln -s $(dir $(abspath $(lastword $(MAKEFILE_LIST))))${EXECUTABLE} ${INSTALLPATH}
42+
@ln -s $(dir $(abspath $(lastword $(MAKEFILE_LIST))))$(EXECUTABLE) $(INSTALLPATH)
4343
else
4444
@echo "make install is not supported for windows"
4545
# SETX /M PATH "%PATH%;$(dir $(abspath $(lastword $(MAKEFILE_LIST))))"
4646
endif
4747

4848
uninstall:
4949
ifeq ($(OS), Linux)
50-
@rm ${INSTALLPATH}/${EXECUTABLE}
50+
@rm $(INSTALLPATH)/$(EXECUTABLE)
5151
else
5252
@echo "make uninstall is not supported for windows"
5353
endif
@@ -58,4 +58,4 @@ clean:
5858
@echo "removing uci-analyse object files"
5959
@$(MAKE) -C dependencies/uci-analyser clean
6060
@echo "removing analyse-pgn binaries files"
61-
@rm ./bin/analyse${EXTENSION} ./bin/pgn-extract${EXTENSION} ./${EXECUTABLE}
61+
@rm ./bin/analyse$(EXTENSION) ./bin/pgn-extract$(EXTENSION) ./$(EXECUTABLE)

dependencies/uci-analyser/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
OS := $(shell uname)
2424

25-
CC=g++
25+
CXX=g++
2626

2727
ifeq ($(OS), Linux)
2828
# LINUX
@@ -46,10 +46,10 @@ OBJS=analyse.o evaluation.o engine.o utils.o interpret.o
4646
TARGET=analyse
4747

4848
.cpp.o:
49-
$(CC) $(CFLAGS) $< -o $@
49+
$(CXX) $(CFLAGS) $< -o $@
5050

5151
$(TARGET) : $(OBJS)
52-
$(CC) -o $@ $(OBJS)
52+
$(CXX) -o $@ $(OBJS)
5353

5454
clean:
5555
rm -f $(OBJS) $(TARGET)

dependencies/uci-analyser/interpret.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
#include <iterator>
12
#include <map>
23
#include <cmath>
4+
#include <stdexcept>
35
#include "interpret.hpp"
46

57
using namespace std;
@@ -88,8 +90,14 @@ namespace interpret
8890

8991
ofstream outfile;
9092
outfile.open(saveFile+".stats.txt",ios_base::out | ios_base::app);
91-
outfile<<"==============================================================\n";
92-
outfile<<statCounts;
93+
94+
if (outfile.good()) {
95+
outfile<<"==============================================================\n";
96+
outfile<<statCounts;
97+
} else {
98+
throw std::runtime_error("Error writing to the statistics file");
99+
}
100+
93101
outfile.close();
94102
}
95103

main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ int main(int argc, char* argv[])
306306
apgn_convert::uci_to_pgn(FILENAME[i]+".analyzed",FILENAME[i]+".analyzed.pgn");
307307

308308
// clean temporary files
309-
apgnFileSys::deleteFile(FILENAME[i]);
310-
apgnFileSys::deleteFile(FILENAME[i]+".analyzed");
309+
// apgnFileSys::deleteFile(FILENAME[i]);
310+
// apgnFileSys::deleteFile(FILENAME[i]+".analyzed");
311311
}
312312

313313
std::cout << "Analyzed PGN files: " << PGN_GAMES.size() << "\n";

pgn_samples/first

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[Event "sample game"]
2+
[Site "chesstest.com"]
3+
[Date "2012.12.12"]
4+
[Round "?"]
5+
[White "player1"]
6+
[Black "player2"]
7+
[Result "1-0"]
8+
[WhiteElo "1342"]
9+
[BlackElo "1335"]
10+
[TimeControl "180"]
11+
[Termination "player1 won on time"]
12+
13+
d2d4 d7d5 g1f3 g8f6 c2c4 c7c6 c1g5 c8f5 b1c3 h7h6 g5f6 e7f6 e2e3 f8b4 c4d5 d8d5 f3h4 b4c3 b2c3 f5g6 c3c4 d5a5 d1d2 a5d2 e1d2 b8d7 f2f3 e8c8 e3e4 d7b6 a1b1 d8d4 d2c3 d4d8 f1e2 h8e8 g2g3 b6a4 c3b4 a4b6 h1d1 c8c7 h4g2 d8d1 b1d1 e8e7 g2e3 b6d7 a2a4 d7e5 d1d2 b7b6 a4a5 c6c5 b4b5 b6a5 e3d5 c7d6 d5e7 d6e7 b5c5 e5d7 c5b5 a5a4 b5a4 d7c5 a4b5 c5b3 d2b2 b3d4 b5a6 d4e2 b2e2 e7d6 a6a7 d6c5 e2c2 c5d4 a7b6 d4d3 c2c1 d3d2 c1a1 d2d3 c4c5 f6f5 c5c6 f5e4 c6c7 g6f5 f3e4 d3e4 a1f1 f5e6 b6c6 e4e3 c6d6 e3e2 f1f4 g7g5 f4f6 e2e3 d6c6 e3e4 c6b7 e4e5 f6e6 e5e6 c7c8Q e6f6 c8c6 f6g7 c6c3 g7g6 c3d3 g6g7 d3d4 f7f6 d4d7 g7g6 d7d3 g6g7 g3g4 g7f7 d3f5 f7e7 b7b6 e7f7 b6c6 f7e7 c6d5 e7f7 d5d6 f7g7 d6e6 h6h5 f5f6 g7h7 f6g5 1-0
14+

0 commit comments

Comments
 (0)