From 69aadde85c22eed79e69e8323c2634ca4c944505 Mon Sep 17 00:00:00 2001 From: JCW Date: Thu, 11 Jun 2026 13:29:53 +0100 Subject: [PATCH] Update ci pipeline to allow switching between msvc versions --- .github/actions/build-deps/action.yml | 10 ++++++ .github/scripts/strategy-matrix/generate.py | 33 +++++++++++++++++-- .github/scripts/strategy-matrix/windows.json | 14 +++++++- .../workflows/reusable-build-test-config.yml | 15 ++++++++- .github/workflows/reusable-build-test.yml | 2 ++ .github/workflows/upload-conan-deps.yml | 1 + 6 files changed, 71 insertions(+), 4 deletions(-) diff --git a/.github/actions/build-deps/action.yml b/.github/actions/build-deps/action.yml index 044c264ef0..585d24692a 100644 --- a/.github/actions/build-deps/action.yml +++ b/.github/actions/build-deps/action.yml @@ -22,6 +22,10 @@ inputs: description: "The sanitizers to enable." required: false default: "" + compiler_version: + description: "Override the Conan compiler.version (e.g. msvc '194' or '195'). Leave empty to auto-detect." + required: false + default: "" runs: using: composite @@ -34,9 +38,15 @@ runs: BUILD_TYPE: ${{ inputs.build_type }} LOG_VERBOSITY: ${{ inputs.log_verbosity }} SANITIZERS: ${{ inputs.sanitizers }} + COMPILER_VERSION: ${{ inputs.compiler_version }} run: | + COMPILER_VERSION_SETTING=() + if [ -n "${COMPILER_VERSION}" ]; then + COMPILER_VERSION_SETTING=(--settings:all compiler.version="${COMPILER_VERSION}") + fi conan install \ --profile:all ci \ + "${COMPILER_VERSION_SETTING[@]}" \ --build="${BUILD_OPTION}" \ --options:host='&:tests=True' \ --options:host='&:xrpld=True' \ diff --git a/.github/scripts/strategy-matrix/generate.py b/.github/scripts/strategy-matrix/generate.py index 6353567f27..0afe9d90e5 100755 --- a/.github/scripts/strategy-matrix/generate.py +++ b/.github/scripts/strategy-matrix/generate.py @@ -102,6 +102,20 @@ class PlatformConfig: self.build_type = [self.build_type] +@dataclasses.dataclass +class Toolset: + """One entry in windows.json's 'toolsets' array (Windows only). + + Each toolset selects a Visual Studio version: the CMake generator drives + the configure step, and compiler_version pins the matching Conan msvc + toolset so dependencies are built against the same compiler. + """ + + name: str # short config-name suffix, e.g. "vs2022" + generator: str # CMake generator, e.g. "Visual Studio 17 2022" + compiler_version: str = "" # Conan msvc compiler.version, e.g. "194" + + @dataclasses.dataclass class PlatformFile: """Shape of macos.json and windows.json.""" @@ -109,6 +123,7 @@ class PlatformFile: platform: str # e.g. "macos/arm64" or "windows/amd64" runner: list[str] # GitHub Actions runner labels configs: list[PlatformConfig] + toolsets: list[Toolset] = dataclasses.field(default_factory=list) @classmethod def load(cls, path: Path) -> "PlatformFile": @@ -117,6 +132,7 @@ class PlatformFile: platform=data["platform"], runner=data["runner"], configs=[PlatformConfig(**c) for c in data["configs"]], + toolsets=[Toolset(**t) for t in data.get("toolsets", [])], ) @@ -144,6 +160,8 @@ class MatrixEntry: sanitizers: str image: str = "" # container image; empty for macOS/Windows (runs natively) compiler: str = "" # compiler name ("gcc" or "clang"); empty for macOS/Windows + generator: str = "" # CMake generator; empty selects Ninja (Linux/macOS) + compiler_version: str = "" # Conan msvc compiler.version; empty auto-detects @dataclasses.dataclass @@ -248,24 +266,35 @@ def expand_platform_matrix( """Expand a PlatformFile (macOS or Windows) into matrix entries. Configs that exclude the current event are skipped. + + + When toolsets are defined (Windows), the configs are expanded over the + cross-product with the toolsets so each config is built against every + Visual Studio version. Platforms without toolsets (macOS) use a single + implicit toolset with no generator override (the build defaults to Ninja). """ platform_name, arch = pf.platform.split("/") is_windows = platform_name == "windows" + toolsets = pf.toolsets or [Toolset(name="", generator="", compiler_version="")] + entries: list[MatrixEntry] = [] - for cfg in pf.configs: + for toolset, cfg in itertools.product(toolsets, pf.configs): if not runs_on_event(cfg.exclude_event_types, event): continue for build_type in cfg.build_type: + name_parts = [platform_name, arch, toolset.name, build_type.lower()] entries.append( MatrixEntry( - config_name=f"{platform_name}-{arch}-{build_type.lower()}", + config_name="-".join(p for p in name_parts if p), cmake_args=get_cmake_args(build_type, cfg.extra_cmake_args), cmake_target="install" if is_windows else "all", build_only=cfg.build_only, build_type=build_type, architecture=Architecture(platform=pf.platform, runner=pf.runner), sanitizers="", + generator=toolset.generator, + compiler_version=toolset.compiler_version, ) ) return entries diff --git a/.github/scripts/strategy-matrix/windows.json b/.github/scripts/strategy-matrix/windows.json index e25f9ad131..edef239123 100644 --- a/.github/scripts/strategy-matrix/windows.json +++ b/.github/scripts/strategy-matrix/windows.json @@ -1,6 +1,18 @@ { "platform": "windows/amd64", - "runner": ["self-hosted", "Windows", "devbox"], + "runner": ["self-hosted", "Windows", "devbox-jcw-test"], + "toolsets": [ + { + "name": "vs2022", + "generator": "Visual Studio 17 2022", + "compiler_version": "194" + }, + { + "name": "vs2026", + "generator": "Visual Studio 18 2026", + "compiler_version": "195" + } + ], "configs": [ { "build_type": "Release" }, { diff --git a/.github/workflows/reusable-build-test-config.yml b/.github/workflows/reusable-build-test-config.yml index 8cb5f8c46a..fb26ba933b 100644 --- a/.github/workflows/reusable-build-test-config.yml +++ b/.github/workflows/reusable-build-test-config.yml @@ -63,6 +63,18 @@ on: type: string default: "" + generator: + description: "The CMake generator to use. Leave empty to use Ninja (Linux/macOS)." + required: false + type: string + default: "" + + compiler_version: + description: "Override the Conan compiler.version (Windows Visual Studio toolset). Leave empty to auto-detect." + required: false + type: string + default: "" + secrets: CODECOV_TOKEN: description: "The Codecov token to use for uploading coverage reports." @@ -150,6 +162,7 @@ jobs: # amount of logs. For other OSes, the "verbose" logs are more useful. log_verbosity: ${{ runner.os == 'Windows' && 'quiet' || 'verbose' }} sanitizers: ${{ inputs.sanitizers }} + compiler_version: ${{ inputs.compiler_version }} - name: Configure CMake working-directory: ${{ env.BUILD_DIR }} @@ -158,7 +171,7 @@ jobs: CMAKE_ARGS: ${{ inputs.cmake_args }} run: | cmake \ - -G '${{ runner.os == 'Windows' && 'Visual Studio 17 2022' || 'Ninja' }}' \ + -G '${{ inputs.generator != '' && inputs.generator || 'Ninja' }}' \ -DCMAKE_TOOLCHAIN_FILE:FILEPATH=build/generators/conan_toolchain.cmake \ -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" \ ${CMAKE_ARGS} \ diff --git a/.github/workflows/reusable-build-test.yml b/.github/workflows/reusable-build-test.yml index 4b64c53521..a29a307e3b 100644 --- a/.github/workflows/reusable-build-test.yml +++ b/.github/workflows/reusable-build-test.yml @@ -50,5 +50,7 @@ jobs: config_name: ${{ matrix.config_name }} sanitizers: ${{ matrix.sanitizers }} compiler: ${{ matrix.compiler || '' }} + generator: ${{ matrix.generator || '' }} + compiler_version: ${{ matrix.compiler_version || '' }} secrets: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/upload-conan-deps.yml b/.github/workflows/upload-conan-deps.yml index 7ca9d13007..d9fa195a7e 100644 --- a/.github/workflows/upload-conan-deps.yml +++ b/.github/workflows/upload-conan-deps.yml @@ -105,6 +105,7 @@ jobs: # amount of logs. For other OSes, the "verbose" logs are more useful. log_verbosity: ${{ runner.os == 'Windows' && 'quiet' || 'verbose' }} sanitizers: ${{ matrix.sanitizers }} + compiler_version: ${{ matrix.compiler_version || '' }} - name: Log into Conan remote if: ${{ github.repository == 'XRPLF/rippled' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }}