diff --git a/.github/workflows/reusable-cpp-coverage.yml b/.github/workflows/reusable-cpp-coverage.yml index 97efa72..a615055 100644 --- a/.github/workflows/reusable-cpp-coverage.yml +++ b/.github/workflows/reusable-cpp-coverage.yml @@ -10,10 +10,6 @@ name: 🇨 • Coverage on: workflow_call: inputs: - cmake-args: - description: "Additional arguments to pass to CMake" - default: "-G Ninja" - type: string setup-z3: description: "Whether to set up Z3" default: false @@ -90,24 +86,18 @@ jobs: - name: Install lit if: ${{ inputs.setup-mlir }} - run: uv pip install lit + run: | + uv pip install lit + echo "LIT_BIN=$(which lit)" >> $GITHUB_ENV - name: Configure CMake - env: - CMAKE_ARGS: ${{ inputs.cmake-args }} - SETUP_MLIR: ${{ inputs.setup-mlir }} - run: | - LIT_ARG="" - if [ "$SETUP_MLIR" = "true" ]; then - LIT_ARG="-DLLVM_EXTERNAL_LIT=$(which lit)" - fi - cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON $CMAKE_ARGS "$LIT_ARG" + run: cmake --preset coverage - name: Build - run: cmake --build build --config Debug + run: cmake --build --preset coverage - name: Test - run: ctest -C Debug --output-on-failure --test-dir build --repeat until-pass:3 --timeout 600 + run: ctest --preset coverage - name: Upload coverage to Codecov uses: codecov/codecov-action@57e3a136b779b570ffcdbf80b3bdc90e7fab3de2 # v6.0.0 diff --git a/.github/workflows/reusable-cpp-linter.yml b/.github/workflows/reusable-cpp-linter.yml index 3cea6b8..5e34de9 100644 --- a/.github/workflows/reusable-cpp-linter.yml +++ b/.github/workflows/reusable-cpp-linter.yml @@ -18,10 +18,6 @@ on: description: "Whether to only lint files that have changed" default: true type: boolean - cmake-args: - description: "Additional arguments to pass to CMake" - default: "" - type: string cpp-linter-extra-args: description: "Extra arguments to pass to the cpp-linter" default: "-std=c++17" @@ -158,22 +154,12 @@ jobs: uv pip install "${pkgs_array[@]}" fi - # generate a compilation database (assumes that the CMake project has `CMAKE_EXPORT_COMPILE_COMMANDS` set) - name: Generate compilation database - env: - CMAKE_ARGS: ${{ inputs.cmake-args }} - run: | - echo $CC - echo $CXX - $CC --version - $CXX --version - echo $MLIR_DIR - echo $LLVM_DIR - cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=Debug $CMAKE_ARGS + run: cmake --preset lint - name: Build if: ${{ inputs.build-project }} - run: cmake --build build --config Debug + run: cmake --build --preset lint # runs the cpp-linter action using the generated compilation database and the specified clang version - name: Run cpp-linter diff --git a/.github/workflows/reusable-cpp-tests-macos.yml b/.github/workflows/reusable-cpp-tests-macos.yml index 578c761..fc68736 100644 --- a/.github/workflows/reusable-cpp-tests-macos.yml +++ b/.github/workflows/reusable-cpp-tests-macos.yml @@ -16,12 +16,6 @@ on: This can be any valid macOS runner image, such as 'macos-15', 'macos-26', or 'macos-26-intel'. default: "macos-latest" type: string - config: - description: > - The build type to use. Defaults to 'Release'. - This can be any valid CMake build type, such as 'Debug' or 'Release'. - default: "Release" - type: string compiler: description: > The compiler to use. Defaults to 'clang'. @@ -31,12 +25,6 @@ on: A specific version of Clang can be requested via 'clang-XX', where XX is the version number (e.g., 'clang-20'). default: "clang" type: string - cmake-args: - description: > - Additional arguments to pass to CMake. Defaults to an empty string. - This can be any valid CMake argument, such as '-DBUILD_SHARED_LIBS=ON'. - default: "" - type: string setup-z3: description: "Whether to set up Z3" default: false @@ -53,9 +41,13 @@ on: description: "The LLVM version to set up (formatted as 'major.minor.patch') or commit hash (minimum 7 characters, e.g., 'a832a52')" default: "21.1.8" type: string + preset-name: + description: "The CMake preset to use for configuration and build" + required: true + type: string concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}-cpp-tests-${{ inputs.runs-on }}-${{ inputs.compiler }}-${{ inputs.config }} + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}-cpp-tests-${{ inputs.runs-on }}-${{ inputs.compiler }}-${{ inputs.preset-name }} cancel-in-progress: true permissions: @@ -63,7 +55,7 @@ permissions: jobs: cpp-tests-macos: - name: 🍎 ${{ inputs.runs-on }} ${{ inputs.compiler }} ${{ inputs.config }} + name: 🍎 ${{ inputs.runs-on }} ${{ inputs.compiler }} ${{ inputs.preset-name }} runs-on: ${{ inputs.runs-on }} env: CMAKE_BUILD_PARALLEL_LEVEL: 4 @@ -100,7 +92,9 @@ jobs: - name: Install lit if: ${{ inputs.setup-mlir }} - run: uv pip install lit + run: | + uv pip install lit + echo "LIT_BIN=$(which lit)" >> $GITHUB_ENV - name: Set up GCC if: ${{ startsWith(inputs.compiler, 'gcc-') }} @@ -141,22 +135,15 @@ jobs: - name: Configure CMake env: - CONFIG: ${{ inputs.config }} - CMAKE_ARGS: ${{ inputs.cmake-args }} - SETUP_MLIR: ${{ inputs.setup-mlir }} - run: | - LIT_ARG="" - if [ "$SETUP_MLIR" = "true" ]; then - LIT_ARG="-DLLVM_EXTERNAL_LIT=$(which lit)" - fi - cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=$CONFIG $CMAKE_ARGS "$LIT_ARG" + PRESET_NAME: ${{ inputs.preset-name }} + run: cmake --preset "$PRESET_NAME" - name: Build env: - CONFIG: ${{ inputs.config }} - run: cmake --build build --config $CONFIG + PRESET_NAME: ${{ inputs.preset-name }} + run: cmake --build --preset "$PRESET_NAME" - name: Test env: - CONFIG: ${{ inputs.config }} - run: ctest -C $CONFIG --output-on-failure --test-dir build --repeat until-pass:3 --timeout 600 + PRESET_NAME: ${{ inputs.preset-name }} + run: ctest --preset "$PRESET_NAME" diff --git a/.github/workflows/reusable-cpp-tests-ubuntu.yml b/.github/workflows/reusable-cpp-tests-ubuntu.yml index 2d8d471..89271b9 100644 --- a/.github/workflows/reusable-cpp-tests-ubuntu.yml +++ b/.github/workflows/reusable-cpp-tests-ubuntu.yml @@ -16,12 +16,6 @@ on: This can be any valid Ubuntu runner image, such as 'ubuntu-24.04' or its ARM variant 'ubuntu-24.04-arm'. default: "ubuntu-24.04" type: string - config: - description: > - The build type to use. Defaults to 'Release'. - This can be any valid CMake build type, such as 'Debug' or 'Release'. - default: "Release" - type: string compiler: description: > The compiler to use. Defaults to 'gcc'. @@ -31,12 +25,6 @@ on: A specific version of Clang can be requested via 'clang-XX', where XX is the version number (e.g., 'clang-20'). default: "gcc" type: string - cmake-args: - description: > - Additional arguments to pass to CMake. Defaults to an empty string. - This can be any valid CMake argument, such as '-DBUILD_SHARED_LIBS=ON'. - default: "" - type: string setup-z3: description: "Whether to set up Z3" default: false @@ -53,9 +41,13 @@ on: description: "The LLVM version to set up (formatted as 'major.minor.patch') or commit hash (minimum 7 characters, e.g., 'a832a52')" default: "21.1.8" type: string + preset-name: + description: "The CMake preset to use for configuration and build" + required: true + type: string concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}-cpp-tests-${{ inputs.runs-on }}-${{ inputs.compiler }}-${{ inputs.config }} + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}-cpp-tests-${{ inputs.runs-on }}-${{ inputs.compiler }}-${{ inputs.preset-name }} cancel-in-progress: true permissions: @@ -63,7 +55,7 @@ permissions: jobs: cpp-tests-ubuntu: - name: 🐧 ${{ inputs.runs-on }} ${{ inputs.compiler }} ${{ inputs.config }} + name: 🐧 ${{ inputs.runs-on }} ${{ inputs.compiler }} ${{ inputs.preset-name }} runs-on: ${{ inputs.runs-on }} env: CMAKE_BUILD_PARALLEL_LEVEL: 4 @@ -103,7 +95,9 @@ jobs: - name: Install lit if: ${{ inputs.setup-mlir }} - run: uv pip install lit + run: | + uv pip install lit + echo "LIT_BIN=$(which lit)" >> $GITHUB_ENV - name: Set up default Clang if: ${{ inputs.compiler == 'clang' }} @@ -141,22 +135,15 @@ jobs: - name: Configure CMake env: - CONFIG: ${{ inputs.config }} - CMAKE_ARGS: ${{ inputs.cmake-args }} - SETUP_MLIR: ${{ inputs.setup-mlir }} - run: | - LIT_ARG="" - if [ "$SETUP_MLIR" = "true" ]; then - LIT_ARG="-DLLVM_EXTERNAL_LIT=$(which lit)" - fi - cmake -G Ninja -S . -B build -DCMAKE_BUILD_TYPE=$CONFIG $CMAKE_ARGS "$LIT_ARG" + PRESET_NAME: ${{ inputs.preset-name }} + run: cmake --preset "$PRESET_NAME" - name: Build env: - CONFIG: ${{ inputs.config }} - run: cmake --build build --config $CONFIG + PRESET_NAME: ${{ inputs.preset-name }} + run: cmake --build --preset "$PRESET_NAME" - name: Test env: - CONFIG: ${{ inputs.config }} - run: ctest -C $CONFIG --output-on-failure --test-dir build --repeat until-pass:3 --timeout 600 + PRESET_NAME: ${{ inputs.preset-name }} + run: ctest --preset "$PRESET_NAME" diff --git a/.github/workflows/reusable-cpp-tests-windows.yml b/.github/workflows/reusable-cpp-tests-windows.yml index f4cf7e9..5ae2b69 100644 --- a/.github/workflows/reusable-cpp-tests-windows.yml +++ b/.github/workflows/reusable-cpp-tests-windows.yml @@ -16,12 +16,6 @@ on: This can be any valid Windows runner image, such as 'windows-2022' or 'windows-2025'. default: "windows-latest" type: string - config: - description: > - The build type to use. Defaults to 'Release'. - This can be any valid CMake build type, such as 'Debug' or 'Release'. - default: "Release" - type: string compiler: description: > The compiler to use. Defaults to 'msvc'. @@ -29,12 +23,6 @@ on: If 'clang' is selected, '-T ClangCL' is automatically added to the CMake arguments. default: "msvc" type: string - cmake-args: - description: > - Additional arguments to pass to CMake. Defaults to an empty string. - This can be any valid CMake argument, such as '-DBUILD_SHARED_LIBS=ON'. - default: "" - type: string setup-z3: description: "Whether to set up Z3" default: false @@ -51,9 +39,17 @@ on: description: "The LLVM version to set up (formatted as 'major.minor.patch') or commit hash (minimum 7 characters, e.g., 'a832a52')" default: "21.1.8" type: string + mlir-debug: + description: "Whether to use a debug build of MLIR" + default: false + type: boolean + preset-name: + description: "The CMake preset to use for configuration and build" + required: true + type: string concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}-cpp-tests-${{ inputs.runs-on }}-${{ inputs.compiler }}-${{ inputs.config }} + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}-cpp-tests-${{ inputs.runs-on }}-${{ inputs.compiler }}-${{ inputs.preset-name }} cancel-in-progress: true permissions: @@ -65,7 +61,7 @@ defaults: jobs: cpp-tests-windows: - name: 🏁 ${{ inputs.runs-on }} ${{ inputs.compiler }} ${{ inputs.config }} + name: 🏁 ${{ inputs.runs-on }} ${{ inputs.compiler }} ${{ inputs.preset-name }} runs-on: ${{ inputs.runs-on }} env: CMAKE_BUILD_PARALLEL_LEVEL: 4 @@ -89,7 +85,7 @@ jobs: uses: munich-quantum-software/setup-mlir@883c1e05e60abbc215e967cde7d3ca7fde378e8d # v1.3.1 with: llvm-version: ${{ inputs.llvm-version }} - debug: ${{ inputs.config == 'Debug' }} + debug: ${{ inputs.mlir-debug }} - name: Install the latest version of uv uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 @@ -100,28 +96,22 @@ jobs: - name: Install lit if: ${{ inputs.setup-mlir }} - run: uv pip install lit + run: | + uv pip install lit + echo "LIT_BIN=$GITHUB_WORKSPACE/.venv/Scripts/lit.exe" >> $GITHUB_ENV - name: Configure CMake env: - CONFIG: ${{ inputs.config }} - CMAKE_ARGS: ${{ inputs.cmake-args }} - COMPILER: ${{ inputs.compiler }} - LIT_ARG: ${{ inputs.setup-mlir && format('-DLLVM_EXTERNAL_LIT={0}/.venv/Scripts/lit.exe', github.workspace) || '' }} - run: | - cmake_args=$CMAKE_ARGS - if [ "$COMPILER" == "clang" ]; then - cmake_args="$cmake_args -T ClangCL" - fi - cmake -S . -B build -DCMAKE_BUILD_TYPE=$CONFIG $cmake_args $LIT_ARG + PRESET_NAME: ${{ inputs.preset-name }} + run: cmake --preset "$PRESET_NAME" - name: Build timeout-minutes: 60 env: - CONFIG: ${{ inputs.config }} - run: cmake --build build --config $CONFIG + PRESET_NAME: ${{ inputs.preset-name }} + run: cmake --build --preset "$PRESET_NAME" - name: Test env: - CONFIG: ${{ inputs.config }} - run: ctest -C $CONFIG --output-on-failure --test-dir build --repeat until-pass:3 --timeout 600 + PRESET_NAME: ${{ inputs.preset-name }} + run: ctest --preset "$PRESET_NAME" diff --git a/CHANGELOG.md b/CHANGELOG.md index 9edcd4a..f5704ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,15 @@ This project adheres to [Semantic Versioning], with the exception that minor rel ## [Unreleased] +## [2.0.0] - 2026-05-22 + +_If you are upgrading: please see [`UPGRADING.md`](UPGRADING.md#200)._ + +### Changed + +- 🚸 Adapt C++ workflows to require [CMake presets] ([#363]) ([**@denialhaag**]) +- ♻️ Add `mlir-debug` flag to the `reusable-cpp-tests-windows` workflow for requesting a debug build of MLIR ([#363]) ([**@denialhaag**]) + ## [1.18.1] - 2026-04-09 _If you are upgrading: please see [`UPGRADING.md`](UPGRADING.md#1181)._ @@ -303,7 +312,8 @@ _📚 Refer to the [GitHub Release Notes] for previous changelogs._ -[unreleased]: https://github.com/munich-quantum-toolkit/workflows/compare/v1.18.1...HEAD +[unreleased]: https://github.com/munich-quantum-toolkit/workflows/compare/v2.0.0...HEAD +[2.0.0]: https://github.com/munich-quantum-toolkit/workflows/releases/tag/v2.0.0 [1.18.1]: https://github.com/munich-quantum-toolkit/workflows/releases/tag/v1.18.1 [1.18.0]: https://github.com/munich-quantum-toolkit/workflows/releases/tag/v1.18.0 [1.17.15]: https://github.com/munich-quantum-toolkit/workflows/releases/tag/v1.17.15 @@ -337,6 +347,7 @@ _📚 Refer to the [GitHub Release Notes] for previous changelogs._ +[#363]: https://github.com/munich-quantum-toolkit/workflows/pull/363 [#356]: https://github.com/munich-quantum-toolkit/workflows/pull/356 [#344]: https://github.com/munich-quantum-toolkit/workflows/pull/344 [#343]: https://github.com/munich-quantum-toolkit/workflows/pull/343 @@ -397,3 +408,4 @@ _📚 Refer to the [GitHub Release Notes] for previous changelogs._ [Semantic Versioning]: https://semver.org/spec/v2.0.0.html [GitHub Release Notes]: https://github.com/munich-quantum-toolkit/workflows/releases [munich-quantum-software/setup-mlir]: https://github.com/munich-quantum-software/setup-mlir +[CMake presets]: https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html diff --git a/UPGRADING.md b/UPGRADING.md index 894123c..a700863 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -4,6 +4,171 @@ This document describes breaking changes and how to upgrade. For a complete list ## [Unreleased] +## [2.0.0] + +This release adapts all C++ workflows to require [CMake presets], providing a standardized and reproducible way to configure builds across different platforms while eliminating scattered configuration with string-based arguments. + +The testing workflows for macOS, Ubuntu, and Windows (`reusable-cpp-tests-macos.yml`, `reusable-cpp-tests-ubuntu.yml`, and `reusable-cpp-tests-windows.yml`) now require a `preset-name` input and no longer accept `cmake-args` or `config` inputs. +On Windows, the new `mlir-debug` flag can be used for debug MLIR builds. + +The coverage and linter workflows (`reusable-cpp-coverage.yml` and `reusable-cpp-linter.yml`) require `coverage` and `lint` presets, respectively, and no longer accept `cmake-args`. + +An exemplary `CMakePresets.json` can be found below. + +```json +{ + "version": 3, + "configurePresets": [ + { + "name": "base", + "hidden": true, + "binaryDir": "${sourceDir}/build/${presetName}", + "cacheVariables": { + "MLIR_DIR": "$env{MLIR_DIR}" + } + }, + { + "name": "base-unix", + "hidden": true, + "inherits": "base", + "condition": { + "type": "inList", + "string": "${hostSystemName}", + "list": ["Linux", "Darwin"] + }, + "description": "Default configuration for Linux and macOS builds. Uses the Ninja generator", + "generator": "Ninja" + }, + { + "name": "base-windows", + "hidden": true, + "inherits": "base", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + }, + "description": "Default configuration for Windows builds. Uses the default generator" + }, + { + "name": "debug", + "inherits": "base-unix", + "displayName": "Debug config", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "LLVM_ENABLE_ASSERTIONS": "ON" + } + }, + { + "name": "release", + "inherits": "base-unix", + "displayName": "Release config", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "coverage", + "inherits": "base-unix", + "displayName": "Coverage config", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "ENABLE_COVERAGE": "ON" + } + }, + { + "name": "lint", + "inherits": "base-unix", + "displayName": "Lint config", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "BUILD_MQT_CORE_BENCHMARKS": "ON", + "BUILD_MQT_CORE_BINDINGS": "ON" + } + }, + { + "name": "debug-windows", + "inherits": "base-windows", + "displayName": "Windows Debug config", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "LLVM_ENABLE_ASSERTIONS": "ON" + } + }, + { + "name": "release-windows", + "inherits": "base-windows", + "displayName": "Windows Release config", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + } + ], + "buildPresets": [ + { + "name": "debug", + "configurePreset": "debug" + }, + { + "name": "release", + "configurePreset": "release" + }, + { + "name": "coverage", + "configurePreset": "coverage" + }, + { + "name": "lint", + "configurePreset": "lint" + }, + { + "name": "debug-windows", + "configurePreset": "debug-windows", + "configuration": "Debug" + }, + { + "name": "release-windows", + "configurePreset": "release-windows", + "configuration": "Release" + } + ], + "testPresets": [ + { + "name": "base", + "hidden": true, + "output": { "outputOnFailure": true } + }, + { + "name": "debug", + "inherits": "base", + "configurePreset": "debug" + }, + { + "name": "release", + "inherits": "base", + "configurePreset": "release" + }, + { + "name": "coverage", + "inherits": "base", + "configurePreset": "coverage" + }, + { + "name": "debug-windows", + "inherits": "base", + "configurePreset": "debug-windows", + "configuration": "Debug" + }, + { + "name": "release-windows", + "inherits": "base", + "configurePreset": "release-windows", + "configuration": "Release" + } + ] +} +``` + ## [1.18.1] To reduce complications when uploading artifacts during deployment to PyPI, we are reverting changes made in [1.17.15]. @@ -294,7 +459,8 @@ Consider removing any `-G Ninja` flags from your CMake invocations under Windows -[unreleased]: https://github.com/munich-quantum-toolkit/workflows/compare/v1.18.1...HEAD +[unreleased]: https://github.com/munich-quantum-toolkit/workflows/compare/v2.0.0...HEAD +[2.0.0]: https://github.com/munich-quantum-toolkit/workflows/compare/v1.18.1...v2.0.0 [1.18.1]: https://github.com/munich-quantum-toolkit/workflows/compare/v1.18.0...v1.18.1 [1.18.0]: https://github.com/munich-quantum-toolkit/workflows/compare/v1.17.15...v1.18.0 [1.17.15]: https://github.com/munich-quantum-toolkit/workflows/compare/v1.17.11...v1.17.15 @@ -319,3 +485,4 @@ Consider removing any `-G Ninja` flags from your CMake invocations under Windows [portable-mlir-toolchain]: https://github.com/munich-quantum-software/portable-mlir-toolchain [setup-mlir]: https://github.com/munich-quantum-software/setup-mlir [zizmor]: https://docs.zizmor.sh/ +[CMake presets]: https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html