Skip to content

Commit 5adde6c

Browse files
authored
Setting up Windows CI workflow (#46)
* added windows version of docker image serving as a base for cicd * wouaou, this is kinda working, insanely difficult to make this windows container run shitty powershell * this version was working, but failures at cmake configuration time * removed unecessary comments * save * renamed workflows * renamed build push docker image wf * added test configuration flag for msvc tests presets * had to write my own constexpr std::abs function only for msvc that does not support c++ 23 features... * updated build workflows * Typo * removed cl.exe version used for debug * backticks are bugged * there was some missing buildPresets configuration for msvc. msvc is a multi configuration generator and therefore needs the information of build configuration. * removed vcpkg setup in the windows runner as it already exists on the windows image * reset linux ci since debug is done * deleted former windows docker image that was originally for github runners but is overkill and hard to configure (windows github runner is already well populated)
1 parent 9c38403 commit 5adde6c

File tree

6 files changed

+114
-14
lines changed

6 files changed

+114
-14
lines changed

.github/workflows/docker_build_push.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Push Docker Image
1+
name: Build Push Linux Docker Image
22

33
on:
44
workflow_dispatch:
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: Linux Build
22

33
on:
44
push:
@@ -9,7 +9,7 @@ permissions:
99
packages: read
1010

1111
jobs:
12-
linux:
12+
linux-build:
1313
runs-on: ubuntu-latest
1414

1515
container:
@@ -47,7 +47,7 @@ jobs:
4747
4848
exit $CONFIGURE_EXIT_CODE
4949
50-
- name: Build
50+
- name: Build (${{ matrix.preset }})
5151
run: |
5252
set +e
5353
cmake --build --preset ${{ matrix.preset }} 2>&1 | tee build_output.txt
@@ -69,7 +69,7 @@ jobs:
6969
7070
exit $BUILD_EXIT_CODE
7171
72-
- name: Test
72+
- name: Test (${{ matrix.preset }})
7373
run: |
7474
set +e
7575
ctest --preset ${{ matrix.preset }} --output-on-failure 2>&1 | tee test_output.txt
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Windows Build
2+
3+
on:
4+
push:
5+
workflow_dispatch:
6+
7+
jobs:
8+
windows-build:
9+
runs-on: windows-2022
10+
11+
strategy:
12+
matrix:
13+
preset: [ msvc_debug, msvc_release ]
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Configure (${{ matrix.preset }})
19+
env:
20+
VCPKG_ROOT: C:\vcpkg
21+
shell: pwsh
22+
run: |
23+
$outputFile = "configure_output.txt"
24+
25+
cmake --preset ${{ matrix.preset }} 2>&1 | Tee-Object -FilePath $outputFile
26+
$exitCode = $LASTEXITCODE
27+
28+
if ($exitCode -eq 0) {
29+
Add-Content $env:GITHUB_STEP_SUMMARY "<details><summary>🟢 Configure Results (click to expand)</summary>"
30+
} else {
31+
Add-Content $env:GITHUB_STEP_SUMMARY "## 🔴 Configure Results"
32+
}
33+
34+
Add-Content $env:GITHUB_STEP_SUMMARY ""
35+
Add-Content $env:GITHUB_STEP_SUMMARY '```'
36+
Get-Content $outputFile | Add-Content $env:GITHUB_STEP_SUMMARY
37+
Add-Content $env:GITHUB_STEP_SUMMARY '```'
38+
39+
if ($exitCode -eq 0) {
40+
Add-Content $env:GITHUB_STEP_SUMMARY "</details>"
41+
}
42+
43+
exit $exitCode
44+
45+
- name: Build (${{ matrix.preset }})
46+
shell: pwsh
47+
run: |
48+
$outputFile = "build_output.txt"
49+
50+
cmake --build --preset ${{ matrix.preset }} 2>&1 | Tee-Object -FilePath $outputFile
51+
$exitCode = $LASTEXITCODE
52+
53+
if ($exitCode -eq 0) {
54+
Add-Content $env:GITHUB_STEP_SUMMARY "<details><summary>🟢 Build Results (click to expand)</summary>"
55+
} else {
56+
Add-Content $env:GITHUB_STEP_SUMMARY "## 🔴 Build Results"
57+
}
58+
59+
Add-Content $env:GITHUB_STEP_SUMMARY ""
60+
Add-Content $env:GITHUB_STEP_SUMMARY '```'
61+
Get-Content $outputFile | Add-Content $env:GITHUB_STEP_SUMMARY
62+
Add-Content $env:GITHUB_STEP_SUMMARY '```'
63+
64+
if ($exitCode -eq 0) {
65+
Add-Content $env:GITHUB_STEP_SUMMARY "</details>"
66+
}
67+
68+
exit $exitCode
69+
70+
- name: Test (${{ matrix.preset }})
71+
shell: pwsh
72+
run: |
73+
$outputFile = "test_output.txt"
74+
75+
ctest --preset ${{ matrix.preset }} --output-on-failure 2>&1 | Tee-Object -FilePath $outputFile
76+
$exitCode = $LASTEXITCODE
77+
78+
if ($exitCode -eq 0) {
79+
Add-Content $env:GITHUB_STEP_SUMMARY "<details><summary>🟢 Test Results (click to expand)</summary>"
80+
} else {
81+
Add-Content $env:GITHUB_STEP_SUMMARY "## 🔴 Test Results"
82+
}
83+
84+
Add-Content $env:GITHUB_STEP_SUMMARY ""
85+
Add-Content $env:GITHUB_STEP_SUMMARY '```'
86+
Get-Content $outputFile | Add-Content $env:GITHUB_STEP_SUMMARY
87+
Add-Content $env:GITHUB_STEP_SUMMARY '```'
88+
89+
if ($exitCode -eq 0) {
90+
Add-Content $env:GITHUB_STEP_SUMMARY "</details>"
91+
}
92+
93+
exit $exitCode

CMakePresets.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@
6666
},
6767
{
6868
"name": "msvc_debug",
69-
"configurePreset": "msvc_debug"
69+
"configurePreset": "msvc_debug",
70+
"configuration": "Debug"
7071
},
7172
{
7273
"name": "msvc_release",
73-
"configurePreset": "msvc_release"
74+
"configurePreset": "msvc_release",
75+
"configuration": "Release"
7476
}
7577
],
7678
"testPresets": [
@@ -84,11 +86,13 @@
8486
},
8587
{
8688
"name": "msvc_debug",
87-
"configurePreset": "msvc_debug"
89+
"configurePreset": "msvc_debug",
90+
"configuration": "Debug"
8891
},
8992
{
9093
"name": "msvc_release",
91-
"configurePreset": "msvc_release"
94+
"configurePreset": "msvc_release",
95+
"configuration": "Release"
9296
}
9397
],
9498
"packagePresets": [

docker/ubuntu/Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Commands:
2-
# [build] docker build -t ghr-chess-engine-ubuntu . -f docker/ubuntu/Dockerfile
3-
# [run] docker run -it --rm ghr-chess-engine-ubuntu
4-
# [configure cmake] cmake --preset=clang_release
5-
# [build cmake] cmake --build --preset=clang_release
2+
# [build] docker build -t bitbishop-ubuntu . -f docker/ubuntu/Dockerfile
3+
# [run] docker run -it --rm bitbishop-ubuntu
64

75
FROM ubuntu:24.04
86

include/bitbishop/moves/pawn_move_gen.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ constexpr bool is_promotion_rank(Square sq, Color c) { return c == Color::WHITE
102102
* @return true if the capture geometry is valid for en passant, false otherwise
103103
*/
104104
constexpr bool can_capture_en_passant(Square from, Square epsq, Color side) noexcept {
105-
int df = std::abs(int(from.file()) - int(epsq.file()));
105+
// MSVC have not yet made std::abs() constexpr for C++ 23, forcing us to define a generic constexpr one...
106+
// For this, lets apply the abs() function manually. This is sad, but you know, MSVC...
107+
// The code should not adapt to the compiler for the same language, the compiler should...
108+
int df = int(from.file()) - int(epsq.file());
109+
df = (df < 0) ? -df : df;
110+
106111
if (df != 1) return false;
107112
if (side == Color::WHITE && from.rank() == 4 && epsq.rank() == 5) return true;
108113
if (side == Color::BLACK && from.rank() == 3 && epsq.rank() == 2) return true;

0 commit comments

Comments
 (0)