Skip to content

Commit 58cb6fb

Browse files
authored
Merge pull request #288 from cwellm/Add-Windows-CI
Add basic windows ci
2 parents b1c509d + e6e8a58 commit 58cb6fb

11 files changed

+203
-16
lines changed

.github/workflows/format.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
branches:
99
- main
1010

11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }}
13+
cancel-in-progress: true
14+
1115
jobs:
1216
build:
1317
runs-on: ubuntu-22.04
@@ -23,4 +27,3 @@ jobs:
2327
- name: check code format
2428
run: |
2529
clang-format-15 --style=file --Werror --dry-run --verbose `find . -type d \( -name '3rdparty' \) -prune -o -regex '.*\.\(cpp\|hpp\)' -print`
26-

.github/workflows/linux-build.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ on:
88
branches:
99
- main
1010

11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }}
13+
cancel-in-progress: true
14+
15+
1116
jobs:
1217
build:
1318
strategy:
@@ -68,4 +73,3 @@ jobs:
6873
- name: unit tests
6974
run: |
7075
cmake --build build --target test
71-

.github/workflows/qt5.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
branches:
99
- main
1010

11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }}
13+
cancel-in-progress: true
14+
1115
jobs:
1216
build:
1317
runs-on: ubuntu-22.04
@@ -74,4 +78,3 @@ jobs:
7478
(cd examples/CalcQt; cucumber)
7579
wait %
7680
done
77-

.github/workflows/run-all.yml

+10-4
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,19 @@ on:
88
branches:
99
- main
1010

11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }}
13+
cancel-in-progress: true
14+
1115
jobs:
12-
build:
16+
build-linux:
1317
runs-on: ubuntu-22.04
1418

1519
steps:
16-
- uses: actions/checkout@v2
20+
- uses: actions/checkout@v4
21+
22+
- name: update package index
23+
run: sudo apt-get -y update
1724

1825
- name: setup environment
1926
run: |
@@ -49,7 +56,7 @@ jobs:
4956
5057
- name: build and run
5158
run: |
52-
./run-all.sh
59+
./run-linux.sh
5360
5461
- name: code coverage summary report
5562
uses: irongut/[email protected]
@@ -64,4 +71,3 @@ jobs:
6471
run: |
6572
echo '# Code Coverage Report' >> $GITHUB_STEP_SUMMARY
6673
cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
67-

.github/workflows/windows-build.yml

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Windows build
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
workflow_dispatch:
7+
push:
8+
branches:
9+
- main
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
build:
17+
strategy:
18+
matrix:
19+
cpp-standard:
20+
- 17
21+
- 20
22+
# You can find specific tool versions for Windows builds in the Runner specification:
23+
# https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md
24+
# In particular, this build uses:
25+
# cmake: 3.27.9
26+
# VSCode: 2022 Enterprise Edition (corresponding C++ version: https://blog.knatten.org/2022/08/26/microsoft-c-versions-explained/)
27+
# Ruby: 3.0.6p216
28+
# boost: 1.82.0
29+
runs-on: windows-2022
30+
env:
31+
BOOST_VERSION: 1.82.0
32+
NLOHMANN_CLONE_DIR: nlohmann
33+
NLOHMANN_TAG: v3.11.3
34+
ASIO_CLONE_DIR: asio
35+
ASIO_TAG: asio-1-29-0
36+
TCLAP_CLONE_DIR: tclap
37+
TCLAP_TAG: v1.2.5
38+
39+
steps:
40+
- uses: actions/checkout@v4
41+
42+
- name: install ruby tools
43+
run: |
44+
gem install bundler
45+
bundle install
46+
47+
# - name: Install Google Test
48+
# uses: MarkusJx/[email protected]
49+
50+
- name: Restore cached boost dependencies
51+
id: cache-boost-deps
52+
uses: actions/cache@v3
53+
with:
54+
path: |
55+
boost_1_82_0
56+
key: ${{ runner.os }}-boost-1820
57+
58+
- name: install boost
59+
if: steps.cache-boost-deps.outputs.cache-hit != 'true'
60+
run: |
61+
$boost_version_str = ${Env:BOOST_VERSION}.Replace(".","_")
62+
$ProgressPreference = 'SilentlyContinue'
63+
Invoke-WebRequest -Uri https://boostorg.jfrog.io/artifactory/main/release/${Env:BOOST_VERSION}/source/boost_${boost_version_str}.zip -OutFile boost_${boost_version_str}.zip
64+
7z x boost_${boost_version_str}.zip
65+
cd boost_${boost_version_str}
66+
cmd /C bootstrap
67+
./b2.exe --build-type=complete toolset=msvc --with-regex --with-program_options --with-system --with-test
68+
69+
- name: Get and build nlohmann-json
70+
run: |
71+
Start-Process "git" -ArgumentList "clone https://github.com/nlohmann/json.git $Env:NLOHMANN_CLONE_DIR --depth 1 --branch $Env:NLOHMANN_TAG" -PassThru -NoNewWindow -Wait
72+
cd $Env:NLOHMANN_CLONE_DIR
73+
cmake -B build -S .
74+
cd ..
75+
76+
- name: Get ASIO
77+
run: Start-Process "git" -ArgumentList "clone https://github.com/chriskohlhoff/asio.git $Env:ASIO_CLONE_DIR --depth 1 --branch $Env:ASIO_TAG" -PassThru -NoNewWindow -Wait
78+
79+
- name: Get TCLAP
80+
run: Start-Process "git" -ArgumentList "clone https://github.com/mirror/tclap.git $Env:TCLAP_CLONE_DIR --depth 1 --branch $Env:TCLAP_TAG" -PassThru -NoNewWindow -Wait
81+
82+
- name: build and run
83+
run: |
84+
$current_script_dir = Get-Location | Select-Object -Expand "Path"
85+
$Env:nlohmann_json_DIR = "${current_script_dir}/$Env:NLOHMANN_CLONE_DIR/build"
86+
$Env:Asio_ROOT = "${current_script_dir}/$Env:ASIO_CLONE_DIR/asio"
87+
$Env:TCLAP_ROOT = "${current_script_dir}/$Env:TCLAP_CLONE_DIR"
88+
$Env:cpp_standard = ${{ matrix.cpp-standard }}
89+
./run-windows.ps1

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@
2020
# Qt Creator
2121
/CMakeLists.txt.user
2222

23+
# build folder
24+
build

CMakeLists.txt

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
cmake_minimum_required(VERSION 3.16)
22

3-
if(NOT CMAKE_VERSION VERSION_LESS "3.3")
4-
# Don't ignore visibility related properties for non-SHARED targets
5-
cmake_policy(SET CMP0063 NEW)
6-
endif()
3+
cmake_policy(SET CMP0063 NEW)
74

8-
if (NOT CMAKE_VERSION VERSION_LESS "3.13")
9-
# CMP0077: option() honors normal variables
10-
# https://cmake.org/cmake/help/latest/policy/CMP0077.html
11-
cmake_policy(SET CMP0077 NEW)
12-
endif()
5+
# CMP0077: option() honors normal variables
6+
# https://cmake.org/cmake/help/latest/policy/CMP0077.html
7+
cmake_policy(SET CMP0077 NEW)
8+
9+
# CMP0074: find_package() makes use of <PackageName>_ROOT variables
10+
# https://cmake.org/cmake/help/latest/policy/CMP0074.html
11+
cmake_policy(SET CMP0074 NEW)
1312

1413
project(Cucumber-Cpp)
1514

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
[![Join the chat at https://gitter.im/cucumber/cucumber-cpp](https://badges.gitter.im/cucumber/cucumber-cpp.svg)](https://gitter.im/cucumber/cucumber-cpp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
44

5+
## Overview
6+
57
Cucumber-Cpp allows Cucumber to support step definitions written in C++.
68

79
* [Cucumber-Cpp Website](https://github.com/cucumber/cucumber-cpp)
@@ -15,6 +17,8 @@ with [CPP].
1517

1618
If you want to contribute code to the project, guidelines are in [CONTRIBUTING.md](CONTRIBUTING.md).
1719

20+
## Dependencies
21+
1822
It relies on a few executables:
1923

2024
* [cmake](https://cmake.org/download/) 3.16 or later.
@@ -48,6 +52,14 @@ gem install bundler // For windows: gem install bundle
4852
bundle install
4953
```
5054

55+
### Windows vs. Linux
56+
57+
To get an inspiration on how to set up the dependencies on your specific system (Windows or Linux), you may want to have a look at the
58+
workflow files [for Windows](.github/workflows/windows-build.yml) and [for Linux](.github/workflows/linux-build.yml).
59+
60+
61+
## Build
62+
5163
Building Cucumber-Cpp with tests and samples:
5264

5365
```

run-all.sh renamed to run-linux.sh

File renamed without changes.

run-windows.ps1

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# --- Function definitions ---
2+
function Invoke-CMake {
3+
param (
4+
$Arguments
5+
)
6+
$process = Start-Process "cmake" -ArgumentList "$Arguments" -NoNewWindow -Wait -PassThru
7+
If ($process.ExitCode -ne 0) {
8+
Write-Host "Abort script execution due to CMake error."
9+
Exit(42)
10+
}
11+
}
12+
13+
function Get-VariableOrEnv {
14+
param (
15+
[string]$Name
16+
)
17+
18+
$envValue = [Environment]::GetEnvironmentVariable($Name)
19+
if ($envValue -ne $null) {
20+
return $envValue
21+
}
22+
23+
if (Get-Variable -Name $Name -ErrorAction SilentlyContinue) {
24+
return (Get-Variable -Name $Name).Value
25+
}
26+
27+
return $null
28+
}
29+
30+
# --- Variable definitions ---
31+
$cpp_standard = Get-VariableOrEnv -Name "cpp_standard"
32+
33+
$nlohmann_json_DIR = Get-VariableOrEnv -Name "nlohmann_json_DIR"
34+
$Asio_ROOT = Get-VariableOrEnv -Name "Asio_ROOT"
35+
$TCLAP_ROOT = Get-VariableOrEnv -Name "TCLAP_ROOT"
36+
$Env:BOOST_ROOT = "boost_${Env:BOOST_VERSION}".Replace(".","_")
37+
38+
$Env:CTEST_OUTPUT_ON_FAILURE="ON"
39+
40+
41+
# --- Script ---
42+
43+
Invoke-CMake "-E","make_directory","build"
44+
45+
$cmake_params = "-E chdir build cmake",
46+
"-DBUILD_SHARED_LIBS=`"${BUILD_SHARED_LIBS}`"",
47+
"-DCMAKE_INSTALL_PREFIX=${HOME}/.local"
48+
49+
$cmake_params += "-DCMAKE_CXX_STANDARD=${cpp_standard}"
50+
51+
$cmake_params += "-DCUKE_ENABLE_BOOST_TEST=OFF"
52+
$cmake_params += "-DCUKE_ENABLE_GTEST=OFF"
53+
$cmake_params += "-DCUKE_ENABLE_QT_6=OFF"
54+
$cmake_params += "-DCUKE_ENABLE_EXAMPLES=OFF"
55+
$cmake_params += "-DCUKE_TESTS_UNIT=OFF"
56+
$cmake_params += "-DCUKE_CODE_COVERAGE=OFF"
57+
58+
$cmake_params += "-Dnlohmann_json_DIR=${nlohmann_json_DIR}"
59+
$cmake_params += "-DAsio_ROOT=${Asio_ROOT}"
60+
$cmake_params += "-DTCLAP_ROOT=${TCLAP_ROOT}"
61+
62+
$cmake_params += ".."
63+
64+
65+
Invoke-CMake "$cmake_params"
66+
Invoke-CMake "--build","build" #,"--parallel"

src/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,14 @@ foreach(TARGET
105105
PUBLIC
106106
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
107107
$<BUILD_INTERFACE:${CUKE_INCLUDE_DIR}>
108+
$<BUILD_INTERFACE:${ASIO_INCLUDE_DIR}>
109+
$<BUILD_INTERFACE:${TCLAP_INCLUDE_DIR}>
108110
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>
109111
)
110112
target_link_libraries(${TARGET}
111113
PRIVATE
112114
${CUKE_EXTRA_PRIVATE_LIBRARIES}
115+
nlohmann_json::nlohmann_json
113116
)
114117
# Don't export or import symbols for statically linked libraries
115118
get_property(type TARGET ${TARGET} PROPERTY TYPE)

0 commit comments

Comments
 (0)