-
Notifications
You must be signed in to change notification settings - Fork 356
feat(Provenance): Add DirectoryProvenance as a LocalProvenance
#9872
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
base: main
Are you sure you want to change the base?
Conversation
a984e1f to
2471efa
Compare
2471efa to
1e3c8cf
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #9872 +/- ##
============================================
+ Coverage 57.38% 57.47% +0.08%
- Complexity 1673 1691 +18
============================================
Files 346 346
Lines 12759 12801 +42
Branches 1209 1219 +10
============================================
+ Hits 7322 7357 +35
- Misses 4972 4976 +4
- Partials 465 468 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
1e3c8cf to
c2f8552
Compare
DirectoryProvenance as a LocalProvenanceLocalProvenance sub-interface
c2f8552 to
c6cbdbc
Compare
|
@sschuberth failing tests seem unrelated. |
c6cbdbc to
c0a51c2
Compare
The "Unable to create proxy for sealed class" failures in |
|
Thanks @sschuberth, I missed that. I'm already working on the However, it is quite a large branch, since a lot of I started with reasonable implementation for the Any thoughts or other ideas how to keep the PR small? |
Can't you "cheat" a bit by first limiting some / all |
Great to see we are on the same page here. I will do just that. |
9322fb4 to
9ffd2c5
Compare
LocalProvenance sub-interfaceDirectoryProvenance as a LocalProvenance
|
@sschuberth I added the |
|
Commit message:
We should probably say "absolute" / "canonical" / "real" path, and do the implementation accordingly.
"the new class can not be used right now."
"However, the presence of a new
"Wherever"
"exception"
"provenance hierarchy" |
9ffd2c5 to
9fc284d
Compare
9fc284d to
4d39003
Compare
cfdad33 to
4b97905
Compare
4b97905 to
cdeeddb
Compare
| is UnknownProvenance -> false | ||
| is ArtifactProvenance -> sourceArtifactUrl != null && sourceArtifactUrl == provenance.sourceArtifact.url | ||
| is RepositoryProvenance -> vcs != null && vcs.matches(provenance) | ||
| is DirectoryProvenance -> false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could combine this with line 85 to
is DirectoryProvenance, UnknownProvenance -> false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But actually, at least when a PackageConfiguration is used in the context of a RepositoryConfiguration, the Identifier (and Provenance) actually is allowed to refer to a Project. So we should probably implement a proper check for DirectoryProvenance in that case after all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I assumed we would need a proper check sooner or later, which is why I added the case as a separate line.
Since this would touch the attributes of the PackageConfiguration, I assumed the best cause of action was to postpone any changes for the sake of a shorter PR and handle DirectoryProvenace like UnknownProvenance for now. I'd recommend to handle this, when we actually start using the DirectoryProvenance.
| * scan results for a package based on the VCS path. | ||
| */ | ||
| private val packageProvenances = mutableMapOf<Identifier, KnownProvenance>() | ||
| private val packageProvenances = mutableMapOf<Identifier, RemoteProvenance>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is changed, the docs need to be adjusted as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change requires some careful thinking: We actually do want to be able to scan projects with DirectoryProvenance in the end, at least in the case when analyzer and scanner are run on the same machine. So is it really correct to limit us to RemoteProvenance here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are probably multiple places, where the limit to RemoteProvenance is not correct in order to handle the DirectoryProvenance, once it is fully implemented.
But right now, while the class is dormant, it is either this or cast the arguments. Otherwise we would have to handle it everywhere from the get go as well.
side note: as this attribute is named packageProvenances, we probably need to address the shift from packages to projects as (primary) input for the scanner at some point, since you repeatedly stated before that a DirectoryProvenace can not be a Package due to lack of a remote.
| val query = table.selectAll() | ||
|
|
||
| if (provenance !is RemoteProvenance) { | ||
| throw ScanStorageException("Scan result must have a known provenance, but it is $provenance.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The message refers to "known provenance", but the check is against RemoteProvenance, so this does not match.
This also somewhat relates to my comment above, that we actually do want to be able to scan a DirectoryProvenance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the code and the exception's text are technically not reflecting the same thing.
However, while the DirectoryProvenance is unused, the RemoteProvenance is practically the same as KnownProvenance. Similar to my comment above, this is a temporary change, which aims to avoid issues due unfinished class handling.
| requireEmptyVcsPath(provenance) | ||
|
|
||
| if (provenance !is KnownProvenance) { | ||
| if (provenance !is RemoteProvenance) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same. ^^
cdeeddb to
84cf646
Compare
150b157 to
19e6d80
Compare
19e6d80 to
534213d
Compare
534213d to
0f33b19
Compare
In contrast to the previously added `RemoteProvenance` stands the `LocalProvenance`, which has no remote source, but instead references a local input of some kind. The `DirectoryProvenance` references a local project directory, which is lacking supported (remote) version control. It is defined by its canonical path only. Since ORT needs further refactoring until `DirectoryProvenance` can be fully utilized, the new class can not be used right now. However the presence of a new `KnownProvenance` class results in `when` conditional cases not being exhaustive anymore. To circumvent this issue, the following changes were made: 1. Wherever possible `RemoteProvenance` is used as parameter type instead of `KnownProvenance`. 2. When necessary `KnownProvenance`s are cast to `RemoteProvenance`. 3. If `Provenance` is expected, `DirectoryProvenance` is handled like `UnknownProvenance`. For instances of `Package` the new default data structure should be `RemoteProvenance`, as a `Package` by definition requires a remote. The exception being `hash` and `storageKey`, which both required a default value, which was set to the `canonicalPath`. However, since the rest of the code does not handle `DirectoryProvenance`, this should remain unused for now. See [1] for more context on the new provenance hierarchy. [1]: oss-review-toolkit#8803 (comment) Signed-off-by: Jens Keim <[email protected]>
Casts were removed from `FileListResolver`, `ProvenanceBasedFileStorage`, `ProvenanceDownloader`, and `Scanner`. In order to avoid casting `KnownProvenance` to `RemoteProvenance`, a lot of parameters need to be changed to `RemoteProvenance`. With the exception of `ProvenanceBasedFileStorage`, which now uses `UnknownProvenance` exceptions just like `ProvenanceBasedPostgresStorage`. Signed-off-by: Jens Keim <[email protected]>
Signed-off-by: Jens Keim <[email protected]>
0f33b19 to
450b5eb
Compare
|
Just a rebase onto |
|
As discussed in the weekly developer meeting today, I have for you the working branch for handling The branch is still rough, I just extracted it from the POC. I believe for proper handling of the |
In contrast to the previously added
RemoteProvenancestands theLocalProvenance, which has no remote source, but instead references a local input of some kind.The
DirectoryProvenancereferences a local project directory, which is lacking supported (remote) version control. It is defined by its local directory path only.Since ORT needs further refactoring until
DirectoryProvenancecan be fully utilized, it the new class can not be used right now. However the presence of a newKnownProvenanceclass, results inwhenconditional cases not being exhaustive anymore.To circumvent this issue, the following changes were made:
RemoteProvenanceis used as parameter type instead ofKnownProvenance.KnownProvenances are cast toRemoteProvenance.Provenanceis expected,DirectoryProvenanceis handled likeUnknownProvenance.The excaption being
hashandstorageKey, which both default to an empty string. However, since the rest of the code does not handleDirectoryProvenance, this should not become an issue.For more context on the new Provenance Hierarchy, see: #8803 (comment)
Signed-off-by: Jens Keim [email protected]