-
Notifications
You must be signed in to change notification settings - Fork 0
155 lines (121 loc) · 4.36 KB
/
ci.yml
File metadata and controls
155 lines (121 loc) · 4.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# CI workflow for cpp-library project itself
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
jobs:
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Run dependency mapping tests
run: cmake -P tests/install/CMakeLists.txt
- name: Run provider merging tests
run: cmake -P tests/install/test_provider_merge.cmake
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Download CPM.cmake
run: |
mkdir -p cmake
wget -q -O cmake/CPM.cmake https://github.com/cpm-cmake/CPM.cmake/releases/latest/download/get_cpm.cmake
- name: Create test project
run: |
mkdir -p test-project/include/testlib
cd test-project
# Create CMakeLists.txt that uses cpp-library
cat > CMakeLists.txt << 'EOF'
cmake_minimum_required(VERSION 3.24)
# Setup CPM before project()
include(../cmake/CPM.cmake)
# Fetch cpp-library before project()
# Check https://github.com/stlab/cpp-library/releases for the latest version
CPMAddPackage(NAME cpp-library SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
include(${cpp-library_SOURCE_DIR}/cpp-library.cmake)
# Enable dependency tracking before project()
cpp_library_enable_dependency_tracking()
# Now call project()
project(mylib VERSION 1.0.0)
# Create a simple test library
cpp_library_setup(
DESCRIPTION "Test library for cpp-library"
NAMESPACE testlib
HEADERS mylib.hpp
)
EOF
# Create a simple header
cat > include/testlib/mylib.hpp << 'EOF'
#pragma once
namespace testlib {
inline int get_value() { return 42; }
}
EOF
- name: Configure test project
run: |
cd test-project
cmake -B build -DCMAKE_BUILD_TYPE=Release
- name: Build test project
run: |
cd test-project
cmake --build build
- name: Install test project
run: |
cd test-project
cmake --install build --prefix ${{ runner.temp }}/install
- name: Verify installation
run: |
# Check that package config was installed
if [ ! -f "${{ runner.temp }}/install/lib/cmake/testlib-mylib/testlib-mylibConfig.cmake" ]; then
echo "Error: Package config not found"
exit 1
fi
echo "✓ Installation successful"
- name: Test find_package
run: |
mkdir -p test-consumer
cd test-consumer
# Create a consumer project
cat > CMakeLists.txt << 'EOF'
cmake_minimum_required(VERSION 3.20)
project(test-consumer)
find_package(testlib-mylib REQUIRED)
add_executable(consumer main.cpp)
target_link_libraries(consumer PRIVATE testlib::mylib)
EOF
# Create main.cpp
cat > main.cpp << 'EOF'
#include <testlib/mylib.hpp>
#include <iostream>
int main() {
std::cout << "Value: " << testlib::get_value() << std::endl;
return 0;
}
EOF
# Configure with installed package
cmake -B build -DCMAKE_PREFIX_PATH=${{ runner.temp }}/install
# Build
cmake --build build
echo "✓ Consumer project built successfully"
documentation:
name: Documentation Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Check README examples
run: |
# Extract and validate code blocks from README
grep -A 20 '```cmake' README.md | head -50
echo "✓ README documentation looks valid"
- name: Validate template files
run: |
# Check that all template files exist
test -f templates/CMakePresets.json
test -f templates/Config.cmake.in
test -f templates/Doxyfile.in
test -f templates/custom.css
echo "✓ All template files present"