Implement `scoreTarget ` as CIL feature for categories
User story
As a user I want to have a scoreTarget configuration available to be able to control my KPIs better.
At the moment plugin-coverage implements something similar. A adopted version of this feature would be helpful as global CLI feature.
The behaviour should help to specify a value that acts as a gate in audit/score values to mark them as fulfilled/passed.
Existing similar ideas:
- The
largest-contentful-paintin theplugin-lighthouseplugin is scores with1(100) if the value is smaller than2000ms - The
plugin-coverageplugin provides aperfectScoreThresholdoption, to configure the score to be 1 (perfect) for all audits audits of the plugin. - The
CategoryConfigobject has aisBinaryproperty that adds a checkmark if the score is equal to1(100)
This feature is applicable to the following types/data objects:
AuditOtuputCategoryConfig
Relates parts Portal
- Score display in the portal
- The displayed score
- The
✅or❌mark on the score ATM configured overisBinaryRelates parts CLI
- The displayed score of
AuditOutputsin all report formatsmdas well as thejson- and the
stdoutin the terminal
- The displayed score of a category score in all report formats
mdas well as thejson- and the
stdoutin the terminal
- Shared type to implement this property to all plugins
Related PRs:
Acceptance criteria
- [x] https://github.com/code-pushup/cli/issues/592
graph TD
#592 --> CLI_Preparation
CLI_Preparation --> CLI_Client_Update
Portal_Model_Adoption --> Portal_UI_Update
Portal_Model_Adoption --> CLI_Client_Update
PR1 - CLI preparation
- [ ] rename
isBinarytotargetScoreand change the type tononnegativeNumberSchema.max(1) - (TBD) adjust
executePluginto apply the new scoring logic after the normalization (for audits) - [ ] adopt
categoryToGQLfunctions to convert the name back and the floating number back to boolean and mark it with a comment
PR2 - Portal model adoption
- [ ] accept a number from 0-1 for new property
targetScoreand removeisBinary - [ ] release portal-client
PR3 - CLI portal-client update
- [ ] adopt
categoryToGQLfunctions for new type upload - [ ] add
targetScorestyling to all places- [ ] for
categories,scoreTargetdoesn't change the score (or score colour), but affects whether ✅ or ❌ is displayed - (TBD) for
audits,scoreTargetmeans score is changed to perfect score, because it affects the category/group scoe calculation
- [ ] for
PR4 - Portal UI updates
- [ ] adopt score card for new
targetScorelogic
Implementation details
CategoryConfig adoption
const model = z.object({
scoreTarget: nonnegativeNumberSchema
.describe('Is this a binary category (i.e. only a perfect score considered a "pass")?')
.max(1)
.optional(),
}),
scoreTarget suggestion
export const scoreTargetSchema = z.union([
nonnegativeNumberSchema,
z.record(z.string(), nonnegativeNumberSchema)
])
.describe('one target treshold for all audits or a record with audit slug and treshold');
export type ScoreTarget = z.infer<typeof scoreTargetSchema>;
Part of other PR: #721
Related issues:
#592, #721
what about scoreTarget instead of goalScoreThreshold?
After discussion:
- for categories,
scoreTargetdoesn't change the score (or score colour), but affects whether ✅ or ❌ is displayed - for audits,
scoreTargetmeans score is changed to perfect score, because it affects the category/group scoe calculation