Repository navigation
XRAY-170058 - Supports requirements file flag in jf ca - #952
gauriy-tech wants to merge 2 commits into
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
5b958b7 to
f6e4bc4
Compare
| if ca.Progress() != nil { | ||
| err = errors.Join(err, ca.Progress().Quit()) | ||
| } | ||
| if err == nil && ca.detectedTechCount == 0 { |
There was a problem hiding this comment.
Runs that produce no audit report (an unsupported-only directory such as conanfile.txt, or Hugging Face auto-discovery that finds no model references) still exit 0 with nothing audited, because the counter is incremented on detection (techs), not on a produced report. Consider checking results instead. results only gets an entry once an audit produced a report, so it needs no extra state; detectedTechCount (field at 316-318 and the += in doCurateAudit) can then be removed.
| if err == nil && ca.detectedTechCount == 0 { | |
| if err == nil && len(results) == 0 { |
One question: an HF run where every reference is unresolved or dynamic still adds a warnings-only placeholder to results (it already exits 0 today with a "NOT audited" warning). Is exit 0 intended there?
Review generated by xray-pr-review
| techs := promotePnpmWorkspaceMember(techutils.DetectedTechnologiesListForCurationAudit()) | ||
| techs := promotePnpmWorkspaceMember(techutils.DetectedTechnologiesListForCurationAuditWithRequirementsFile(ca.PipRequirementsFile())) | ||
| techs = promoteYarnWorkspaceMember(techs) | ||
| techs = promotePipToUvIn(techs, ca.OriginPath) |
There was a problem hiding this comment.
With a machine-global ~/.config/uv/uv.toml (a curation-only signal, PromotePipToUvForCurationAudit), --requirements-file=requirements-dev.txt — the example in the jf ca help — is audited as uv, so the flag is silently ignored. jf audit doesn't consider the global config. Consider using techutils.PromotePipToUv only when the named file exists in this directory, so other --working-dirs entries keep the default promotion, and replacing this line with techs = ca.promotePipToUv(techs):
func (ca *CurationAuditCommand) promotePipToUv(techs []string) []string {
if ca.PipRequirementsFile() == "" || ca.OriginPath == "" {
return promotePipToUvIn(techs, ca.OriginPath)
}
if _, statErr := os.Stat(filepath.Join(ca.OriginPath, ca.PipRequirementsFile())); statErr != nil {
return promotePipToUvIn(techs, ca.OriginPath)
}
promoted := techutils.PromotePipToUv(techutils.ToTechnologies(techs), ca.OriginPath)
result := make([]string, 0, len(promoted))
for _, t := range promoted {
result = append(result, t.String())
}
return result
}A uv.lock next to the custom file still promotes to uv, as in jf audit. An absolute --requirements-file value isn't covered by the stat (it falls back to the current behavior).
Review generated by xray-pr-review
| errorNothingAudited = "no supported package manager was recognised in any working directory, so nothing was audited. " + | ||
| "Check the working directories, or pass --requirements-file for a custom pip file name." |
There was a problem hiding this comment.
When --requirements-file was passed but matched nothing, the "pass --requirements-file" hint isn't actionable. Consider naming the value only when it is set (the wording is neutral because the same error also covers unsupported-only and HF-empty runs):
| errorNothingAudited = "no supported package manager was recognised in any working directory, so nothing was audited. " + | |
| "Check the working directories, or pass --requirements-file for a custom pip file name." | |
| errorNothingAudited = "nothing was audited: no supported project files were found in the working directories. " + | |
| "For a custom-named pip requirements file, use --requirements-file." | |
| errorNothingAuditedWithRequirementsFile = "nothing was audited: no supported project files were found in the working directories " + | |
| "(--requirements-file %q matched no file there)." |
plus a small helper that picks the message, used at the call site in Run():
func (ca *CurationAuditCommand) nothingAuditedError() error {
if file := ca.PipRequirementsFile(); file != "" {
return errorutils.CheckErrorf(errorNothingAuditedWithRequirementsFile, file)
}
return errorutils.CheckErrorf(errorNothingAudited)
}Review generated by xray-pr-review
| err = errors.Join(err, ca.Progress().Quit()) | ||
| } | ||
| if err == nil && ca.detectedTechCount == 0 { | ||
| err = errorutils.CheckErrorf(errorNothingAudited) |
There was a problem hiding this comment.
Was the exit-code change (exit 0 → error when nothing is audited) part of XRAY-170058's scope? It also applies to the curation-after-failure path (an extra [Error] line after the user's own failed install) and to HF-only runs under a globally exported HF_ENDPOINT. If it is intended, could the PR description, the release note and the help.go "Gotchas" mention it? Would a warning first be an option for existing CI usage?
Review generated by xray-pr-review
|
In the curation-after-failure path ( Review generated by xray-pr-review |
|
Could you add a short description to the PR? Currently it has the template checklist (unchecked) and screenshots but no text on what changed and why. It would help to mention that Review generated by xray-pr-review |
devbranch.Before

After