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

dependabot doesn't work well for multi modules repository #6678

Closed
1 task done
ahrtr opened this issue Feb 16, 2023 · 6 comments
Closed
1 task done

dependabot doesn't work well for multi modules repository #6678

ahrtr opened this issue Feb 16, 2023 · 6 comments
Labels
F: monorepo 📦 Issues related to bumping a dep in manifests from multiple apps L: go:modules Golang modules T: bug 🐞 Something isn't working

Comments

@ahrtr
Copy link

ahrtr commented Feb 16, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Package ecosystem

gomod

Package manager version

No response

Language version

golang 1.19.5

Manifest location and content before the Dependabot update

dependabot.yml content

https://github.com/etcd-io/etcd/blob/main/.github/dependabot.yml

Updated dependency

No response

What you expected to see, versus what you actually saw

etcd is a multi-modules repository. The problem is each time dependabot automatically creates a PR for each module for exactly the same dependency. Let's work with an example. Multiple modules (e.g. client/v3, etcdctl, etcdutl, pkg, server, test ) depend on github.com/dustin/go-humanize, so dependabot automatically creates the following PRs,

Obviously it doesn't make sense. It makes more sense to do all of them in one PR.

Note the go modules are interrelated, and each module depends on the local version of other modules using the replace directive, e.g. go.mod#L6-L13

replace (
	go.etcd.io/etcd/api/v3 => ../api
	go.etcd.io/etcd/client/pkg/v3 => ../client/pkg
	go.etcd.io/etcd/client/v2 => ../client/v2
	go.etcd.io/etcd/client/v3 => ../client/v3
	go.etcd.io/etcd/etcdctl/v3 => ../etcdctl
	go.etcd.io/etcd/etcdutl/v3 => ../etcdutl
	go.etcd.io/etcd/pkg/v3 => ../pkg
	go.etcd.io/etcd/server/v3 => ../server
)

When you bump a dependency for one of the module (assuming A), and then execute go mod tidy for another module (assming B), the go.mod and go.sum of B may also change. So usually the PR submitted by dependabot will never pass the github workflow's test/validation.

Is there any solution for such situation? Or what's the best practice for dependency management for multi-module (go module) repository?

We also attempt to remove non-root gomod dependabot rules as to as remove most of the spam. But the problem is some direct dependencies in sub-directories' go.mod files are marked as indirect dependencies in the top level go.mod file; and it seems that dependabot will not bump version for indirect dependencies. I did a simple experiment in ahrtr/deps, and confirmed that dependabot indeed doesn't bump indirect dependency ( github.com/stretchr/testify v1.7.1 in this experiment). Did I miss anything? Could anyone confirm this?

Native package manager behavior

No response

Images of the diff or a link to the PR, issue, or logs

No response

Smallest manifest that reproduces the issue

No response

@GerardGarcia
Copy link

I can confirm I'm having the same issue in a project with multiple modules and I'm also seeing that dependabot is not updating the indirect dependencies of nested modules.

@jeffwidman
Copy link
Member

Thanks, and sorry for the frustrating experience here. However, this is already tracked under:

So I'm going to close as a duplicate.

Regarding your other questions:

When you bump a dependency for one of the module (assuming A), and then execute go mod tidy for another module (assming B), the go.mod and go.sum of B may also change. So usually the PR submitted by dependabot will never pass the github workflow's test/validation.

Is there any solution for such situation? Or what's the best practice for dependency management for multi-module (go module) repository?

In the abstract, you basically need custom post-processing of the PR based on the structure of your repo... that's probably best accomplished by using a custom GitHub action that watches for Dependabot PR's and then runs go mod tidy on them. Here's an example of how to wire something like this up: https://github.com/dependabot/dependabot-actions-workflow

But the problem is some direct dependencies in sub-directories' go.mod files are marked as indirect dependencies in the top level go.mod file; and it seems that dependabot will not bump version for indirect dependencies.

We actually just added support for bumping indirect deps in go at the beginning of January:

However, bumping transitive deps is the non-default behavior because it's noisy, so you'll need to specifically allow indirect deps in the dependabot.yml config.

Hopefully this helps, and if it's still confusing let us know so we can improve our docs.

@jeffwidman jeffwidman closed this as not planned Won't fix, can't repro, duplicate, stale Mar 1, 2023
@ahrtr
Copy link
Author

ahrtr commented Mar 1, 2023

However, bumping transitive deps is the non-default behavior because it's noisy, so you'll need to specifically allow indirect deps in the dependabot.yml config.

Thanks for the feedback. So we need to configure the dependabot.yml something like below if we want to bump both direct and indirect dependencies?

  - package-ecosystem: gomod
    directory: /
    schedule:
      interval: weekly
    allow:
      - dependency-type: direct
      - dependency-type: indirect

@jeffwidman
Copy link
Member

Pretty sure you can use dependency-type: all to get both direct + indirect, and that matches what the docs say. If that doesn't work please let me know so we can fix the docs.

@ahrtr
Copy link
Author

ahrtr commented Mar 1, 2023

Pretty sure you can use dependency-type: all to get both direct + indirect, and that matches what the docs say. If that doesn't work please let me know so we can fix the docs.

Thanks for the quick response. But it seems that the doc isn't correct. Anyway, let me try it out.

All explicitly defined dependencies. For bundler, pip, composer, cargo, gomod, also the dependencies of direct dependencies.

@ahrtr
Copy link
Author

ahrtr commented Mar 1, 2023

Confirmed that dependency-type: all works. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: monorepo 📦 Issues related to bumping a dep in manifests from multiple apps L: go:modules Golang modules T: bug 🐞 Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants