Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CI workflow and Makefile #19

Merged
merged 36 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
67fe743
Experiment with CI
ruicoelhopedro Oct 3, 2023
6c5d3f4
Fix attempt
ruicoelhopedro Oct 3, 2023
f336626
Fix attempt 2
ruicoelhopedro Oct 3, 2023
78d98a3
Force run bench
ruicoelhopedro Oct 3, 2023
3f06da3
Debug on bench extraction
ruicoelhopedro Oct 3, 2023
4074fdd
More git logs
ruicoelhopedro Oct 3, 2023
ab96d1c
Fix fetch depth
ruicoelhopedro Oct 3, 2023
d24bd43
Remove debug steps
ruicoelhopedro Oct 3, 2023
cf6323e
Introduce basic CI support
ruicoelhopedro Oct 3, 2023
b4edeac
Merge branch 'main' into ci
ruicoelhopedro Nov 18, 2023
e68cfc8
WIP: add more configurations in CI
ruicoelhopedro Nov 18, 2023
0a10c35
WIP: add MacOS and Windows
ruicoelhopedro Nov 18, 2023
d1159fc
WIP: add missing gcc
ruicoelhopedro Nov 18, 2023
bf4dc13
WIP: add missing diffutils and windows clang
ruicoelhopedro Nov 18, 2023
9735164
Comment out tests check
ruicoelhopedro Nov 18, 2023
154ec2a
WIP: more debug
ruicoelhopedro Nov 18, 2023
d5b9f7a
WIP: Update checkout
ruicoelhopedro Nov 18, 2023
796008e
WIP: update output of bench and test
ruicoelhopedro Nov 18, 2023
72e5a0d
WIP: fix redirect
ruicoelhopedro Nov 18, 2023
da0039f
WIP: fix redirect - take 2
ruicoelhopedro Nov 18, 2023
05e098f
WIP: attempt to fix Makefile for Windows clang
ruicoelhopedro Nov 18, 2023
bfa8871
WIP: another take on Makefile fix for Windows clang
ruicoelhopedro Nov 18, 2023
895e837
WIP: take 3
ruicoelhopedro Nov 18, 2023
9aeb8c3
WIP: disable fail-fast
ruicoelhopedro Nov 18, 2023
1a0f200
WIP: another fix attempt
ruicoelhopedro Nov 18, 2023
16bd2e3
WIP: fix
ruicoelhopedro Nov 18, 2023
cedae9a
WIP: some debug prints
ruicoelhopedro Nov 18, 2023
71d4de0
WIP: another attempt
ruicoelhopedro Nov 18, 2023
0cf8a51
WIP: another take
ruicoelhopedro Nov 18, 2023
a2ab273
WIP: possible bugfix for windows
ruicoelhopedro Nov 18, 2023
06df91c
WIP: bugfix continuation
ruicoelhopedro Nov 18, 2023
b18f576
Some updates to the Makefile and incbin include
ruicoelhopedro Nov 19, 2023
ed338f0
Cleanup debug parts from CI
ruicoelhopedro Nov 19, 2023
1b69fb8
Add release action
ruicoelhopedro Nov 21, 2023
bbf30fa
Fix wrong bench comparison
ruicoelhopedro Nov 22, 2023
8c5c1e1
Verify bench signature of all binaries on a release
ruicoelhopedro Nov 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 77 additions & 10 deletions .github/workflows/pawn-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Pawn tests
name: Build and test pawn

on:
push:
Expand All @@ -11,20 +11,87 @@ on:

jobs:
build:
name: Building and testing pawn
runs-on: ubuntu-latest
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
env:
CC: ${{ matrix.config.cc }}
CXX: ${{ matrix.config.cxx }}
strategy:
fail-fast: false
matrix:
config:
- name: "Ubuntu Latest - GCC"
os: ubuntu-latest
cc: gcc
cxx: g++
shell: bash
- name: "Ubuntu Latest - Clang"
os: ubuntu-latest
cc: clang
cxx: clang++
shell: bash
- name: "Ubuntu 20.04 - GCC"
os: ubuntu-20.04
cc: gcc
cxx: g++
shell: bash
- name: "Ubuntu 20.04 - Clang"
os: ubuntu-20.04
cc: clang
cxx: clang++
shell: bash
- name: "MacOS - GCC 11"
os: macos-latest
cc: gcc-11
cxx: g++-11
shell: bash
- name: "MacOS - Clang"
os: macos-latest
cc: clang
cxx: clang++
shell: bash
- name: "Windows 2022 - GCC"
os: windows-2022
cc: gcc
cxx: g++
sys: mingw64
packages: mingw-w64-x86_64-gcc
shell: msys2 {0}
- name: "Windows 2022 - Clang"
os: windows-2022
cc: clang
cxx: clang++
sys: mingw64
packages: mingw-w64-x86_64-clang mingw-w64-x86_64-lld
shell: msys2 {0}
defaults:
run:
shell: ${{ matrix.config.shell }}
steps:
- name: Check out repository
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Extract bench signature
run: "git log HEAD | grep 'Bench: ' | head -n 1 | awk '{print $2}' > bench.sig"
- name: Prepare Windows with MSYS2
if: runner.os == 'Windows'
uses: msys2/setup-msys2@v2
with:
msystem: ${{matrix.config.sys}}
install: make git diffutils ${{matrix.config.packages}}
- name: Fetch bench signature
run: "git log HEAD | grep 'Bench: ' | head -n 1 | awk '{print $2}' > bench.sig_ref"
- name: Build pawn
run: "make"
- name: Run bench
run: "build/pawn bench 2>&1 | grep 'Nodes searched:' | awk '{print $3}' > bench.out"
- name: Verify bench signature
run: "cmp bench.sig bench.out"
run: |
build/pawn bench > bench.out 2>&1
cat bench.out
- name: Extract and verify bench signature
run: |
cat bench.out | grep 'Nodes searched:' | awk '{print $3}' > bench.sig
cmp bench.sig bench.sig_ref
- name: Run tests
run: "build/pawn test | grep -q 'All tests passed'"
run: |
build/pawn test > test.out
cat test.out
grep -q 'All tests passed' test.out
77 changes: 77 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Upload binaries to release

on:
release:
types: [published]

permissions:
contents: write

jobs:
build:
name: ${{matrix.config.name}}
runs-on: ${{matrix.config.os}}
env:
CC: ${{matrix.config.cc}}
CXX: ${{matrix.config.cxx}}
strategy:
fail-fast: false
matrix:
config:
- name: ubuntu
os: ubuntu-20.04
cc: gcc
cxx: g++
shell: bash
- name: macos
os: macos-latest
cc: gcc-11
cxx: g++-11
shell: bash
- name: windows
os: windows-2022
cc: gcc
cxx: g++
sys: mingw64
packages: mingw-w64-x86_64-gcc
shell: msys2 {0}
binaries:
- x86-64
- haswell
defaults:
run:
shell: ${{matrix.config.shell}}
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Prepare Windows with MSYS2
if: runner.os == 'Windows'
uses: msys2/setup-msys2@v2
with:
msystem: ${{matrix.config.sys}}
install: make git diffutils mingw-w64-x86_64-github-cli ${{matrix.config.packages}}
- name: Build
run: make ARCH=${{matrix.binaries}} -j
- name: Verify bench signature
run: |
git log HEAD | grep 'Bench: ' | head -n 1 | awk '{print $2}' > bench.sig_ref
build/pawn bench > bench.out 2>&1
cat bench.out
cat bench.out | grep 'Nodes searched:' | awk '{print $3}' > bench.sig
cmp bench.sig bench.sig_ref
- name: Upload Release Asset
if: runner.os != 'Windows'
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
cp build/pawn pawn-${{github.event.release.tag_name}}-${{matrix.config.name}}-${{matrix.binaries}}
gh release upload ${{github.event.release.tag_name}} pawn-${{github.event.release.tag_name}}-${{matrix.config.name}}-${{matrix.binaries}}
- name: Upload Release Asset (Windows)
if: runner.os == 'Windows'
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
run: |
cp build/pawn.exe pawn-${{github.event.release.tag_name}}-${{matrix.config.name}}-${{matrix.binaries}}.exe
gh release upload ${{github.event.release.tag_name}} pawn-${{github.event.release.tag_name}}-${{matrix.config.name}}-${{matrix.binaries}}.exe
18 changes: 15 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,26 @@ SRC_DIR=src
ARCH = native

# Compiler flags
CFLAGS = -Wall -Isrc/syzygy/Fathom/src -O3 -flto -march=$(ARCH)
CXXFLAGS = -Wall -std=c++17 -Isrc/syzygy/Fathom/src -O3 -flto -march=$(ARCH)
LDFLAGS = -pthread -flto -march=$(ARCH)
COMMON = -Wall -Isrc/syzygy/Fathom/src -O3 -flto -march=$(ARCH)
CFLAGS = $(COMMON)
CXXFLAGS = $(COMMON) -std=c++17
LDFLAGS = -flto -march=$(ARCH)

# Windows-specific stuff
ifeq ($(OS), Windows_NT)
LDFLAGS += -static
BIN_NAME := $(BIN_NAME).exe
ifeq ($(CC), clang)
# Needed for -flto to work on Windows Clang
# This is also the only case where we don't use -pthread
CFLAGS += -fuse-ld=lld
CXXFLAGS += -fuse-ld=lld
LDFLAGS += -fuse-ld=lld
else
LDFLAGS += -pthread
endif
else
LDFLAGS += -pthread
endif

SRC_FILES := $(shell find $(SRC_DIR) -name *.cpp) src/syzygy/Fathom/src/tbprobe.c
Expand Down
1 change: 1 addition & 0 deletions src/NNUE.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "incbin/incbin.h"
#include "Types.hpp"
#include "NNUE.hpp"
#include <iostream>
Expand Down
2 changes: 1 addition & 1 deletion src/NNUE.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include "incbin/incbin.h"
#include "Types.hpp"


#define NNUE_Default_File "nnue-10427ad1e4e6.dat"


Expand Down
4 changes: 2 additions & 2 deletions src/Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ namespace Tests
for (auto& test : tests)
{
Position pos(test.fen());
Histories hists;
auto result = Search::perft<false>(pos, test.depth(), hists);
auto hists = std::make_unique<Histories>();
auto result = Search::perft<false>(pos, test.depth(), *hists);
if (result == test.result())
{
std::cout << "[ OK ] " << test.fen() << " (" << result << ")" << std::endl;
Expand Down
6 changes: 3 additions & 3 deletions src/Tests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ namespace Tests
int n_failed = 0;
for (auto& test : tests)
{
Histories hists;
Position pos(test.fen());
auto result_base = Search::perft<false>(pos, test.depth() - 1, hists);
auto result_test = Search::template perft<false, USE_ORDER, TT, LEGALITY, VALIDITY>(pos, test.depth() - 1, hists);
auto hists = std::make_unique<Histories>();
auto result_base = Search::perft<false>(pos, test.depth() - 1, *hists);
auto result_test = Search::template perft<false, USE_ORDER, TT, LEGALITY, VALIDITY>(pos, test.depth() - 1, *hists);
if (result_base == result_test)
{
std::cout << "[ OK ] " << test.fen() << " (" << result_test << ")" << std::endl;
Expand Down