Skip to content

Define and use HLKPlatform sorbet type #972

Merged
kostyanf14 merged 5 commits into
HCK-CI:masterfrom
kostyanf14:platform-type
May 29, 2026
Merged

Define and use HLKPlatform sorbet type #972
kostyanf14 merged 5 commits into
HCK-CI:masterfrom
kostyanf14:platform-type

Conversation

@kostyanf14
Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings May 25, 2026 16:09
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the platform configuration logic by replacing hash-based data access with Sorbet-typed models, specifically introducing HLKPlatform, HLKClient, and HLKPlatformClientsOptions. The changes span several modules, including hckinstall, hcktest, and the qemuhck setup manager, updating them to use method calls and adding type signatures. Feedback from the review identifies several high-severity issues in the new models: the merge! method in HLKPlatformClientsOptions uses incorrect logic for booleans and default values while violating Sorbet's immutability for const fields. Furthermore, the use of the unsupported factory: keyword in T::Struct was flagged as a likely cause for runtime errors.

Comment thread lib/models/hlk_platform.rb Outdated
Comment thread lib/models/hlk_platform.rb
Comment thread lib/models/hlk_platform.rb Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a Sorbet-typed Models::HLKPlatform (and related structs) and migrates platform access from hash-style (['key']/dig) to typed attribute access across engines/setup managers, aiming to make platform configuration safer and more consistent.

Changes:

  • Add Models::HLKPlatform, Models::HLKClient, and Models::HLKPlatformClientsOptions as Sorbet T::Structs.
  • Update hcktest, hckinstall, qemuhck, and ancillary code to use typed accessors instead of JSON hashes.
  • Extend the JSON-load spec to validate platform JSON files against the new type.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
spec/srb_json_load_spec.rb Adds HLK platform JSON glob to Sorbet JSON-load coverage.
lib/models/hlk_platform.rb Introduces new Sorbet structs for platform/client/options plus validation.
lib/models.rb Registers new model autoloads for HLK platform types.
lib/models/svvp_config.rb Switches SVVP clients_options type to the shared HLK platform clients options struct.
lib/engines/hcktest/hcktest.rb Loads platform as Models::HLKPlatform and updates platform/client option access.
lib/engines/hcktest/tools.rb Updates client address extraction to use typed client attributes.
lib/engines/hckinstall/hckinstall.rb Updates install flow to use typed platform attributes (kit/clients/iso selection).
lib/setupmanagers/qemuhck/qemuhck.rb Migrates QemuHCK to typed platform access and adds Sorbet signatures.
lib/project.rb Types @engine_platform as T.nilable(Models::HLKPlatform) and updates usage.
lib/junit.rb Updates platform name extraction to typed access (.name).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/setupmanagers/qemuhck/qemuhck.rb
Comment thread lib/setupmanagers/qemuhck/qemuhck.rb
Comment thread lib/project.rb
Comment thread lib/engines/hckinstall/hckinstall.rb
Comment thread lib/models/hlk_platform.rb Outdated
Comment thread lib/models/hlk_platform.rb
Comment thread lib/models/hlk_platform.rb
Comment thread lib/models/hlk_platform.rb Outdated
Comment thread lib/models.rb
@kostyanf14 kostyanf14 force-pushed the platform-type branch 2 times, most recently from 0e41534 to bc0dcc1 Compare May 25, 2026 16:21
@kostyanf14
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request transitions the configuration handling from generic hashes to formal Sorbet models (HLKPlatform, HLKClient, and HLKPlatformClientsOptions), updating the install and test engines to utilize these typed structures. While this improves type safety, the review identifies critical bugs in the HLKPlatformClientsOptions#merge! implementation, specifically regarding the mutation of immutable const fields, the use of non-standard methods like .present?, and logic errors that prevent the correct merging of boolean values. A minor refactoring to remove a redundant variable in hckinstall.rb was also suggested.

Comment thread lib/engines/hcktest/hcktest.rb
Comment thread lib/models/hlk_platform.rb Outdated
Comment thread lib/engines/hckinstall/hckinstall.rb Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Comment thread lib/models.rb
Comment thread lib/models/hlk_platform.rb Outdated
Comment thread lib/models/hlk_platform.rb
Comment thread lib/models/hlk_platform.rb Outdated
Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
@kostyanf14
Copy link
Copy Markdown
Contributor Author

/gemini review

Comment thread spec/models/hlk_platform_json_spec.rb Fixed
Comment thread spec/models/hlk_platform_json_spec.rb Fixed
Comment thread spec/models/hlk_platform_json_spec.rb Fixed
Comment thread spec/models/hlk_platform_json_spec.rb Fixed
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the platform and client configuration parsing to use strongly-typed Sorbet models (HLKPlatform, HLKClient, and HLKPlatformClientsOptions) instead of raw JSON hashes. Hash accessors have been replaced with typed method calls across the codebase, and validation logic has been added for QEMU HCK platforms. The review feedback correctly identifies a potential runtime NoMethodError due to a missing nil check on @engine_platform in lib/project.rb, as well as Sorbet type-checking issues regarding nilable firmware binaries in lib/setupmanagers/qemuhck/qemuhck.rb.

Comment thread lib/project.rb
Comment thread lib/setupmanagers/qemuhck/qemuhck.rb
Comment thread lib/setupmanagers/qemuhck/qemuhck.rb
Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Comment thread lib/engines/hcktest/hcktest.rb
Comment thread lib/setupmanagers/qemuhck/qemuhck.rb
@kostyanf14 kostyanf14 merged commit 09c715a into HCK-CI:master May 29, 2026
12 of 13 checks passed
@kostyanf14 kostyanf14 deleted the platform-type branch May 29, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants