Skip to content

Activate clang format hook #2187

Activate clang format hook

Activate clang format hook #2187

Workflow file for this run

name: Windows
on:
workflow_dispatch:
pull_request:
push:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash -e -l {0}
jobs:
build:
runs-on: ${{ matrix.runs-on }}
name: ${{ matrix.toolchain.compiler }} / ${{ matrix.build-system.name }} / ${{ matrix.config.name }} / targets ${{ matrix.target-arch.name }} / date-polyfill ${{ matrix.toolchain.date-polyfill}}
strategy:
fail-fast: false
matrix:
runs-on: [windows-latest]
toolchain:
- {compiler: msvc, date-polyfill: 'ON', use-large-int-placeholders: 'ON'}
- {compiler: msvc, date-polyfill: 'OFF', use-large-int-placeholders: 'ON'}
- {compiler: clang, date-polyfill: 'ON', version: 18, use-large-int-placeholders: 'ON'}
- {compiler: clang, date-polyfill: 'OFF', version: 18, use-large-int-placeholders: 'ON'}
target-arch:
- {
name: "Win64",
vs-flags: "-A x64", # only used by VS generator
cl-flags: "/arch (x64)",
gnu-flags: "-m64",
msvc-dev-cmd: "win64"
}
- {
name: "Win32",
vs-flags: "-A Win32", # only used by VS generator
cl-flags: "/arch (x86)",
gnu-flags: "-m32",
msvc-dev-cmd: "win32"
}
config:
- {name: Debug}
- {name: Release}
build-system:
- {name: "Visual Studio 17 2022"}
- {name: "Ninja"}
steps:
- name: Setup MSVC (only for non-VS buildsystems)
if: matrix.toolchain.compiler == 'msvc' && !startsWith(matrix.build-system.name, 'Visual Studio')
uses: ilammy/msvc-dev-cmd@v1
with:
# Ninja will take cues of which target architecture to use from the (powershell)
# msvc environment so we need to setup everything at this level.
arch: ${{matrix.target-arch.msvc-dev-cmd}}
- name: Install LLVM and Clang
if: matrix.toolchain.compiler == 'clang'
uses: KyleMayes/install-llvm-action@v2
with:
version: ${{matrix.toolchain.version}}
arch: x64
- name: Setup clang
if: matrix.toolchain.compiler == 'clang'
run: |
echo "CC=clang" >> $GITHUB_ENV
echo "CXX=clang++" >> $GITHUB_ENV
- name: Setup gnu compilers
if: matrix.toolchain.compiler != 'msvc'
run: |
echo "CMAKE_CXX_FLAGS=${{matrix.target-arch.gnu-flags}}" >> $GITHUB_ENV
echo "CMAKE_CXX_LINK_FLAGS=${{matrix.target-arch.gnu-flags}}" >> $GITHUB_ENV
- name: Setup Ninja + msvc
if: matrix.toolchain.compiler == 'msvc' && matrix.build-system.name == 'Ninja'
run: |
echo "CMAKE_CXX_FLAGS=${{matrix.target-arch.cl-flags}}" >> $GITHUB_ENV
echo "CMAKE_CXX_LINK_FLAGS=${{matrix.target-arch.cl-flags}}" >> $GITHUB_ENV
- name: Setup Visual Studio
if: startsWith(matrix.build-system.name, 'Visual Studio')
run: |
echo "GENERATOR_EXTRA_FLAGS=${{matrix.target-arch.vs-flags}}" >> $GITHUB_ENV
- name: Setup toolset if we use Visual Studio Build System and Clang
if: startsWith(matrix.build-system.name, 'Visual Studio') && matrix.toolchain.compiler == 'clang'
run: |
echo "GENERATOR_EXTRA_FLAGS=${GENERATOR_EXTRA_FLAGS} -T ClangCL" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v4
- name: ccache
uses: hendrikmuhs/[email protected]
with:
key: ${{ matrix.toolchain.compiler }}_${{ matrix.build-system.name }}_${{ matrix.config.name }}_targets_${{ matrix.target-arch.name }}_date-polyfill_${{ matrix.toolchain.date-polyfill}}_ccache
- name: Setup vcpkg environment
if: matrix.target-arch.name == 'Win32'
run: |
vcpkg install --triplet=x86-windows
- name: Set conda environment
if: matrix.target-arch.name == 'Win64'
uses: mamba-org/setup-micromamba@main
with:
environment-name: myenv
environment-file: environment-dev.yml
init-shell: bash
cache-downloads: true
create-args: |
ninja
- name: Set dependencies install prefix dir for 64bit
if: matrix.target-arch.name == 'Win64'
run: |
echo "SPARROW_DEPS_PREFIX=$CONDA_PREFIX" >> $GITHUB_ENV
echo "SPARROW_INSTALL_PREFIX=$CONDA_PREFIX" >> $GITHUB_ENV
echo "SPARROW_ADDITIONAL_OPTIONS=-DSPARROW_TARGET_32BIT=OFF -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL" >> $GITHUB_ENV
- name: Set dependencies install prefix dir for 32bit
if: matrix.target-arch.name == 'Win32'
run: |
echo "SPARROW_DEPS_PREFIX=$VCPKG_INSTALLED_DIR" >> $GITHUB_ENV
echo "SPARROW_INSTALL_PREFIX=${{ github.workspace }}/install" >> $GITHUB_ENV
echo "VCPKG_TARGET_TRIPLET='x86-windows'" >> $GITHUB_ENV
echo "VCPKG_BUILD_TYPE='Release'" >> $GITHUB_ENV
echo "CMAKE_TOOLCHAIN_FILE=$VCPKG_INSTALLATION_ROOT/scripts/buildsystems/vcpkg.cmake" >> $GITHUB_ENV
echo "SPARROW_ADDITIONAL_OPTIONS=-DSPARROW_TARGET_32BIT=ON" >> $GITHUB_ENV
choco install ninja
- name: Enable runtime size/length/offset validity checks
if: matrix.config.name == 'Debug'
run: |
echo "SPARROW_CHECKS='$SPARROW_CHECKS -DSPARROW_ENABLE_SIZE_CHECKS=ON'" >> $GITHUB_ENV
- name: Enable runtime 32bit size/length/offset limit
if: matrix.target-arch.name == 'Win32' # Note: this is not a mandatory limitation in any context, we add this just to have at least one configuration testing that feature
run: echo "SPARROW_CHECKS='$SPARROW_CHECKS -DSPARROW_ENABLE_32BIT_SIZE_LIMIT=ON'" >> $GITHUB_ENV
- name: Enable tests coverage
if: matrix.config.name == 'Debug' && matrix.toolchain.compiler == 'msvc'
run: |
choco install opencppcoverage
echo "TEST_COVERAGE_ACTIVATION=' -DENABLE_COVERAGE=ON'" >> $GITHUB_ENV
- name: Set CMake generator environment variable
run: |
echo "CMAKE_GENERATOR=${{ matrix.build-system.name }}" >> $GITHUB_ENV
- name: Configure using CMake
run: |
cmake -S ./ -B ./build \
-DCMAKE_BUILD_TYPE:STRING=${{matrix.config.name}} \
-DCMAKE_PREFIX_PATH=$SPARROW_DEPS_PREFIX \
-DCMAKE_INSTALL_PREFIX=$SPARROW_INSTALL_PREFIX \
-DBUILD_TESTS=ON \
-DBUILD_EXAMPLES=ON \
-DUSE_LARGE_INT_PLACEHOLDERS=${{matrix.toolchain.use-large-int-placeholders}} \
-DUSE_DATE_POLYFILL=${{matrix.toolchain.date-polyfill}} \
$GENERATOR_EXTRA_FLAGS \
$SPARROW_CHECKS \
$SPARROW_ADDITIONAL_OPTIONS \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DFETCH_DEPENDENCIES_WITH_CMAKE=MISSING \
$TEST_COVERAGE_ACTIVATION
- name: Build library
working-directory: build
run: cmake --build . --config ${{matrix.config.name}} --target sparrow --parallel 8
- name: Install
working-directory: build
run: cmake --install . --config ${{matrix.config.name}}
- name: Build tests
working-directory: build
run: cmake --build . --config ${{matrix.config.name}} --target test_sparrow_lib --parallel 8
- name: Run tests
working-directory: build
run: cmake --build . --config ${{matrix.config.name}} --target run_tests_with_junit_report
- name: Upload test results
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: test_sparrow_lib_report_Windows_${{ matrix.toolchain.compiler }}_${{ matrix.build-system.name }}_${{ matrix.config.name }}_${{ matrix.target-arch.name }}_date-polyfill_${{ matrix.toolchain.date-polyfill}}
path: ./**/test*.xml
if-no-files-found: error
- name: Tests coverage
if: matrix.config.name == 'Debug' && matrix.toolchain.compiler == 'msvc'
working-directory: build
run: |
cmake --build . --config Debug --target generate_cobertura
- name: Upload coverage to Codecov
if: matrix.config.name == 'Debug' && matrix.toolchain.compiler == 'msvc'
env:
COMPILER: ${{ matrix.toolchain.compiler }}
BUILD_SYSTEM: ${{ matrix.build-system.name }}
CONFIG: ${{ matrix.config.name }}
TARGET_ARCH: ${{ matrix.target-arch.name }}
DATE_POLYFILL: ${{ matrix.toolchain.date-polyfill }}
uses: codecov/codecov-action@v5
with:
directory: ./build/coverage_reports/
fail_ci_if_error: true
files: ./cobertura.xml
env_vars: COMPILER,BUILD_SYSTEM,CONFIG,TARGET_ARCH,DATE_POLYFILL
flags: unittests
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
- name: Run all examples
working-directory: build
run: cmake --build . --config ${{matrix.config.name}} --target run_examples