Hey all, so I’m pleased to announce Shards support for dependabot is finally is in a reviewable state!
Needless to say the vast majority of the files are just boilerplate, but i’d love to get at least some initial community feedback/testing before i go and open a PR against upstream. I opened a PR in my fork to make reviewing easier, which ultimately i’ll squash (based on author) once it’s in a good spot.
This is a good starting point to understand the architecture, but I also wanted to outline my approach at a high level to make it easier to review than first having to fully understand how dependabot internals work. Each section includes some option questions that would be to focus on. Tho some of these may be better suited to the dependabot maintainers themselves.
Implementation
FileFetcher
Parses shard.yml
from host, and shard.lock
if it exists. Don’t really think we need to worry about path dependencies for now, if ever.
Open Questions
- All the other ecosystems have a concept of “supported versions”, for now I just made this
>= 0.19
as other ecosystems have versions like>= 0.13
so seems reasonable. - Is the
lib/.shards.info
file important at all? Seems to be on version1.0
unlikeshard.lock
FileParser
Parses shard.yml
and shard.lock
into either a runtime
or development
dependency group depending on if they’re dependencies
or development_dependencies
. This is one of the areas where i’m not 100%. shard.yml
dependencies are treated as having a *
requirement if they only provide github
.
Open Questions
- If there is not a
shard.lock
, how to determine the version of a dependency? My thinking is if there is noshard.lock
then it’s not installed sonil
makes sense. Otherwise we could figure out what would be installed viagit
but don’t think that’s appropriate. - For
branch
/commit
/tag
, the current logic just does latest commit on a branch for branch, latest tag fortag
, and no-ops forcommit
since there is no upgradable path for that. - For
runtime
vsdevelopment
we don’t really have a way to know if a given dep is one or the other outside of them being directly listed independencies
ordevelopment_dependencies
. So as of now it’ll just assume they’re aruntime
if not explicitly included within the top level keys ofdevelopment_dependencies
. - The format (
0.13.0+git.commit.7fff589e026412646b33cef80f78cd1c7fd072aa
) ofbranch
/commit
/tag
is kinda strange because it includes the commit and the last tag is there a reason for that vs making it specific totag
? Actually just seems to use theversion
of the shard inshard.yml
as even if you don’t have any tags, it’ll use0.1.0+git.commit...
when pinned tomaster
branch for example
UpdateChecker
#fetch_latest_version
is basically the implementation of the second open in the FileParser
section. We also can’t really rely on dependabot’s built-in git
features (tho its been a while as to exactly why). The RequirementsUpdater
helper type is what actually handles changing the version of a dep one to another. The logic in there and #fetch_latest_version
makes sense to me, but another pair of eyes wouldn’t hurt. It just tries to keep the version
requirement similar to what it was before.
Vast majority of the determining the latest “resolvable” version is basically just running like shards lock --update ameba
in a temp dir and reading the updated lock file. Might be a more robust way to handle it, but this was easiest and seems to work fine.
Open Questions
-
#fetch_latest_version
/RequirementsUpdater
logic makes sense? - Not totally sure what “full unlock” means
- Probably fine to keep using
shards lock
command?
FileUpdater
Feel pretty good about this one, just handles writing the updates to the underlying files
Requirement, Version, MetadataFinder, PackageManager, Language
Feel pretty good about these, mostly just boilerplate/meta information about the ecosystem and such. Dependabot makes use of some Ruby Gem related types like Requirement
for representing a dependency’s version constraint. E.g. ~> 1.2.3
. It supports mostly the same values, other than *
at least.
Final Thoughts
- Currently only supports
git
, probably fine - Some repos to test on would be
- Want to take another pass on the specs, they dont feel all that robust to me even tho coverage is good. Tho might just be rspec feeling weird to me
- Don’t think we need to handle any security/credential stuff since it’s all just
git
- Ultimately will need to implement the
cooldown
feature, at first glance seems doable as it just uses metadata related to a tag.