Skip to content

Commit 5e6e02b

Browse files
committed
add a test workflow
1 parent bb2a4d8 commit 5e6e02b

File tree

5 files changed

+68
-18
lines changed

5 files changed

+68
-18
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

0 commit comments

Comments
 (0)