Skip to content
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

🐛 Analysis - Update the TaskGroup to id selected rulesets #2034

Merged
merged 5 commits into from
Aug 2, 2024

Conversation

sjd78
Copy link
Member

@sjd78 sjd78 commented Aug 1, 2024

Supports: https://issues.redhat.com/browse/MTA-3330

The way custom targets are handled by the analysis wizard has been updated. There are no visual changes.

At analysis start time, a Taskgroup is submitted containing all of the user's choices. To better support custom targets, the ruleSet of any selected custom targets will no be submitted as part of the Taskgroup.TaskData.rules. Identifying the ruleSet will allow the custom target's rules to be enabled in analysis.

In support of this change:

  • The wizard's form data now stores a Target[] instead of a number[] to make working with the selected targets more convenient across the wizard components.
  • Any code working with just the targetId has been updated to use the full Target object
  • The handlers for changes to the target labels on the wizard's options step better handle mapping the selected label changes to target card selection

Copy link

codecov bot commented Aug 1, 2024

Codecov Report

Attention: Patch coverage is 18.91892% with 30 lines in your changes missing coverage. Please review.

Project coverage is 42.37%. Comparing base (b654645) to head (a38bd49).
Report is 207 commits behind head on main.

Files Patch % Lines
...rc/app/pages/applications/analysis-wizard/utils.ts 20.00% 15 Missing and 1 partial ⚠️
...pages/applications/analysis-wizard/set-options.tsx 22.22% 7 Missing ⚠️
...s/applications/analysis-wizard/analysis-wizard.tsx 0.00% 4 Missing ⚠️
...pages/applications/analysis-wizard/set-targets.tsx 25.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2034      +/-   ##
==========================================
+ Coverage   39.20%   42.37%   +3.17%     
==========================================
  Files         146      172      +26     
  Lines        4857     5520     +663     
  Branches     1164     1360     +196     
==========================================
+ Hits         1904     2339     +435     
- Misses       2939     3065     +126     
- Partials       14      116     +102     
Flag Coverage Δ
client 42.37% <18.91%> (+3.17%) ⬆️
server ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

jortel added a commit to konveyor/tackle2-addon-analyzer that referenced this pull request Aug 1, 2024
https://issues.redhat.com/browse/MTA-3330

A custom target that references a repository will be created with a
related `RuleSet`. A repository may be defined on the ruleSet. An
analysis task defines _included_ labels which determine which rulesets
are pulled (downloaded) from the hub. Since ruleSets that reference
repositories do not have labels, the addon did not know to download it
and clone the repository.

Solution:
The new rules.ruleSets will be used to pass a list of RuleSet (refs)
selected by the user (by selecting targets). Each will be be
unconditionally fetched by the addon.

For each ruleset with a repository the addon will:
- clone the repository
- update .yaml files - replacing the `labels` element with
`konveyor.io/include=always`.

related: konveyor/tackle2-ui#2034

---------

Signed-off-by: Jeff Ortel <[email protected]>
github-actions bot pushed a commit to konveyor/tackle2-addon-analyzer that referenced this pull request Aug 1, 2024
https://issues.redhat.com/browse/MTA-3330

A custom target that references a repository will be created with a
related `RuleSet`. A repository may be defined on the ruleSet. An
analysis task defines _included_ labels which determine which rulesets
are pulled (downloaded) from the hub. Since ruleSets that reference
repositories do not have labels, the addon did not know to download it
and clone the repository.

Solution:
The new rules.ruleSets will be used to pass a list of RuleSet (refs)
selected by the user (by selecting targets). Each will be be
unconditionally fetched by the addon.

For each ruleset with a repository the addon will:
- clone the repository
- update .yaml files - replacing the `labels` element with
`konveyor.io/include=always`.

related: konveyor/tackle2-ui#2034

---------

Signed-off-by: Jeff Ortel <[email protected]>
Signed-off-by: Cherry Picker <[email protected]>
sjd78 added 3 commits August 1, 2024 12:24
  Targets getting selected will add labels.  The set
  of labels isn't visible until the options step.  On
  that step the labels can be changed.

  When the labels change, the new set of labels need
  to be mapped back to the targets.  The mapping code
  needs to:
    - Keep the correct set of target cards selected as
      per the current set of selected target labels
    - Keep targets selected that lack any labels (currently
      only custom source repository targets have no
      labels)

Signed-off-by: Scott J Dickerson <[email protected]>
@sjd78 sjd78 force-pushed the analysis_with_custom_targets branch from d478e86 to ed417ab Compare August 1, 2024 16:24
jortel added a commit to konveyor/tackle2-addon-analyzer that referenced this pull request Aug 1, 2024
https://issues.redhat.com/browse/MTA-3330

A custom target that references a repository will be created with a
related `RuleSet`. A repository may be defined on the ruleSet. An
analysis task defines _included_ labels which determine which rulesets
are pulled (downloaded) from the hub. Since ruleSets that reference
repositories do not have labels, the addon did not know to download it
and clone the repository.

Solution:
The new rules.ruleSets will be used to pass a list of RuleSet (refs)
selected by the user (by selecting targets). Each will be be
unconditionally fetched by the addon.

For each ruleset with a repository the addon will:
- clone the repository
- update .yaml files - replacing the `labels` element with
`konveyor.io/include=always`.

related: konveyor/tackle2-ui#2034

---------

Signed-off-by: Jeff Ortel <[email protected]>
Signed-off-by: Cherry Picker <[email protected]>

Signed-off-by: Jeff Ortel <[email protected]>
Signed-off-by: Cherry Picker <[email protected]>
Co-authored-by: Jeff Ortel <[email protected]>
@sjd78 sjd78 added the cherry-pick/release-0.5 This PR should be cherry-picked to release-0.5 branch. label Aug 1, 2024
@sjd78 sjd78 added this to the v0.5.1 milestone Aug 1, 2024
Copy link
Collaborator

@rszwajko rszwajko left a comment

Choose a reason for hiding this comment

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

Looks OK! Standard analysis works fine.

const ruleSetRefsFromSelectedTargets: Ref[] = fieldValues.selectedTargets
.map(({ ruleset }) => ruleset)
.filter(Boolean)
.map<Ref>(({ id, name }) => ({ id: id ?? 0, name: name ?? "" }));
Copy link
Collaborator

Choose a reason for hiding this comment

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

can zero ID be used by some existing rule set? if yes then I would go with safer value.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope. Ids start at 1.

}
const updatedFormLabels = !matchingLabel
? formLabels
: toggle(formLabels, matchingLabel, (tl) => tl.label);
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice!

@sjd78 sjd78 merged commit e920acb into konveyor:main Aug 2, 2024
12 checks passed
github-actions bot pushed a commit that referenced this pull request Aug 2, 2024
Supports: https://issues.redhat.com/browse/MTA-3330

The way custom targets are handled by the analysis wizard has been
updated. There are no visual changes.

At analysis start time, a `Taskgroup` is submitted containing all of the
user's choices. To better support custom targets, the `ruleSet` of any
selected custom targets will no be submitted as part of the
`Taskgroup.TaskData.rules`. Identifying the `ruleSet` will allow the
custom target's rules to be enabled in analysis.

In support of this change:
  - The wizard's form data now stores a `Target[]` instead of a `number[]`
    to make working with the selected targets more convenient across the
    wizard components.
  - Any code working with just the `targetId` has been updated to use the
    full `Target` object
  - The handlers for changes to the target labels on the wizard's options
    step better handle mapping the selected label changes to target card
    selection

---------

Signed-off-by: Scott J Dickerson <[email protected]>
Signed-off-by: Cherry Picker <[email protected]>
@sjd78 sjd78 deleted the analysis_with_custom_targets branch August 2, 2024 13:48
sjd78 pushed a commit that referenced this pull request Aug 2, 2024
…ed rulesets (#2034) (#2042)

Backport-of: #2034
Supports: https://issues.redhat.com/browse/MTA-3330

The way custom targets are handled by the analysis wizard has been
updated. There are no visual changes.

At analysis start time, a `Taskgroup` is submitted containing all of the
user's choices. To better support custom targets, the `ruleSet` of any
selected custom targets will no be submitted as part of the
`Taskgroup.TaskData.rules`. Identifying the `ruleSet` will allow the
custom target's rules to be enabled in analysis.

In support of this change:
  - The wizard's form data now stores a `Target[]` instead of a `number[]`
    to make working with the selected targets more convenient across the
    wizard components.
  - Any code working with just the `targetId` has been updated to use the
    full `Target` object
  - The handlers for changes to the target labels on the wizard's options
    step better handle mapping the selected label changes to target card
    selection

---------

Signed-off-by: Scott J Dickerson <[email protected]>
Signed-off-by: Cherry Picker <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick/release-0.5 This PR should be cherry-picked to release-0.5 branch.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants