Skip to content

Commit f291e70

Browse files
authored
Merge pull request #35 from CLOCTools/github-actions-workflow
GitHub Actions workflow for automated build and test
2 parents 6f09abb + 8c7d853 commit f291e70

File tree

2 files changed

+121
-0
lines changed

2 files changed

+121
-0
lines changed

.github/workflows/build.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Build and Test ldsCtrlEst
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
strategy:
13+
matrix:
14+
os: [ubuntu-latest, macos-latest, windows-latest]
15+
16+
runs-on: ${{ matrix.os }}
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v3
21+
with:
22+
submodules: recursive
23+
24+
- name: Set up dependencies for macOS and Linux
25+
if: runner.os != 'Windows'
26+
run: |
27+
if [ "${{ runner.os }}" == "macOS" ]; then
28+
brew install cmake ninja
29+
elif [ "${{ runner.os }}" == "Linux" ]; then
30+
sudo apt-get update
31+
sudo apt-get install -y cmake build-essential
32+
fi
33+
34+
- name: Set up dependencies for Windows
35+
if: runner.os == 'Windows'
36+
run: |
37+
choco install cmake
38+
39+
- name: Run vcpkg
40+
uses: lukka/run-vcpkg@v11
41+
with:
42+
vcpkgJsonGlob: 'vcpkg.json'
43+
runVcpkgInstall: true
44+
45+
- name: Cache build directory
46+
uses: actions/cache@v3
47+
with:
48+
path: build
49+
key: build-${{ matrix.os }}-${{ hashFiles('CMakeLists.txt') }}
50+
restore-keys: |
51+
build-${{ matrix.os }}-
52+
53+
- name: Configure and build for macOS/Linux
54+
if: runner.os != 'Windows'
55+
uses: lukka/run-cmake@v10
56+
with:
57+
cmakeListsTxtPath: CMakeLists.txt
58+
configurePreset: 'linux-release'
59+
buildPreset: 'linux-release'
60+
61+
- name: Configure and build for Windows
62+
if: runner.os == 'Windows'
63+
uses: lukka/run-cmake@v10
64+
with:
65+
cmakeListsTxtPath: CMakeLists.txt
66+
configurePreset: 'windows-release'
67+
buildPreset: 'windows-release'
68+
69+
- name: Install and Update PATH (Windows only)
70+
if: runner.os == 'Windows'
71+
run: |
72+
cd build
73+
cmake --install .
74+
echo "${{github.workspace}}/install/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
75+
76+
- name: Run tests
77+
run: |
78+
cd build
79+
ctest -C Release

CMakePresets.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"version": 3,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 18,
6+
"patch": 0
7+
},
8+
"configurePresets": [
9+
{
10+
"name": "linux-release",
11+
"hidden": false,
12+
"generator": "Unix Makefiles",
13+
"binaryDir": "${sourceDir}/build",
14+
"cacheVariables": {
15+
"CMAKE_BUILD_TYPE": "Release",
16+
"CMAKE_INSTALL_PREFIX": "${sourceDir}/install"
17+
}
18+
},
19+
{
20+
"name": "windows-release",
21+
"hidden": false,
22+
"generator": "Visual Studio 17 2022",
23+
"binaryDir": "${sourceDir}/build",
24+
"cacheVariables": {
25+
"CMAKE_BUILD_TYPE": "Release",
26+
"CMAKE_INSTALL_PREFIX": "${sourceDir}/install"
27+
}
28+
}
29+
],
30+
"buildPresets": [
31+
{
32+
"name": "linux-release",
33+
"configurePreset": "linux-release",
34+
"hidden": false
35+
},
36+
{
37+
"name": "windows-release",
38+
"configurePreset": "windows-release",
39+
"hidden": false
40+
}
41+
]
42+
}

0 commit comments

Comments
 (0)