Skip to content

Commit 5b6aeea

Browse files
committed
Testing CPP library update
1 parent 11a7734 commit 5b6aeea

4 files changed

Lines changed: 136 additions & 54 deletions

File tree

.github/workflows/ci.yml

Lines changed: 118 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ name: CI
55

66
on:
77
push:
8-
branches: [ main, develop ]
8+
branches: [main, develop]
99
pull_request:
10-
branches: [ main ]
10+
branches: [main]
1111
release:
1212
types: [published]
1313

@@ -32,42 +32,109 @@ jobs:
3232
runs-on: ${{ matrix.os }}
3333

3434
steps:
35-
- uses: actions/checkout@v4
35+
- uses: actions/checkout@v5
3636

37-
- name: Configure CMake
38-
run: cmake --preset=test
37+
- name: Configure CMake
38+
run: cmake --preset=test
3939

40-
- name: Build
41-
run: cmake --build --preset=test
40+
- name: Build
41+
run: cmake --build --preset=test
4242

43-
- name: Test
44-
run: ctest --preset=test
43+
- name: Test
44+
run: ctest --preset=test
4545

46-
clang-tidy:
47-
runs-on: ubuntu-latest
48-
49-
steps:
50-
- uses: actions/checkout@v4
46+
install-test:
47+
name: Test Installation (${{ matrix.os }})
48+
runs-on: ${{ matrix.os }}
49+
needs: test
50+
strategy:
51+
fail-fast: false
52+
matrix:
53+
os: [ubuntu-latest, macos-latest, windows-latest]
5154

52-
- name: Setup Ninja
53-
uses: ashutoshvarma/setup-ninja@master
55+
steps:
56+
- uses: actions/checkout@v5
57+
58+
- name: Build and Install
59+
run: |
60+
cmake --preset=default
61+
cmake --build --preset=default
62+
cmake --install build/default --prefix ${{ runner.temp }}/install
63+
64+
- name: Test find_package
65+
shell: bash
66+
run: |
67+
# Create a minimal test to verify the installation works with find_package
68+
mkdir -p ${{ runner.temp }}/test-find-package
69+
cd ${{ runner.temp }}/test-find-package
70+
71+
# Get project name from CMakeLists.txt
72+
PROJECT_NAME=$(grep -m1 "project(" ${{ github.workspace }}/CMakeLists.txt | sed 's/project(\(.*\))/\1/' | awk '{print $1}')
73+
74+
# Create test CMakeLists.txt
75+
cat > CMakeLists.txt << EOF
76+
cmake_minimum_required(VERSION 3.20)
77+
project(test-find-package CXX)
78+
79+
set(CMAKE_PREFIX_PATH "${{ runner.temp }}/install")
80+
find_package(\${PROJECT_NAME} REQUIRED)
81+
82+
message(STATUS "Successfully found \${PROJECT_NAME}")
83+
EOF
84+
85+
# Test find_package
86+
cmake -B build -S .
87+
88+
- name: Test CPMFindPackage
89+
shell: bash
90+
run: |
91+
# Create test to verify CPMFindPackage works (tries find_package first, then CPM)
92+
mkdir -p ${{ runner.temp }}/test-cpm
93+
cd ${{ runner.temp }}/test-cpm
94+
95+
# Download CPM.cmake
96+
mkdir cmake
97+
curl -L https://github.com/cpm-cmake/CPM.cmake/releases/latest/download/get_cpm.cmake -o cmake/CPM.cmake
98+
99+
# Get project name from CMakeLists.txt
100+
PROJECT_NAME=$(grep -m1 "project(" ${{ github.workspace }}/CMakeLists.txt | sed 's/project(\(.*\))/\1/' | awk '{print $1}')
101+
102+
# Create test CMakeLists.txt that uses CPMFindPackage
103+
cat > CMakeLists.txt << EOF
104+
cmake_minimum_required(VERSION 3.20)
105+
project(test-cpm CXX)
106+
107+
set(CMAKE_PREFIX_PATH "${{ runner.temp }}/install")
108+
set(CPM_SOURCE_CACHE \${CMAKE_SOURCE_DIR}/.cache/cpm CACHE PATH "CPM cache")
109+
include(cmake/CPM.cmake)
110+
111+
# CPMFindPackage tries find_package first, then falls back to CPMAddPackage
112+
CPMFindPackage(
113+
NAME \${PROJECT_NAME}
114+
GITHUB_REPOSITORY ${{ github.repository }}
115+
GIT_TAG ${{ github.sha }}
116+
)
117+
118+
message(STATUS "Successfully acquired \${PROJECT_NAME} via CPMFindPackage")
119+
EOF
120+
121+
# Test CPMFindPackage (should find the installed version first)
122+
cmake -B build -S .
54123
55-
- name: Setup Clang
56-
uses: egor-tensin/setup-clang@v1
57-
with:
58-
version: latest
124+
clang-tidy:
125+
runs-on: ubuntu-latest
59126

60-
- name: Install clang-tidy
61-
run: sudo apt-get update && sudo apt-get install -y clang-tidy
127+
steps:
128+
- uses: actions/checkout@v5
62129

63-
- name: Configure CMake with clang-tidy
64-
run: cmake --preset=clang-tidy
130+
- name: Configure CMake with clang-tidy
131+
run: cmake --preset=clang-tidy
65132

66-
- name: Build with clang-tidy
67-
run: cmake --build --preset=clang-tidy
133+
- name: Build with clang-tidy
134+
run: cmake --build --preset=clang-tidy
68135

69-
- name: Run tests with clang-tidy
70-
run: ctest --preset=clang-tidy
136+
- name: Run tests with clang-tidy
137+
run: ctest --preset=clang-tidy
71138

72139
docs:
73140
runs-on: ubuntu-latest
@@ -76,27 +143,27 @@ jobs:
76143
id-token: write
77144
pages: write
78145
contents: read
79-
146+
80147
steps:
81-
- uses: actions/checkout@v5
82-
83-
- name: Install Doxygen
84-
uses: ssciwr/doxygen-install@v1
85-
86-
- name: Configure CMake
87-
run: cmake --preset=docs
88-
89-
- name: Build Documentation
90-
run: cmake --build --preset=docs
91-
92-
- name: Setup Pages
93-
uses: actions/configure-pages@v5
94-
95-
- name: Upload artifact
96-
uses: actions/upload-pages-artifact@v3
97-
with:
98-
path: build/docs/html
99-
100-
- name: Deploy to GitHub Pages
101-
id: deployment
102-
uses: actions/deploy-pages@v4
148+
- uses: actions/checkout@v5
149+
150+
- name: Install Doxygen
151+
uses: ssciwr/doxygen-install@v1
152+
153+
- name: Configure CMake
154+
run: cmake --preset=docs
155+
156+
- name: Build Documentation
157+
run: cmake --build --preset=docs
158+
159+
- name: Setup Pages
160+
uses: actions/configure-pages@v5
161+
162+
- name: Upload artifact
163+
uses: actions/upload-pages-artifact@v4
164+
with:
165+
path: build/docs/html
166+
167+
- name: Deploy to GitHub Pages
168+
id: deployment
169+
uses: actions/deploy-pages@v4

.vscode/extensions.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"_comment": "Auto-generated from cpp-library (https://github.com/stlab/cpp-library) - Do not edit this file directly",
32
"recommendations": [
43
"matepek.vscode-catch2-test-adapter",
54
"llvm-vs-code-extensions.vscode-clangd",

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ include(cmake/CPM.cmake)
1313
# NAME cpp-library
1414
# URL "${CMAKE_SOURCE_DIR}/../cpp-library"
1515
# )
16-
CPMAddPackage("gh:stlab/cpp-library@4.0.3")
16+
CPMAddPackage("gh:stlab/cpp-library#3ab13f2be3b835fd1e6feaab7845088c31642eba")
17+
# CPMAddPackage("gh:stlab/cpp-library@4.0.3")
1718
include(${cpp-library_SOURCE_DIR}/cpp-library.cmake)
1819

1920
# Let cpp-library handle the project declaration and version detection

CMakePresets.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,29 @@
6868
"CMAKE_CXX_EXTENSIONS": "OFF",
6969
"CPP_LIBRARY_FORCE_INIT": "ON"
7070
}
71+
},
72+
{
73+
"name": "install",
74+
"displayName": "Local Install Test",
75+
"description": "Configuration for testing installation locally (installs to build/install/prefix)",
76+
"binaryDir": "${sourceDir}/build/install",
77+
"generator": "Ninja",
78+
"cacheVariables": {
79+
"CMAKE_BUILD_TYPE": "Release",
80+
"BUILD_TESTING": "OFF",
81+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
82+
"CMAKE_CXX_EXTENSIONS": "OFF",
83+
"CMAKE_INSTALL_PREFIX": "${sourceDir}/build/install/prefix"
84+
}
7185
}
7286
],
7387
"buildPresets": [
7488
{ "name": "default", "displayName": "Default Build", "configurePreset": "default" },
7589
{ "name": "test", "displayName": "Build Tests", "configurePreset": "test" },
7690
{ "name": "docs", "displayName": "Build Docs", "configurePreset": "docs", "targets": "docs" },
7791
{ "name": "clang-tidy", "displayName": "Build with Clang-Tidy", "configurePreset": "clang-tidy" },
78-
{ "name": "init", "displayName": "Initialize Templates", "configurePreset": "init" }
92+
{ "name": "init", "displayName": "Initialize Templates", "configurePreset": "init" },
93+
{ "name": "install", "displayName": "Build for Local Install", "configurePreset": "install" }
7994
],
8095
"testPresets": [
8196
{ "name": "test", "displayName": "Run All Tests", "configurePreset": "test", "output": { "outputOnFailure": true } },

0 commit comments

Comments
 (0)