From 1c403bb281574bae9744805f53517505e723ee9a Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Fri, 14 Nov 2025 00:20:56 +0100 Subject: [PATCH 1/8] [CI] Introduce GitHub CI that builds the project on Windows and Linux (OpenCL) Also, it runs `runtests` and publishes build artifacts fix #1124 --- .github/workflows/build.yml | 107 ++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..2fcddf4a3 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,107 @@ +name: Build and Test + +on: + push: + branches: [ master ] + pull_request: + workflow_dispatch: + +jobs: + build-linux: + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y cmake build-essential zlib1g-dev libzip-dev opencl-headers ocl-icd-opencl-dev + + - name: Cache CMake build + uses: actions/cache@v4 + with: + path: | + cpp/CMakeCache.txt + cpp/CMakeFiles + key: ${{ runner.os }}-cmake-${{ hashFiles('**/CMakeLists.txt') }} + restore-keys: | + ${{ runner.os }}-cmake- + + - name: Configure CMake + working-directory: cpp + run: | + cmake . -DUSE_BACKEND=OPENCL -DNO_GIT_REVISION=1 + + - name: Build + working-directory: cpp + run: | + make -j$(nproc) + + - name: Run tests + run: | + cpp/katago runtests + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: katago-linux-opencl + path: cpp/katago + + build-windows: + runs-on: windows-latest + permissions: + contents: read + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup MSVC + uses: microsoft/setup-msbuild@v2 + + - name: Cache vcpkg packages + uses: actions/cache@v4 + with: + path: | + ${{ env.VCPKG_INSTALLATION_ROOT }}/installed + ${{ env.VCPKG_INSTALLATION_ROOT }}/packages + key: ${{ runner.os }}-vcpkg-${{ hashFiles('**/vcpkg.json') }}-opencl + restore-keys: | + ${{ runner.os }}-vcpkg- + + - name: Install vcpkg dependencies + run: | + vcpkg install zlib:x64-windows libzip:x64-windows opencl:x64-windows + + - name: Configure CMake + working-directory: cpp + run: | + cmake . -G "Visual Studio 17 2022" -A x64 ` + -DUSE_BACKEND=OPENCL ` + -DNO_GIT_REVISION=1 ` + -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" + + - name: Build + working-directory: cpp + run: | + cmake --build . --config Release -j 4 + + - name: Copy required DLLs + working-directory: cpp + run: | + $vcpkgRoot = $env:VCPKG_INSTALLATION_ROOT + Copy-Item "$vcpkgRoot/installed/x64-windows/bin/*.dll" -Destination "Release/" -ErrorAction SilentlyContinue + + - name: Run tests + run: | + cpp/Release/katago.exe runtests + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: katago-windows-opencl + path: cpp/Release/katago.exe From 7cb021858597fa0e281fac689a59068115cbef01 Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Sun, 16 Nov 2025 14:17:19 +0100 Subject: [PATCH 2/8] [CI] Support for GitHub CI on macOS (OpenCL) --- .github/workflows/build.yml | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2fcddf4a3..1a9da66e6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,6 +51,47 @@ jobs: name: katago-linux-opencl path: cpp/katago + build-macos: + runs-on: macos-latest + permissions: + contents: read + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install dependencies + run: | + brew install zlib libzip opencl-headers + - name: Cache CMake build + uses: actions/cache@v4 + with: + path: | + cpp/CMakeCache.txt + cpp/CMakeFiles + cpp/build.ninja + cpp/.ninja_deps + cpp/.ninja_log + key: ${{ runner.os }}-cmake-${{ hashFiles('**/CMakeLists.txt') }} + restore-keys: | + ${{ runner.os }}-cmake- + - name: Configure CMake + working-directory: cpp + run: | + cmake . -G Ninja -DUSE_BACKEND=OPENCL -DNO_GIT_REVISION=1 + - name: Build + working-directory: cpp + run: | + ninja + - name: Run tests + run: | + cpp/katago runtests + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: katago-macos-opencl + path: cpp/katago + build-windows: runs-on: windows-latest permissions: From 4f5ab3bd72f49ea9b7d68cf3b2b0bc2bcb16fbd9 Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Sun, 16 Nov 2025 14:26:33 +0100 Subject: [PATCH 3/8] [CI] Set up `Release` build type for all platforms --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1a9da66e6..fcc65bb4f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,7 +34,7 @@ jobs: - name: Configure CMake working-directory: cpp run: | - cmake . -DUSE_BACKEND=OPENCL -DNO_GIT_REVISION=1 + cmake . -DUSE_BACKEND=OPENCL -DNO_GIT_REVISION=1 -DCMAKE_BUILD_TYPE=Release - name: Build working-directory: cpp @@ -78,7 +78,7 @@ jobs: - name: Configure CMake working-directory: cpp run: | - cmake . -G Ninja -DUSE_BACKEND=OPENCL -DNO_GIT_REVISION=1 + cmake . -G Ninja -DUSE_BACKEND=OPENCL -DNO_GIT_REVISION=1 -DCMAKE_BUILD_TYPE=Release - name: Build working-directory: cpp run: | From 57fa3c88fe2ebb8da562d473a58cd9b2bfcaa50c Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Sun, 16 Nov 2025 14:38:57 +0100 Subject: [PATCH 4/8] [CI] Strip debugging symbols while compiling on Linux Otherwise, the executable is too big even in Release mode --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fcc65bb4f..3980cfdaf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -34,7 +34,7 @@ jobs: - name: Configure CMake working-directory: cpp run: | - cmake . -DUSE_BACKEND=OPENCL -DNO_GIT_REVISION=1 -DCMAKE_BUILD_TYPE=Release + cmake . -DUSE_BACKEND=OPENCL -DNO_GIT_REVISION=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS_RELEASE="-s" - name: Build working-directory: cpp From 525f66cf0ae0f6650ad9dd70eb881560877c4405 Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Sat, 22 Nov 2025 11:19:52 +0100 Subject: [PATCH 5/8] [CI] Upload artifacts only on pushes to master It doesn't make sense to store artifacts from non-master branches --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3980cfdaf..dc5c3ba9f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,6 +46,7 @@ jobs: cpp/katago runtests - name: Upload artifact + if: github.event_name == 'push' && github.ref == 'refs/heads/master' uses: actions/upload-artifact@v4 with: name: katago-linux-opencl @@ -87,6 +88,7 @@ jobs: run: | cpp/katago runtests - name: Upload artifact + if: github.event_name == 'push' && github.ref == 'refs/heads/master' uses: actions/upload-artifact@v4 with: name: katago-macos-opencl @@ -142,6 +144,7 @@ jobs: cpp/Release/katago.exe runtests - name: Upload artifact + if: github.event_name == 'push' && github.ref == 'refs/heads/master' uses: actions/upload-artifact@v4 with: name: katago-windows-opencl From 728dd0cbb821e08bfdc01e5688aa1c74dfb8ff1a Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Sat, 13 Dec 2025 23:52:31 +0100 Subject: [PATCH 6/8] [CI] Pack necessary .dll in resulting Windows artifact --- .github/workflows/build.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dc5c3ba9f..1f82926fa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,6 +4,7 @@ on: push: branches: [ master ] pull_request: + branches: [ master ] workflow_dispatch: jobs: @@ -137,7 +138,7 @@ jobs: working-directory: cpp run: | $vcpkgRoot = $env:VCPKG_INSTALLATION_ROOT - Copy-Item "$vcpkgRoot/installed/x64-windows/bin/*.dll" -Destination "Release/" -ErrorAction SilentlyContinue + Copy-Item "$vcpkgRoot/installed/x64-windows/bin/*.dll" -Destination "Release/" - name: Run tests run: | @@ -148,4 +149,4 @@ jobs: uses: actions/upload-artifact@v4 with: name: katago-windows-opencl - path: cpp/Release/katago.exe + path: cpp/Release/ From dce3558aae67d3c5fb2cfb41f98e73a2a362b9c9 Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Sun, 14 Dec 2025 00:31:15 +0100 Subject: [PATCH 7/8] [CI] Remove `-DNO_GIT_REVISION=1` to include revision in resulting artifacts --- .github/workflows/build.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1f82926fa..449cccf60 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,7 +35,7 @@ jobs: - name: Configure CMake working-directory: cpp run: | - cmake . -DUSE_BACKEND=OPENCL -DNO_GIT_REVISION=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS_RELEASE="-s" + cmake . -DUSE_BACKEND=OPENCL -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS_RELEASE="-s" - name: Build working-directory: cpp @@ -80,7 +80,7 @@ jobs: - name: Configure CMake working-directory: cpp run: | - cmake . -G Ninja -DUSE_BACKEND=OPENCL -DNO_GIT_REVISION=1 -DCMAKE_BUILD_TYPE=Release + cmake . -G Ninja -DUSE_BACKEND=OPENCL -DCMAKE_BUILD_TYPE=Release - name: Build working-directory: cpp run: | @@ -126,7 +126,6 @@ jobs: run: | cmake . -G "Visual Studio 17 2022" -A x64 ` -DUSE_BACKEND=OPENCL ` - -DNO_GIT_REVISION=1 ` -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" - name: Build From 702b38532628bc3cc4302e912a10dae2c934eea0 Mon Sep 17 00:00:00 2001 From: Ivan Kochurkin Date: Sun, 14 Dec 2025 00:36:18 +0100 Subject: [PATCH 8/8] [CI] Set up working directory for tests to run config parsing tests --- .github/workflows/build.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 449cccf60..708479f79 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,8 +43,9 @@ jobs: make -j$(nproc) - name: Run tests + working-directory: cpp run: | - cpp/katago runtests + ./katago runtests - name: Upload artifact if: github.event_name == 'push' && github.ref == 'refs/heads/master' @@ -86,8 +87,9 @@ jobs: run: | ninja - name: Run tests + working-directory: cpp run: | - cpp/katago runtests + ./katago runtests - name: Upload artifact if: github.event_name == 'push' && github.ref == 'refs/heads/master' uses: actions/upload-artifact@v4 @@ -140,8 +142,9 @@ jobs: Copy-Item "$vcpkgRoot/installed/x64-windows/bin/*.dll" -Destination "Release/" - name: Run tests + working-directory: cpp run: | - cpp/Release/katago.exe runtests + Release/katago.exe runtests - name: Upload artifact if: github.event_name == 'push' && github.ref == 'refs/heads/master'