Fix windows_bootstrap_context_spec flakiness on windows-2025 CI - #188
Merged
jaymzh merged 1 commit intoJul 15, 2026
Merged
Conversation
Stub ChefConfig::Config.etc_chef_dir and c_opscode_dir in the WindowsBootstrapContext spec to return deterministic path values (C:\chef and C:\opscode\chef) regardless of the platform. These class methods use ChefConfig::Config.windows_installation_drive which detects the drive letter at runtime from the gem installation path via File.expand_path(__FILE__). The memoized results persist as class-level instance variables (@etc_chef_dir) that are NOT cleared by Chef::Config.reset between tests. This caused intermittent failures on windows-2025 runners when the GitHub Actions runner image was updated (weekly cadence per https://github.com/actions/runner-images#image-releases), changing the system configuration in a way that affected path resolution. The tests passed on windows-2025 in PR #186 (run ~July 1) but began failing in PR #187 (run ~July 10) due to a runner image update in that interval. The windows-2022 runner was unaffected. Failing tests: - spec/unit/knife/core/windows_bootstrap_context_spec.rb:164 - spec/unit/knife/core/windows_bootstrap_context_spec.rb:192 - spec/unit/knife/core/windows_bootstrap_context_spec.rb:201 - spec/unit/knife/core/windows_bootstrap_context_spec.rb:212 - spec/unit/knife/core/windows_bootstrap_context_spec.rb:232 Reference: - #187 - https://github.com/actions/runner-images (weekly image updates) Signed-off-by: Sachin Jain <Sachin.jain@chef.io>
sanjain-progress
marked this pull request as draft
July 15, 2026 11:37
sanjain-progress
marked this pull request as ready for review
July 15, 2026 19:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes intermittent unit test failures in
windows_bootstrap_context_spec.rbon thewindows-2025GitHub Actions runner.Problem
The following tests fail on
windows-2025but pass on all other platforms (ubuntu, macos, windows-2022):spec/unit/knife/core/windows_bootstrap_context_spec.rb:164- config_content generates the config file dataspec/unit/knife/core/windows_bootstrap_context_spec.rb:192- start_chef returns expected string with default valuesspec/unit/knife/core/windows_bootstrap_context_spec.rb:201- start_chef returns expected string with license_idspec/unit/knife/core/windows_bootstrap_context_spec.rb:212- start_chef exclude license key when disable_license_activation is truespec/unit/knife/core/windows_bootstrap_context_spec.rb:232- start_chef with bootstrap_url and chef-iceRoot Cause
The tests hardcode expected paths like
C:\chefandC:\opscode\chef, but the source code resolves these dynamically viaChefConfig::Config.etc_chef_dir(windows: true)andChefConfig::Config.c_opscode_dir.These class methods use
windows_installation_drivewhich detects the drive letter at runtime from the gem installation path (File.expand_path(__FILE__).split("/", 2)[0]). The memoized result is stored as a class-level instance variable (@etc_chef_dir) that is NOT cleared byChef::Config.resetbetween tests.When the
windows-2025runner image was updated by GitHub (they deploy weekly updates to runner images), the system configuration changed in a way that affected path resolution, causing these tests to fail.Evidence
windows-2025in PR #186 (run ~July 1, 2026)windows-2025in PR #187 (run ~July 10, 2026)windows-2022runner is unaffected in both casesFix
Stub
ChefConfig::Config.etc_chef_dir(windows: true)andChefConfig::Config.c_opscode_dirin a top-levelbeforeblock to return deterministic values (C:\chefandC:\opscode\chef). This ensures the tests validate the logic of config generation and path construction, not the platform-specific drive letter detection.References