Skip to content

Commit 4aea53d

Browse files
committed
Add conda package testing to CI and fix CMake package configuration
This commit adds automated testing of the conda package to ensure that downstream users can successfully use vira via find_package(vira). CI/Workflow Changes: - Change build.yml to ci-cd.yml (and name from build to CI/CD Pipeline) - Add conda-test-{linux,macos,windows} jobs that build a minimal test project against the installed conda package - Use artifacts to pass built conda packages between build and test jobs - Configure proper conda environment activation in test jobs Conda Recipe Fixes (dependencies/recipe/): - Add explicit CMAKE_INSTALL_PREFIX to build.sh and bld.bat - Disable optional build targets (tools, examples, tests, scratch, docs) - Add all development dependencies to run requirements (header-only library requires -devel packages for downstream compilation) - Add cmake config file existence tests to meta.yaml CMake Package Configuration Fixes: - Rename config files to lowercase (viraConfig.cmake, viraTargets.cmake) for proper find_package(vira) discovery - Add VIRA_INSTALL_CMAKEDIR to PATH_VARS in configure_package_config_file - Add missing find_dependency calls for indicators, plog, termcolor, cspice - Install ViraFetch*.cmake helpers for downstream dependency resolution - Create stb::stb target before including viraTargets.cmake Install Fixes: - Add helper cmake files for finding/resolving dependencies - Fix Cmake install commands to use the correct paths Test Infrastructure: - Add tests/packaging/CMakeLists.txt with minimal find_package test - Add tests/packaging/main.cpp that includes vira/vira.hpp
1 parent 8b032b4 commit 4aea53d

11 files changed

Lines changed: 242 additions & 109 deletions

File tree

Lines changed: 155 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build
1+
name: CI/CD Pipeline
22

33
on:
44
push:
@@ -104,7 +104,14 @@ jobs:
104104

105105
- name: Build conda package
106106
shell: bash -el {0}
107-
run: conda build dependencies/recipe/
107+
run: conda build dependencies/recipe/ --output-folder conda-output
108+
109+
- name: Upload conda package artifact
110+
uses: actions/upload-artifact@v4
111+
with:
112+
name: conda-package-linux
113+
path: conda-output/
114+
retention-days: 1
108115

109116
conda-build-macos:
110117
needs: build-other-platforms
@@ -130,7 +137,14 @@ jobs:
130137

131138
- name: Build conda package
132139
shell: bash -el {0}
133-
run: conda build dependencies/recipe/
140+
run: conda build dependencies/recipe/ --output-folder conda-output
141+
142+
- name: Upload conda package artifact
143+
uses: actions/upload-artifact@v4
144+
with:
145+
name: conda-package-macos
146+
path: conda-output/
147+
retention-days: 1
134148

135149
conda-build-windows:
136150
needs: build-other-platforms
@@ -156,92 +170,144 @@ jobs:
156170

157171
- name: Build conda package
158172
shell: bash -el {0}
159-
run: conda build dependencies/recipe/
160-
161-
# Tests are being temporarily removed as they have not been implemented.
162-
#test:
163-
# needs: build-linux
164-
# runs-on: ubuntu-22.04
165-
# name: Test and Coverage
166-
#
167-
# steps:
168-
# - name: Checkout code
169-
# uses: actions/checkout@v4
170-
# with:
171-
# submodules: recursive
172-
#
173-
# - name: Install lcov for coverage
174-
# run: |
175-
# sudo apt-get update
176-
# sudo apt-get install -y lcov
177-
#
178-
# - name: Set up build environment
179-
# uses: ./.github/actions/setup
180-
# with:
181-
# platform: linux
182-
#
183-
# - name: Configure project with coverage
184-
# uses: ./.github/actions/cmake-configure-test
185-
# with:
186-
# platform: linux
187-
#
188-
# - name: Build project
189-
# uses: ./.github/actions/build
190-
# with:
191-
# platform: linux
192-
#
193-
# - name: Run tests and generate coverage
194-
# shell: bash -el {0}
195-
# run: |
196-
# echo "Running tests and generating coverage report..."
197-
# cd build
198-
# cmake --build . --target coverage
199-
# echo "Coverage generation completed!"
200-
#
201-
# - name: Upload test results
202-
# uses: actions/upload-artifact@v4
203-
# if: always()
204-
# with:
205-
# name: test-results-linux
206-
# path: build/test-results/*.xml
207-
# retention-days: 30
208-
#
209-
# - name: Upload coverage reports
210-
# uses: actions/upload-artifact@v4
211-
# with:
212-
# name: coverage-report-linux
213-
# path: build/coverage/
214-
# retention-days: 30
215-
#
216-
# - name: Publish test results
217-
# uses: dorny/test-reporter@v1
218-
# if: always()
219-
# with:
220-
# name: Linux Test Results
221-
# path: build/test-results/*.xml
222-
# reporter: java-junit
223-
# fail-on-error: false
224-
#
225-
# - name: Upload coverage to Codecov
226-
# uses: codecov/codecov-action@v4
227-
# with:
228-
# file: build/coverage_filtered.info
229-
# flags: unittests
230-
# name: linux-coverage
231-
# fail_ci_if_error: false
232-
# token: ${{ secrets.CODECOV_TOKEN }}
233-
#
234-
# - name: Coverage Summary
235-
# run: |
236-
# echo "## Coverage Summary" >> $GITHUB_STEP_SUMMARY
237-
# if [ -f "build/coverage_filtered.info" ]; then
238-
# COVERAGE=$(lcov --summary build/coverage_filtered.info 2>/dev/null | grep -oP 'lines\.*: \K[0-9.]+(?=%)')
239-
# echo "Line Coverage: ${COVERAGE}%" >> $GITHUB_STEP_SUMMARY
240-
# echo "**Line Coverage:** ${COVERAGE}%" >> $GITHUB_STEP_SUMMARY
241-
# echo "[View Full Coverage Report](../actions/runs/${{ github.run_id }}/artifacts)" >> $GITHUB_STEP_SUMMARY
242-
# else
243-
# echo "Coverage report not generated" >> $GITHUB_STEP_SUMMARY
244-
# fi
173+
run: conda build dependencies/recipe/ --output-folder conda-output
174+
175+
- name: Upload conda package artifact
176+
uses: actions/upload-artifact@v4
177+
with:
178+
name: conda-package-windows
179+
path: conda-output/
180+
retention-days: 1
181+
182+
conda-test-linux:
183+
needs: conda-build-linux
184+
runs-on: ubuntu-22.04
185+
name: Conda Package Test (linux)
186+
187+
steps:
188+
- name: Checkout code (for test files only)
189+
uses: actions/checkout@v4
190+
with:
191+
sparse-checkout: |
192+
tests/packaging
193+
sparse-checkout-cone-mode: false
194+
195+
- name: Download conda package artifact
196+
uses: actions/download-artifact@v4
197+
with:
198+
name: conda-package-linux
199+
path: conda-package
200+
201+
- name: Set up Miniconda
202+
uses: conda-incubator/setup-miniconda@v3
203+
with:
204+
auto-update-conda: true
205+
conda-solver: libmamba
206+
channels: conda-forge
207+
activate-environment: test-env
208+
auto-activate-base: false
209+
210+
- name: Install dependencies and local package
211+
shell: bash -el {0}
212+
run: |
213+
conda install -y cmake ninja
214+
conda install -y -c file://$PWD/conda-package vira
215+
216+
- name: Build and run packaging test
217+
shell: bash -el {0}
218+
run: |
219+
cd tests/packaging
220+
mkdir build && cd build
221+
cmake .. -DCMAKE_PREFIX_PATH=$CONDA_PREFIX
222+
cmake --build .
223+
ctest --output-on-failure
224+
225+
conda-test-macos:
226+
needs: conda-build-macos
227+
runs-on: macos-14
228+
name: Conda Package Test (macos-arm)
229+
230+
steps:
231+
- name: Checkout code (for test files only)
232+
uses: actions/checkout@v4
233+
with:
234+
sparse-checkout: |
235+
tests/packaging
236+
sparse-checkout-cone-mode: false
237+
238+
- name: Download conda package artifact
239+
uses: actions/download-artifact@v4
240+
with:
241+
name: conda-package-macos
242+
path: conda-package
243+
244+
- name: Set up Miniconda
245+
uses: conda-incubator/setup-miniconda@v3
246+
with:
247+
auto-update-conda: true
248+
conda-solver: libmamba
249+
channels: conda-forge
250+
activate-environment: test-env
251+
auto-activate-base: false
252+
253+
- name: Install dependencies and local package
254+
shell: bash -el {0}
255+
run: |
256+
conda install -y cmake ninja
257+
conda install -y -c file://$PWD/conda-package vira
258+
259+
- name: Build and run packaging test
260+
shell: bash -el {0}
261+
run: |
262+
cd tests/packaging
263+
mkdir build && cd build
264+
cmake .. -DCMAKE_PREFIX_PATH=$CONDA_PREFIX
265+
cmake --build .
266+
ctest --output-on-failure
267+
268+
conda-test-windows:
269+
needs: conda-build-windows
270+
runs-on: windows-2022
271+
name: Conda Package Test (windows)
272+
273+
steps:
274+
- name: Checkout code (for test files only)
275+
uses: actions/checkout@v4
276+
with:
277+
sparse-checkout: |
278+
tests/packaging
279+
sparse-checkout-cone-mode: false
280+
281+
- name: Download conda package artifact
282+
uses: actions/download-artifact@v4
283+
with:
284+
name: conda-package-windows
285+
path: conda-package
286+
287+
- name: Set up Miniconda
288+
uses: conda-incubator/setup-miniconda@v3
289+
with:
290+
auto-update-conda: true
291+
conda-solver: libmamba
292+
channels: conda-forge
293+
activate-environment: test-env
294+
auto-activate-base: false
295+
296+
- name: Install dependencies and local package
297+
shell: bash -el {0}
298+
run: |
299+
conda install -y cmake ninja
300+
conda install -y -c file://$PWD/conda-package vira
301+
302+
- name: Build and run packaging test
303+
shell: powershell
304+
run: |
305+
cd tests/packaging
306+
mkdir build
307+
cd build
308+
cmake .. -DCMAKE_PREFIX_PATH="$env:CONDA_PREFIX;$env:CONDA_PREFIX/Library"
309+
cmake --build . --config Release
310+
ctest -C Release --output-on-failure
245311
246312
docs:
247313
needs: build-linux

CMakeLists.txt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,22 @@ set(VIRA_INSTALL_CMAKEDIR ${CMAKE_INSTALL_LIBDIR}/cmake/vira)
7878

7979
# Configure package config files
8080
configure_package_config_file(
81-
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/ViraConfig.cmake.in"
82-
"${CMAKE_CURRENT_BINARY_DIR}/ViraConfig.cmake"
81+
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/viraConfig.cmake.in"
82+
"${CMAKE_CURRENT_BINARY_DIR}/viraConfig.cmake"
8383
INSTALL_DESTINATION ${VIRA_INSTALL_CMAKEDIR}
84-
PATH_VARS VIRA_INSTALL_INCLUDEDIR VIRA_INSTALL_LIBDIR
84+
PATH_VARS VIRA_INSTALL_INCLUDEDIR VIRA_INSTALL_LIBDIR VIRA_INSTALL_CMAKEDIR
8585
)
8686

8787
write_basic_package_version_file(
88-
"${CMAKE_CURRENT_BINARY_DIR}/ViraConfigVersion.cmake"
88+
"${CMAKE_CURRENT_BINARY_DIR}/viraConfigVersion.cmake"
8989
VERSION ${PROJECT_VERSION}
9090
COMPATIBILITY SameMajorVersion
9191
)
9292

9393
# Install CMake config files
9494
install(FILES
95-
"${CMAKE_CURRENT_BINARY_DIR}/ViraConfig.cmake"
96-
"${CMAKE_CURRENT_BINARY_DIR}/ViraConfigVersion.cmake"
95+
"${CMAKE_CURRENT_BINARY_DIR}/viraConfig.cmake"
96+
"${CMAKE_CURRENT_BINARY_DIR}/viraConfigVersion.cmake"
9797
DESTINATION ${VIRA_INSTALL_CMAKEDIR}
9898
)
9999

@@ -102,6 +102,10 @@ install(FILES
102102
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/helpers/SimplePackageHelpers.cmake"
103103
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/helpers/MarkSystemLibrary.cmake"
104104
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/find/ViraFindProjDB.cmake"
105+
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/fetch/ViraFetchIndicators.cmake"
106+
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/fetch/ViraFetchPlog.cmake"
107+
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/fetch/ViraFetchTermcolor.cmake"
108+
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/fetch/ViraFetchCSPICE.cmake"
105109
DESTINATION ${VIRA_INSTALL_CMAKEDIR}
106110
)
107111

README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,8 @@ This project provides a library which can be used for building new projects, as
66

77
**Supported Platforms:** Linux, macOS (ARM), Windows
88

9-
*NOTE:* `main` reflects the latest stable development state; `develop` contains active feature work.
10-
11-
12-
| | Build | Coverage |
13-
|---|---|---|
14-
| **main** | [![Build](https://github.com/crgnam/vira/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/crgnam/vira/actions/workflows/build.yml?query=branch%3Amain) | [![Coverage](https://codecov.io/gh/crgnam/vira/branch/main/graph/badge.svg)](https://app.codecov.io/gh/crgnam/vira/tree/main) |
15-
| **develop** | [![Build](https://github.com/crgnam/vira/actions/workflows/build.yml/badge.svg?branch=develop)](https://github.com/crgnam/vira/actions/workflows/build.yml?query=branch%3Adevelop) | [![Coverage](https://codecov.io/gh/crgnam/vira/branch/develop/graph/badge.svg)](https://app.codecov.io/gh/crgnam/vira/tree/develop) |
9+
[![CI/CD Pipeline](https://github.com/crgnam/vira/actions/workflows/ci-cd.yml/badge.svg?branch=main)](https://github.com/crgnam/vira/actions/workflows/ci-cd.yml?query=branch%3Amain)
10+
[![Coverage](https://codecov.io/gh/crgnam/vira/branch/main/graph/badge.svg)](https://app.codecov.io/gh/crgnam/vira/tree/main)
1611

1712
***
1813

cmake/fetch/ViraFetchSTB.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ if(used_fetchcontent)
5454
message(STATUS "STB Used FetchContent: ${stb_SOURCE_DIR}")
5555

5656
install(DIRECTORY "${stb_SOURCE_DIR}/"
57-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/stb
57+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
5858
FILES_MATCHING PATTERN "*.h"
5959
)
6060
else()
Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ find_dependency(embree 3 CONFIG)
2121
find_dependency(glm CONFIG)
2222
find_dependency(TBB CONFIG)
2323

24+
# Use our fetch/find helpers for packages that need special handling
25+
include(ViraFetchIndicators)
26+
include(ViraFetchPlog)
27+
include(ViraFetchTermcolor)
28+
include(ViraFetchCSPICE)
29+
2430
# Handle CFITSIO
2531
set(cfitsio_FOUND FALSE)
2632
try_config_packages(cfitsio "unofficial-cfitsio;cfitsio" "cfitsio;CFITSIO::CFITSIO;cfitsio::cfitsio")
@@ -102,13 +108,21 @@ if(NOT yaml-cpp_FOUND)
102108
message(FATAL_ERROR "Could not find yaml-cpp")
103109
endif()
104110

111+
# Handle stb (header-only, installed with vira)
112+
if(NOT TARGET stb::stb)
113+
add_library(stb::stb INTERFACE IMPORTED)
114+
set_target_properties(stb::stb PROPERTIES
115+
INTERFACE_INCLUDE_DIRECTORIES "${VIRA_INCLUDE_DIR}"
116+
)
117+
endif()
118+
105119
# Restore deprecation warnings
106120
set(CMAKE_WARN_DEPRECATED ON CACHE BOOL "" FORCE)
107121

108122
# Include the target file
109-
include("${CMAKE_CURRENT_LIST_DIR}/ViraTargets.cmake")
123+
include("${CMAKE_CURRENT_LIST_DIR}/viraTargets.cmake")
110124

111125
# Set the main target
112126
set(VIRA_TARGETS vira::vira)
113127

114-
check_required_components(Vira)
128+
check_required_components(vira)

dependencies/recipe/bld.bat

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@
22

33
echo Building %PKG_NAME% version %PKG_VERSION%
44

5-
cmake -B build %CMAKE_ARGS%
5+
cmake -B build %CMAKE_ARGS% ^
6+
-DCMAKE_BUILD_TYPE=Release ^
7+
-DCMAKE_INSTALL_PREFIX="%LIBRARY_PREFIX%" ^
8+
-DCMAKE_PREFIX_PATH="%LIBRARY_PREFIX%" ^
9+
-DVIRA_BUILD_TOOLS=OFF ^
10+
-DVIRA_BUILD_EXAMPLES=OFF ^
11+
-DVIRA_BUILD_TESTS=OFF ^
12+
-DVIRA_BUILD_SCRATCH=OFF ^
13+
-DVIRA_BUILD_DOCS=OFF
614
if errorlevel 1 exit 1
715

816
cmake --build build --config Release --parallel %CPU_COUNT%

0 commit comments

Comments
 (0)