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

fix(composer): Restore any modified files after analysis #9590

Merged
merged 1 commit into from
Dec 12, 2024

Conversation

sschuberth
Copy link
Member

@sschuberth sschuberth commented Dec 12, 2024

Introduce a LockfileProvider that ensures a lockfile to be present by either using the existing one, or enabling the creation of one and creating it. A self-created lockfile is deleted afterwards, and any modifications to the definition file are reverted.

@sschuberth sschuberth requested a review from a team as a code owner December 12, 2024 08:35
@sschuberth sschuberth enabled auto-merge (rebase) December 12, 2024 08:36
Copy link

codecov bot commented Dec 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.03%. Comparing base (ac6b3ae) to head (5ebf073).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #9590   +/-   ##
=========================================
  Coverage     68.03%   68.03%           
  Complexity     1285     1285           
=========================================
  Files           249      249           
  Lines          8826     8826           
  Branches        920      920           
=========================================
  Hits           6005     6005           
  Misses         2432     2432           
  Partials        389      389           
Flag Coverage Δ
funTest-docker 64.96% <ø> (ø)
funTest-non-docker 33.31% <ø> (ø)
test-ubuntu-24.04 35.81% <ø> (ø)
test-windows-2022 35.79% <ø> (ø)

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.

@sschuberth sschuberth force-pushed the composer-lockfile-provider branch from 8ba53b8 to f5998cf Compare December 12, 2024 10:41
@@ -139,7 +137,11 @@ class Composer(
}

val lockfile = stashDirectories(workingDir.resolve("vendor")).use { _ ->
ensureLockfile(workingDir).let {
val lockfileProvider = LockfileProvider(definitionFile)
Copy link
Member

Choose a reason for hiding this comment

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

I might be wrong, but to my understanding ORT's analyzers normally do not do this kind of clean-up.
If true, what's the reason for doing this here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree that this kind of cleanup is probably done inconsistently / not done at all for package managers currently. But I believe we should come up with a policy to start doing it consistently. Besides the annoyance of modified files when analyzing locally, leaving modified files behind also creates problems in CI pipelines that use git describe-based mechanisms to calculate the project version after analysis, as such approaches would eventually add a -dirty suffix to the version number.

Copy link
Member

Choose a reason for hiding this comment

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

as such approaches would eventually add a -dirty suffix to the version number.

These could be also easily addressed with dropping file changes via git.

I'm undecided if it's worth to maintain the logic for it, what do others think? maybe any @oss-review-toolkit/core-devs ?

Copy link
Member Author

Choose a reason for hiding this comment

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

These could be also easily addressed with dropping file changes via git.

Our premise has always been that the ORT analyzer can be used without changes to your build, and that includes making fixups like resetting modified files with Git in a CI pipeline in my view.

Note that approving this PR does not mean that you agree to do the same changes for other package managers. As such I'd appreciate if the discussion could be limited to the code in this PR, and to pursue the general discussion elsewhere.

Copy link
Member

@mnonnenmacher mnonnenmacher Dec 12, 2024

Choose a reason for hiding this comment

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

In my opinion we should always try to not modify the project files with the analyzer, and we have to, clean up afterward, and I think that was always our philosophy, although we might have forgotten to implement it consistently. For example, in NPM we could simply delete the node_modules directory, but instead we move it away so that it can be restored after the analysis.

@sschuberth sschuberth requested a review from a team December 12, 2024 11:50
Introduce a `LockfileProvider` that ensures a lockfile to be present by
either using the existing one, or enabling the creation of one and
creating it. A self-created lockfile is deleted afterwards, and any
modifications to the definition file are reverted.

Signed-off-by: Sebastian Schuberth <[email protected]>
@sschuberth sschuberth force-pushed the composer-lockfile-provider branch from f5998cf to 5ebf073 Compare December 12, 2024 19:33
@mnonnenmacher mnonnenmacher self-requested a review December 12, 2024 19:40
@sschuberth sschuberth merged commit a9ce535 into main Dec 12, 2024
26 checks passed
@sschuberth sschuberth deleted the composer-lockfile-provider branch December 12, 2024 19:52
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.

3 participants