-
Notifications
You must be signed in to change notification settings - Fork 460
Fix #11161 - GHA: Windows Server 2019 has been retired. Use 2022 #11162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Windows Server 2019 has been retired. The Windows Server 2019 image has been removed as of 2025-06-30. For more details, see actions/runner-images#12045
…fy when 7z.exe isn't found
| if msvc_version in ['16', '17', '18']: | ||
| if self.os == OS.Windows: | ||
| self.msvc_version = msvc_version | ||
| elif self.os == OS.Windows and self.os_version == '2022': | ||
| self.msvc_version = 17 | ||
| elif self.os == OS.Windows: | ||
| self.msvc_version = 16 | ||
| self.asset_pattern = this_config['asset_pattern'] | ||
| self.bitness = this_config['bitness'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here the GHA test step was passing --msvc 2022 for win64 for run_config_key. Given this code block, it was just ignored, and it was checking the CONFIGURATIONS, which listed "os_version" as "10" for "win64", so it'd pick Visual Studio 16 2019, which doesn't exist.
| from enum import IntEnum, StrEnum | ||
|
|
||
|
|
||
| class OS(StrEnum): | ||
| """Operating Systems.""" | ||
|
|
||
| Windows = "Windows" | ||
| Linux = "Linux" | ||
| Mac = "Mac" | ||
|
|
||
|
|
||
| class MSVC(IntEnum): | ||
| """Microsoft Visual Studio versions.""" | ||
|
|
||
| V16 = 16 | ||
| V17 = 17 | ||
| # V18 = 18 # Future version placeholder | ||
|
|
||
| def generator_name(self) -> str: | ||
| """Get the CMake generator name for the MSVC version.""" | ||
| return MSVC_GENERATOR_MAPPING[self] | ||
|
|
||
|
|
||
| # Alias mapping for common version names to MSVC enum, for argparse | ||
| MSVC_ALIAS_MAPPING = { | ||
| "2017": MSVC.V16, | ||
| "2022": MSVC.V17, | ||
| } | ||
|
|
||
| # Mapping from MSVC enum to CMake generator names | ||
| MSVC_GENERATOR_MAPPING = { | ||
| MSVC.V16: "Visual Studio 16 2019", | ||
| MSVC.V17: "Visual Studio 17 2022", | ||
| } | ||
|
|
||
|
|
||
| class Bitness(StrEnum): | ||
| X86 = "x86" | ||
| X64 = "x64" | ||
| ARM64 = "arm64" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello Enums.
| def handle_msvc_arg(arg: str) -> MSVC: | ||
| # Check for aliases first | ||
| if arg in MSVC_ALIAS_MAPPING: | ||
| return MSVC_ALIAS_MAPPING[arg] | ||
|
|
||
| try: | ||
| return MSVC(int(arg)) | ||
| except ValueError: | ||
| possible_values = list(map(str, MSVC)) | ||
| aliases = [f"{k} -> {v}" for k, v in MSVC_ALIAS_MAPPING.items()] | ||
| msg = f"Invalid MSVC version argument: '{arg}' (choose from {possible_values} or aliases {aliases})" | ||
| raise argparse.ArgumentTypeError(msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns the --msvc argument (str) into a MSVC enum instance.
I maintained the backward compat use of aliases, such as '2017' or '2022', but they map to one of MSVC.V16 or MSVC.V17
| if platform.system() == "Windows" and args.msvc is None: | ||
| parser.error("On Windows, the --msvc argument is required to specify the Visual Studio version.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm enforcing that the msvc argument is actually passed. Makes more sense instead of trying to default it for whatever reason.
| print(" ...Extraction Complete") | ||
| except CalledProcessError as e: | ||
| raise Exception("Extraction failed with this error: " + str(e)) | ||
| raise Exception(f"Extraction failed with this error: {e}\nCommand: {extract_command}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My local VM had 7zip installed, by it wasn't on PATH. Wasn't clear what was happening.
| if self.os == OS.Windows: | ||
| self.msvc_version = msvc_version | ||
| elif self.os == OS.Windows and self.os_version == '2022': | ||
| self.msvc_version = 17 | ||
| elif self.os == OS.Windows: | ||
| self.msvc_version = 16 | ||
| self.asset_pattern = this_config['asset_pattern'] | ||
| self.bitness = this_config['bitness'] | ||
| if not isinstance(self.msvc_version, MSVC): | ||
| raise ValueError("On Windows, an MSVC (Enum) version must be provided.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enforce having msvc_version as an Enum here.
| TestCAPIAccess(os=self.os, bitness=self.bitness, msvc_version=self.msvc_version).run( | ||
| install_path, | ||
| verbose, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The C API tests take their required params into their Ctor now. Instead of weirdly passing them via kwargs on the "run" method and assigning there
| if self.bitness == Bitness.X86: | ||
| print("Travis does not have a 32-bit Python package readily available, so not testing Python API") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That shoudn't be there nowadays FYI
| def __init__(self, os: OS, bitness: Bitness, msvc_version: Optional[MSVC] = None): | ||
| super().__init__() | ||
| self.os = None | ||
| self.bitness = None | ||
| self.source_file_name = 'func.cpp' | ||
| self.target_name = 'TestCAPIAccess' | ||
| self.msvc_version = None | ||
| self.os = os | ||
| self.bitness = bitness | ||
| self.msvc_version = msvc_version | ||
| self.source_file_name = "func.cpp" | ||
| self.target_name = "TestCAPIAccess" | ||
| if self.os == OS.Windows and self.msvc_version is None: | ||
| raise Exception("Must pass msvc_version if os is Windows") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like I said, they assigned in Ctor. And will throw if windows and no msvc_version, since it's required
| def make_build_dir_and_build(cmake_build_dir: str, verbose: bool, bitness: Bitness, msvc_version: MSVC): | ||
|
|
||
| os.makedirs(cmake_build_dir) | ||
| my_env = os.environ.copy() | ||
| if platform.system() == "Darwin": # my local comp didn't have cmake in path except in interact shells | ||
| my_env["PATH"] = "/usr/local/bin:" + my_env["PATH"] | ||
| command_line = ["cmake", ".."] | ||
| is_windows = platform.system() == "Windows" | ||
| if is_windows: | ||
| command_line.extend(["-G", msvc_version.generator_name(), "-A", bitness.value]) | ||
|
|
||
| try: | ||
| my_check_call(verbose, command_line, cwd=cmake_build_dir, env=my_env) | ||
| command_line = ['cmake', '--build', '.'] | ||
| if platform.system() == 'Windows': | ||
| command_line.extend(['--config', 'Release']) | ||
| except Exception as e: | ||
| print("C API Wrapper Configuration Failed!") | ||
| raise e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of things happening here:
- One: I try / catch only the check_call. I don't want to swallow other exception. And I clarify the print to let you know it's the CONFIGURATION that failed here (the build later)
- Two: The cmake Generator options are computed from the enums, less error prone.
- Three: I removed Visual Studio 15. It would have forced me to do more complicated things since it doesn't accept a "-A" argument, and it's too old
Myoldmopar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is all fine. The ' to " changes make it a little difficult to see the functional changes, so I appreciate you calling the changes out. This has been needed for a while. The 2022 change is great, and the package testing code was written way way back, so it definitely needed some love.
|
@jmarrec have you built a release from this branch? If not, I'll go ahead and kick one off to check out the release testing updates. |
|
Perfect, thank you! Let's get this merged now. |
Pull request overview
Description of the purpose of this PR
Pull Request Author
Reviewer