Skip to content

Commit

Permalink
add a test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdcvlsc committed May 23, 2024
1 parent bb2a4d8 commit 3bec845
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 20 deletions.
9 changes: 9 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
InlayHints:
Designators: No
Enabled: Yes
ParameterNames: No
DeducedTypes: No

CompileFlags:
Add: [-std=c++17, -Wall, -Wextra, -Wpedantic, -Werror]
Compiler: clang++
45 changes: 39 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,53 @@ name: ci

on:
push:
branches: [ "main" ]
branches: [ "main", "add-ci-test" ]
pull_request:
branches: [ "main" ]
branches: [ "main", "add-ci-test" ]

jobs:
build:
runs-on: ${{ matrix.os }}
name: ${{matrix.platform.name}}
runs-on: ${{matrix.platform.os}}

strategy:
fail-fast: false

matrix:
os: [ubuntu-latest, windows-latest]
platform:
# - { 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 }
# - { 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 }
# - { 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++ }
- { 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++ }
- { 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 }
- { 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++ }
# - { 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 }

steps:
- uses: actions/checkout@v3

- name: compile and build
run: make -j4
- run: echo "this is a test" > test.log

- name: build for -> ${{matrix.platform.os}}
run: make ${{matrix.platform.flags}} -j4

- name: ready executable for execution
run: chmod a+rx ${{matrix.platform.bin}}

- name: ready first.pgn for reading
run: chmod a+r ${{matrix.platform.testpgn}}

- name: run test
run: ${{matrix.platform.bin}} -depth 5 ${{matrix.platform.testpgn}}

- name: show files in current directory
run: ${{matrix.platform.ls}}

- name: show files in sample pgn folder
run: ${{matrix.platform.ls}} ${{matrix.platform.sample}}

- name: display pgn test subject
run: ${{matrix.platform.disp}} ${{matrix.platform.testpgn}}

- name: display results
run: ${{matrix.platform.disp}} ${{matrix.platform.analyzedpgn}}
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ all:
mv dependencies/uci-analyser/analyse bin/analyse

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

test:
./${EXECUTABLE} ./pgn_samples/first.pgn W
./$(EXECUTABLE) ./pgn_samples/first.pgn W

test_clean:
ifeq ($(OS), Linux)
Expand All @@ -39,15 +39,15 @@ endif

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

uninstall:
ifeq ($(OS), Linux)
@rm ${INSTALLPATH}/${EXECUTABLE}
@rm $(INSTALLPATH)/$(EXECUTABLE)
else
@echo "make uninstall is not supported for windows"
endif
Expand All @@ -58,4 +58,4 @@ clean:
@echo "removing uci-analyse object files"
@$(MAKE) -C dependencies/uci-analyser clean
@echo "removing analyse-pgn binaries files"
@rm ./bin/analyse${EXTENSION} ./bin/pgn-extract${EXTENSION} ./${EXECUTABLE}
@rm ./bin/analyse$(EXTENSION) ./bin/pgn-extract$(EXTENSION) ./$(EXECUTABLE)
4 changes: 4 additions & 0 deletions convert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ namespace apgn_convert
throw std::runtime_error("something happend - error in convert.hpp");
break;
}

std::cout << "\n\n--------------------------- Results Output Debug : Start --------------------------- \n";
std::cout << result_pgn << "\n";
std::cout << "\n--------------------------- Results Output Debug : End --------------------------- \n";
#endif

// check if file exist
Expand Down
6 changes: 3 additions & 3 deletions dependencies/uci-analyser/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

OS := $(shell uname)

CC=g++
CXX=g++

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

.cpp.o:
$(CC) $(CFLAGS) $< -o $@
$(CXX) $(CFLAGS) $< -o $@

$(TARGET) : $(OBJS)
$(CC) -o $@ $(OBJS)
$(CXX) -o $@ $(OBJS)

clean:
rm -f $(OBJS) $(TARGET)
Expand Down
12 changes: 10 additions & 2 deletions dependencies/uci-analyser/interpret.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include <iterator>
#include <map>
#include <cmath>
#include <stdexcept>
#include "interpret.hpp"

using namespace std;
Expand Down Expand Up @@ -88,8 +90,14 @@ namespace interpret

ofstream outfile;
outfile.open(saveFile+".stats.txt",ios_base::out | ios_base::app);
outfile<<"==============================================================\n";
outfile<<statCounts;

if (outfile.good()) {
outfile<<"==============================================================\n";
outfile<<statCounts;
} else {
throw std::runtime_error("Error writing to the statistics file");
}

outfile.close();
}

Expand Down
4 changes: 2 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ int main(int argc, char* argv[])
apgn_convert::uci_to_pgn(FILENAME[i]+".analyzed",FILENAME[i]+".analyzed.pgn");

// clean temporary files
apgnFileSys::deleteFile(FILENAME[i]);
apgnFileSys::deleteFile(FILENAME[i]+".analyzed");
// apgnFileSys::deleteFile(FILENAME[i]);
// apgnFileSys::deleteFile(FILENAME[i]+".analyzed");
}

std::cout << "Analyzed PGN files: " << PGN_GAMES.size() << "\n";
Expand Down
14 changes: 14 additions & 0 deletions pgn_samples/first
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Event "sample game"]
[Site "chesstest.com"]
[Date "2012.12.12"]
[Round "?"]
[White "player1"]
[Black "player2"]
[Result "1-0"]
[WhiteElo "1342"]
[BlackElo "1335"]
[TimeControl "180"]
[Termination "player1 won on time"]

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

4 changes: 4 additions & 0 deletions winProcRun.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ namespace apgn
CloseHandle( processInfo.hProcess );
CloseHandle( processInfo.hThread );

std::cout << "\n\n--------------------------- "outbuf" Debug : Start --------------------------- \n";
std::cout << outbuf << "\n";
std::cout << "\n--------------------------- "outbuf" Debug : End --------------------------- \n";

return outbuf;
}
}
Expand Down

0 comments on commit 3bec845

Please sign in to comment.