Skip to content

C++ CI Workflow with dependencies installed via conda #2844

C++ CI Workflow with dependencies installed via conda

C++ CI Workflow with dependencies installed via conda #2844

Workflow file for this run

name: C++ CI Workflow with dependencies installed via conda
on:
push:
pull_request:
workflow_dispatch:
schedule:
# * is a special character in YAML so you have to quote this string
# Execute a "nightly" build at 2 AM UTC
- cron: '0 2 * * *'
jobs:
build:
name: '[${{ matrix.os }}@${{ matrix.build_type }}@conda]'
runs-on: ${{ matrix.os }}
strategy:
matrix:
build_type: [Release]
os: [ubuntu-latest, windows-latest, macos-latest]
fail-fast: false
steps:
- uses: actions/checkout@v5
- uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Miniforge3
miniforge-version: latest
channel-priority: true
conda-remove-defaults: true
environment-file: ci_env.yml
- name: Setup compilation env variables (not Windows)
if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'macos')
shell: bash -l {0}
run: |
echo "CMAKE_INSTALL_PREFIX=${CONDA_PREFIX}" >> $GITHUB_ENV
- name: Setup compilation env variables (Windows)
if: contains(matrix.os, 'windows')
shell: cmd /C CALL {0}
run: |
REM ============================================================
REM Setup compilation environment variables for Windows builds
REM ============================================================
REM This is necessary to use Ninja in bash shells on Windows.
REM Enable delayed expansion so that variables inside echo commands
REM expand correctly at runtime (not at parse time).
REM This fixes the issue where %compiler_path% was empty when
REM writing to %GITHUB_ENV%.
setlocal enabledelayedexpansion
REM Construct the full path to the MSVC compiler (cl.exe).
REM %VCToolsInstallDir% is provided by the Visual Studio environment
REM and should already exist on the GitHub-hosted Windows runners.
set "compiler_path=%VCToolsInstallDir%bin\Hostx64\x64\cl.exe"
REM Convert backslashes to forward slashes so bash/CMake handle paths properly.
REM The 'set' with '!' ensures delayed expansion is applied correctly.
set "compiler_path_fwd=!compiler_path:\=/!"
REM Print out values for debugging (visible in workflow logs).
echo VCToolsInstallDir=%VCToolsInstallDir%
echo compiler_path=!compiler_path!
echo compiler_path_fwd=!compiler_path_fwd!
REM ============================================================
REM Append environment variables for subsequent steps
REM ============================================================
REM Quotes around "%GITHUB_ENV%" are essential because the path
REM can contain spaces (e.g. in C:\Users\runneradmin\AppData...).
REM Using !var! ensures correct runtime expansion.
>> "%GITHUB_ENV%" echo CC=!compiler_path_fwd!
>> "%GITHUB_ENV%" echo CXX=!compiler_path_fwd!
>> "%GITHUB_ENV%" echo CMAKE_INSTALL_PREFIX=%CONDA_PREFIX%\Library
REM Export VS and SDK environment
>> "%GITHUB_ENV%" echo VCToolsInstallDir=%VCToolsInstallDir%
>> "%GITHUB_ENV%" echo VCINSTALLDIR=%VCINSTALLDIR%
>> "%GITHUB_ENV%" echo VSINSTALLDIR=%VSINSTALLDIR%
>> "%GITHUB_ENV%" echo WindowsSdkDir=%WindowsSdkDir%
>> "%GITHUB_ENV%" echo WindowsSdkVersion=%WindowsSdkVersion%
>> "%GITHUB_ENV%" echo INCLUDE=%INCLUDE%
>> "%GITHUB_ENV%" echo LIB=%LIB%
>> "%GITHUB_ENV%" echo LIBPATH=%LIBPATH%
>> "%GITHUB_ENV%" echo PATH=%PATH%
- name: Print environment info
shell: bash -l {0}
run: |
env
conda list
- name: Configure
shell: bash -l {0}
run: |
mkdir -p build
cd build
cmake -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DBUILD_TESTING:BOOL=ON \
-DHUMANSTATEPROVIDER_ENABLE_VISUALIZER:BOOL=ON -DHUMANSTATEPROVIDER_ENABLE_LOGGER:BOOL=ON ..
- name: Build
shell: bash -l {0}
run: |
cd build
cmake --build . --config ${{ matrix.build_type }}
- name: Test
shell: bash -l {0}
run: |
cd build
ctest --output-on-failure -C ${{ matrix.build_type }} .
- name: Install
shell: bash -l {0}
run: |
cd build
cmake --install . --config ${{ matrix.build_type }}
- name: Check install
shell: bash -l {0}
run: |
# Test CMake packages
cmake-package-check IWear --targets IWear::IWear