-
Notifications
You must be signed in to change notification settings - Fork 346
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
Add pdm lockfile support #776
Conversation
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.
Looks good, just got a few changes - would you mind also adding an "empty.lock" (which is "no packages", not "completely empty file") and "two-packages.lock" fixtures as well? (I know technically your other tests cover this, but it's consistent with the standard set of fixtures we have for our other lockfiles)
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.
would you mind restructuring these to use individual functions to be consistent with the rest of our lockfile tests
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.
Restructured
pkg/lockfile/parse-pdm-lock.go
Outdated
const PdmLockFileName = "pdm.lock" | ||
const pdmGroupDefault = "default" | ||
const pdmGroupDev = "dev" |
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.
we don't typically use constants for these, and you're only referencing them each once so lets just inline them
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.
Removed constants
type PdmLockPackage struct { | ||
Name string `toml:"name"` | ||
Version string `toml:"version"` | ||
Groups []string `toml:"groups"` |
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.
just noting for others: it looks like pdm only very recently started recording dependency groups at the package level in its lockfiles - I couldn't actually find any locks searching GitHub, but the PRs on pdm support this feature as being added
pkg/lockfile/parse-pdm-lock.go
Outdated
} | ||
|
||
//nolint:gochecknoinits |
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.
we should ensure the extractor matches the interface:
} | |
//nolint:gochecknoinits | |
} | |
var _ Extractor = PdmLockExtractor{} | |
//nolint:gochecknoinits |
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.
Added.
pkg/lockfile/parse-pdm-lock.go
Outdated
const pdmGroupDefault = "default" | ||
const pdmGroupDev = "dev" | ||
|
||
type PdmExtractor struct{} |
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 matches the naming we use for the other extractors:
type PdmExtractor struct{} | |
type PdmLockExtractor struct{} |
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.
Changed the name
Added requested tests. Amended fixes to the existing commit. |
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.
Awesome stuff! It'd be great if you could space out the tests a bit, but I think this is good to go!
} | ||
|
||
func TestParsePdmLock_FileDoesNotExist(t *testing.T) { | ||
t.Parallel() |
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.
nit: these are pretty squashed together
usually I like to have a new line between every function, after t.Parallel()
, and before the first expect*
call
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.
Added newlines to test functions.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #776 +/- ##
==========================================
+ Coverage 79.85% 80.02% +0.17%
==========================================
Files 90 91 +1
Lines 6174 6213 +39
==========================================
+ Hits 4930 4972 +42
+ Misses 1040 1038 -2
+ Partials 204 203 -1 ☔ View full report in Codecov by Sentry. |
Adds support for parsing package version information from lockfiles of pdm, package and dependency manager for Python.
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.
Thanks!
Add support for parsing package information from
pdm.lock
-files used bypdm
, package and dependency manager for Python (https://pdm-project.org/latest/)