Skip to content

Commit

Permalink
add auto-compilation of executable on workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdcvlsc committed May 25, 2024
1 parent 88a8af9 commit e81229e
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 21 deletions.
62 changes: 49 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:

jobs:
build:
permissions: write-all

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

Expand All @@ -16,28 +18,26 @@ jobs:

matrix:
platform:
# - { name: Windows VS2019, ls: dir, os: windows-2019, disp: type, sample: pgn_samples, testpgn: pgn_samples\first.pgn, testuci: pgn_samples\first, 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, testuci: pgn_samples\first, 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, testuci: pgn_samples\first, 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, testuci: pgn_samples\first, 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, testuci: ./pgn_samples/first, 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, testuci: ./pgn_samples/first, 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, testuci: ./pgn_samples/first, analyzedpgn: ./pgn_samples/first.analyzed.pgn, bin: ./apgn }
# - { name: MacOS-XCode, cpyd: cp -R, cpyf: cp, ls: ls, os: macos-latest, zip: mac-apgn.zip, zipd: zip -r, disp: cat, sample: ./pgn_samples, testpgn: ./pgn_samples/first.pgn, testuci: ./pgn_samples/first, analyzedpgn: ./pgn_samples/first.analyzed.pgn, bindest: build, bin: ./apgn }
# - { name: Windows VS2019, cpyd: xcopy /E /I, cpyf: xcopy, ls: dir, os: windows-2019, zip: windows-apgn-VS19.zip, zipd: 7z a -tzip, disp: type, sample: pgn_samples, testpgn: pgn_samples\first.pgn, testuci: pgn_samples\first, analyzedpgn: .\pgn_samples\first.analyzed.pgn, bindest: build\bin, bin: .\apgn.exe }
# - { name: Windows VS2022, cpyd: xcopy /E /I, cpyf: xcopy, ls: dir, os: windows-2022, zip: windows-apgn-VS22.zip, zipd: 7z a -tzip, disp: type, sample: pgn_samples, testpgn: pgn_samples\first.pgn, testuci: pgn_samples\first, analyzedpgn: .\pgn_samples\first.analyzed.pgn, bindest: build\bin, bin: .\apgn.exe }
# - { name: Windows-Clang, cpyd: xcopy /E /I, cpyf: xcopy, ls: dir, os: windows-latest, zip: windows-apgn-clang.zip, zipd: 7z a -tzip, disp: type, sample: pgn_samples, testpgn: pgn_samples\first.pgn, testuci: pgn_samples\first, analyzedpgn: .\pgn_samples\first.analyzed.pgn, bindest: build\bin, bin: .\apgn.exe, flags: CC=clang CXX=clang++ }
- { name: Windows-GCC, cpyd: xcopy /E /I, cpyf: xcopy, ls: dir, os: windows-latest, zip: windows-apgn-gcc.zip, zipd: 7z a -tzip, disp: type, sample: pgn_samples, testpgn: pgn_samples\first.pgn, testuci: pgn_samples\first, analyzedpgn: .\pgn_samples\first.analyzed.pgn, bindest: build\bin, bin: .\apgn.exe, flags: CC=gcc CXX=g++ }
- { name: Linux-GCC, cpyd: cp -r, cpyf: cp, ls: ls, os: ubuntu-latest, zip: ubuntu-apgn-gcc.zip, zipd: zip -r, disp: cat, sample: ./pgn_samples, testpgn: ./pgn_samples/first.pgn, testuci: ./pgn_samples/first, analyzedpgn: ./pgn_samples/first.analyzed.pgn, bindest: build, bin: ./apgn }
- { name: Linux-Clang, cpyd: cp -r, cpyf: cp, ls: ls, os: ubuntu-latest, zip: ubuntu-apgn-clang.zip, zipd: zip -r, disp: cat, sample: ./pgn_samples, testpgn: ./pgn_samples/first.pgn, testuci: ./pgn_samples/first, analyzedpgn: ./pgn_samples/first.analyzed.pgn, bindest: build, bin: ./apgn, flags: CC=clang CXX=clang++ }

steps:
- uses: actions/checkout@v3

- run: echo "this is a test" > test.log
- name: Display Tag Name
run : echo ${{github.ref_name}}-${{github.sha}}

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

- 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}}

Expand All @@ -54,4 +54,40 @@ jobs:
# run: ${{matrix.platform.disp}} ${{matrix.platform.testuci}}

- name: display results
run: ${{matrix.platform.disp}} ${{matrix.platform.analyzedpgn}}
run: ${{matrix.platform.disp}} ${{matrix.platform.analyzedpgn}}

- name: make a build folder
run: mkdir build

- name: copy the resources in the build folder
run: ${{matrix.platform.cpyd}} bin ${{matrix.platform.bindest}}

- name: copy the binary to the build folder
run: ${{matrix.platform.cpyf}} ${{matrix.platform.bin}} build

- name: display the contents of the build folder
run: cd build && ${{matrix.platform.ls}}

- name: display the contents of the bin folder
run: cd build && cd bin && ${{matrix.platform.ls}}

- name: display the contents of the engines folder
run: cd build && cd bin && cd engines && ${{matrix.platform.ls}}

- name: zip the build folder
run: ${{matrix.platform.zipd}} ${{matrix.platform.zip}} build

- name: Create github release and upload ${{matrix.platform.zip}}
run: gh release create ${{github.ref_name}}-${{github.sha}} ${{matrix.platform.zip}} --title "${{github.ref_name}}-${{github.sha}}" --notes "Release notes for ${{github.ref_name}}-${{github.sha}}" --draft=false --prerelease=true
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload ${{matrix.platform.zip}} to release
run: gh release upload ${{github.ref_name}}-${{github.sha}} ${{matrix.platform.zip}}
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Done
run: echo Workflow Done
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ current_dir := $(notdir $(patsubst %/,%,$(dir $(mkfile_path))))
OS := $(shell uname)

CXX=g++
CXX_FLAGS=-std=c++17 -static-libgcc -static-libstdc++ -O3
CXX_FLAGS=-static -static-libgcc -static-libstdc++ -std=c++17 -O3
ifeq ($(OS), Linux)
EXTENSION=
EXECUTABLE=apgn
Expand All @@ -21,9 +21,9 @@ 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}

Expand Down
4 changes: 2 additions & 2 deletions dependencies/pgn-extract/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ OPTIMISE=-O3
# $(OPTIMISE)

# PRODUCTION
CFLAGS+=-c -I/usr/local/lib/ansi-include -static-libgcc -std=c99 \
CFLAGS+=-c -I/usr/local/lib/ansi-include -std=c99 \
$(CPPFLAGS) $(OPTIMISE)

CC=gcc
Expand All @@ -58,7 +58,7 @@ AIX_CFLAGS=-c -D_POSIX_SOURCE -D_XOPEN_SOURCE -D_ALL_SOURCE
AIX_CC=xlc

pgn-extract : $(OBJS)
$(CC) $(DEBUGINFO) $(ORIGCFLAGS) $(CPPFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o pgn-extract
$(CC) -static -static-libgcc -std=c99 -O3 $(LDFLAGS) $(OBJS) $(LIBS) -o pgn-extract

purify : $(OBJS)
purify $(CC) $(DEBUGINFO) $(OBJS) -o pgn-extract
Expand Down
6 changes: 3 additions & 3 deletions dependencies/uci-analyser/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ ifeq ($(OS), Linux)
# CFLAGS=-c -g -Wall -O3 -D__unix__

# PRODUCTION
CFLAGS= -static-libgcc -static-libstdc++ -std=c++17 -c -O3 -DPRODUCTION -D__unix__
CFLAGS=-std=c++17 -c -O3 -DPRODUCTION -D__unix__
else
# WINDOWS

# DEVELOPMENT
# CFLAGS= -std=c++17 -c -g -Wall -O3

# PRODUCTION
CFLAGS= -static-libgcc -static-libstdc++ -std=c++17 -c -O3 -DPRODUCTION
CFLAGS=-std=c++17 -c -O3 -DPRODUCTION
endif

OBJS=analyse.o evaluation.o engine.o utils.o interpret.o
Expand All @@ -49,7 +49,7 @@ TARGET=analyse
$(CXX) $(CFLAGS) $< -o $@

$(TARGET) : $(OBJS)
$(CXX) -o $@ $(OBJS)
$(CXX) -static -static-libgcc -static-libstdc++ -std=c++17 -O3 -o $@ $(OBJS)

clean:
rm -f $(OBJS) $(TARGET)
Expand Down

0 comments on commit e81229e

Please sign in to comment.