Skip to content
154 changes: 154 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
name: Build and Test

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
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 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS_RELEASE="-s"
- name: Build
working-directory: cpp
run: |
make -j$(nproc)
- name: Run tests
working-directory: cpp
run: |
./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
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 -DCMAKE_BUILD_TYPE=Release
- name: Build
working-directory: cpp
run: |
ninja
- name: Run tests
working-directory: cpp
run: |
./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
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 `
-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/"
- name: Run tests
working-directory: cpp
run: |
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
path: cpp/Release/