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 e05d515
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 14 deletions.
37 changes: 31 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,45 @@ 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: 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 }
- { 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++ }

steps:
- uses: actions/checkout@v3

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

- 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 results
run: ${{matrix.platform.disp}} ${{matrix.platform.analyzedpgn}}

- name: Upload test files
run: gh release upload ${{github.ref_name}} ${{matrix.platform.analyzedpgn}}
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ ifeq ($(OS), Linux)
else
chmod +x 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)
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

0 comments on commit e05d515

Please sign in to comment.