Skip to content

Add exclude-paths option to dependabot.yml #12532

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

Merged

Conversation

dnlfm
Copy link
Contributor

@dnlfm dnlfm commented Jun 30, 2025

This PR adds the possibility of specifying exclude-paths in dependabot.yml.

It's a very old issue, and I decided to give a first stab: #4364

End-to-end tests may be required to validate the solution. Unit tests are in place.

Example of dependabot.yml with the new option:

version: 2
updates:
  - package-ecosystem: "npm_and_yarn"
    directory: "/"
    schedule:
      interval: "daily"
    exclude-paths:
      - "src/test/assets"
      - "vendor/**"
      - "src/*.rb"
      - "src/test/helper.rb"

@dnlfm dnlfm requested a review from a team as a code owner June 30, 2025 11:11
@github-actions github-actions bot added L: java:gradle Maven packages via Gradle L: github:actions GitHub Actions labels Jun 30, 2025
@dnlfm dnlfm marked this pull request as draft June 30, 2025 11:37
@dnlfm dnlfm marked this pull request as ready for review July 1, 2025 01:03
@markhallen markhallen moved this to Scoping in Dependabot Jul 1, 2025
@markhallen markhallen moved this from Scoping to Ready in Dependabot Jul 2, 2025
@markhallen markhallen moved this from Ready to Scoping in Dependabot Jul 2, 2025
@dnlfm dnlfm changed the title Add exclude_directories option to dependabot.yml Add exclude_paths option to dependabot.yml Jul 2, 2025
@dnlfm dnlfm changed the title Add exclude_paths option to dependabot.yml Add exclude-paths option to dependabot.yml Jul 16, 2025
@randhircs randhircs force-pushed the dnlfm/exclude-directories-flag-issue-4364 branch from bf36625 to 696c6c6 Compare July 22, 2025 18:53
@randhircs randhircs self-assigned this Jul 22, 2025
@randhircs
Copy link
Contributor

@dnlfm You may like to fix the specs which are failing.

@dnlfm
Copy link
Contributor Author

dnlfm commented Jul 22, 2025

@dnlfm You may like to fix the specs which are failing.

@randhircs I'm sorry but why did you force push, rewriting previous commits?

The failing spec is not related to the changes in this PR:
image

It seems this issue appeared after your commit. Force-pushes should be avoided, it may have modified something that it is hard to know what it is, as it may have rewritten the git tree. The Specs / ci was fine before this happened: https://github.com/dependabot/dependabot-core/actions/runs/16314785084/job/46077982547

@randhircs
Copy link
Contributor

@dnlfm You may like to fix the specs which are failing.

@randhircs I'm sorry but why did you force push, rewriting previous commits?

The failing spec is not related to the changes in this PR: image

It seems this issue appeared after your commit. Force-pushes should be avoided, it may have modified something that it is hard to know what it is, as it may have rewritten the git tree. The Specs / ci was fine before this happened: https://github.com/dependabot/dependabot-core/actions/runs/16314785084/job/46077982547

@dnlfm I had to rebase to proceed to check if all specs are passing. I am sure sorbet fix is something you can check from your end.

@randhircs randhircs force-pushed the dnlfm/exclude-directories-flag-issue-4364 branch from 696c6c6 to 95d602e Compare July 24, 2025 20:59
@randhircs
Copy link
Contributor

randhircs commented Jul 24, 2025

@dnlfm Again now, I am checking by rebasing it to see if all specs are good. i feel that you may like to fix the sorbet issue.

@dnlfm
Copy link
Contributor Author

dnlfm commented Jul 25, 2025

@dnlfm Again now, I am checking by rebasing it to see if all specs are good. i feel that you may like to fix the sorbet issue.

Hi @randhircs,
I see "Sorbet" was added to this project but not really added to the files, i.e. not completely rolled out it seems. For example,

Checking updater/lib/dependabot/file_fetcher_command.rb for Sorbet typing...
No Sorbet typing found at the top of updater/lib/dependabot/file_fetcher_command.rb

The file file_fetcher_command.rb wasn't added by me, and it contains this error for Sorbet typing.
I would like you to check that, as it is something that was not added in this PR. Another PR that I saw where Sorbet is failing but didn't add the file is: #12589 where the file uv/lib/dependabot/uv/file_fetcher.rb originally didn't have the Sorbet typing, confirming that it is something in the project that wasn't rolled out well.

I would like to also ask you to remove the need of Sorbet typing in test files, as I added # typed: ignore, it is still requiring to use strict or strong, but again, it doesn't make sense to have it in test files.

I would prefer to not have to check these Sorbet issues by myself.

@kbukum1
Copy link
Contributor

kbukum1 commented Jul 28, 2025

@dnlfm Again now, I am checking by rebasing it to see if all specs are good. i feel that you may like to fix the sorbet issue.

Hi @randhircs, I see "Sorbet" was added to this project but not really added to the files, i.e. not completely rolled out it seems. For example,

Checking updater/lib/dependabot/file_fetcher_command.rb for Sorbet typing...
No Sorbet typing found at the top of updater/lib/dependabot/file_fetcher_command.rb

The file file_fetcher_command.rb wasn't added by me, and it contains this error for Sorbet typing. I would like you to check that, as it is something that was not added in this PR. Another PR that I saw where Sorbet is failing but didn't add the file is: #12589 where the file uv/lib/dependabot/uv/file_fetcher.rb originally didn't have the Sorbet typing, confirming that it is something in the project that wasn't rolled out well.

I would like to also ask you to remove the need of Sorbet typing in test files, as I added # typed: ignore, it is still requiring to use strict or strong, but again, it doesn't make sense to have it in test files.

I would prefer to not have to check these Sorbet issues by myself.

@dnlfm — We actually added full Sorbet type checks later on. However, files without proper Sorbet typings won’t be caught by the pipeline unless they’re modified. Once someone touches such a file, it becomes a requirement to fully type it, with the goal of gradually achieving complete Sorbet coverage.

If you're able to add the Sorbet typings here, that would be great. But if it feels like too much, @randhircs can help with that. Thanks again for your contribution!

@randhircs — You might be able to help here. Also, if you're planning to push additional commits, please avoid force-pushing, as we’d like to retain @dnlfm’s original commit.

@dnlfm
Copy link
Contributor Author

dnlfm commented Jul 29, 2025

@dnlfm Again now, I am checking by rebasing it to see if all specs are good. i feel that you may like to fix the sorbet issue.

Hi @randhircs, I see "Sorbet" was added to this project but not really added to the files, i.e. not completely rolled out it seems. For example,

Checking updater/lib/dependabot/file_fetcher_command.rb for Sorbet typing...
No Sorbet typing found at the top of updater/lib/dependabot/file_fetcher_command.rb

The file file_fetcher_command.rb wasn't added by me, and it contains this error for Sorbet typing. I would like you to check that, as it is something that was not added in this PR. Another PR that I saw where Sorbet is failing but didn't add the file is: #12589 where the file uv/lib/dependabot/uv/file_fetcher.rb originally didn't have the Sorbet typing, confirming that it is something in the project that wasn't rolled out well.
I would like to also ask you to remove the need of Sorbet typing in test files, as I added # typed: ignore, it is still requiring to use strict or strong, but again, it doesn't make sense to have it in test files.
I would prefer to not have to check these Sorbet issues by myself.

@dnlfm — We actually added full Sorbet type checks later on. However, files without proper Sorbet typings won’t be caught by the pipeline unless they’re modified. Once someone touches such a file, it becomes a requirement to fully type it, with the goal of gradually achieving complete Sorbet coverage.

If you're able to add the Sorbet typings here, that would be great. But if it feels like too much, @randhircs can help with that. Thanks again for your contribution!

@randhircs — You might be able to help here. Also, if you're planning to push additional commits, please avoid force-pushing, as we’d like to retain @dnlfm’s original commit.

Hi @kbukum1,

Thank you for your response.

it becomes a requirement to fully type it, with the goal of gradually achieving complete Sorbet coverage

I suspected that could be the case, but I would encourage a different approach: I would suggest that the team responsible for adding Sorbet could map the files that they need to go through and address each one of them, let's say, 40 files a week, prioritizing the ones in PRs that are already open. This way, PRs will have isolated changes, i.e. the PRs won't be touching something that is not meaningful to their changes, and thus making the code review process better.

Also, I would really appreciate if a code review is done on what I have done. I looked at my PR once again today, and I started wondering if what I have done will work for all kind of repositories or if there is something missing, for instance:

  • I added the exclusion logic to _fetch_repo_contents and _cloned_repo_contents, covering the flow for repo_contents in the Base implementation of a FileFetcher. However, I noticed that the FileFetcher implementations also implements their own fetch_files.
    I'm not very familiar with the whole flow, but I assumed that they would use repo_contents at some point and I believe it may cover what we want to achieve with these changes. But maybe someone with more knowledge of the codebase or that is able to make a E2E test can tell me if there's any issue or something else missing, and then we can continue from there. Thanks in advance!

@randhircs randhircs moved this from Scoping to In Progress in Dependabot Jul 29, 2025
@AbhishekBhaskar
Copy link
Contributor

@dnlfm, Also, we are planning on releasing this as a new feature. With regards to this, we would need to add a feature flag which when enabled, these changes would be in effect. I will be creating the feature flag shortly. Please let me know if you prefer adding the feature flag, which I can share with you, in the code or I can push those changes myself to the same PR. Thanks!

@dnlfm
Copy link
Contributor Author

dnlfm commented Aug 6, 2025

@dnlfm, Also, we are planning on releasing this as a new feature. With regards to this, we would need to add a feature flag which when enabled, these changes would be in effect. I will be creating the feature flag shortly. Please let me know if you prefer adding the feature flag, which I can share with you, in the code or I can push those changes myself to the same PR. Thanks!

Hi @AbhishekBhaskar, that's great and thank you for asking! Please feel free to push the changes directly to this PR.

@dnlfm
Copy link
Contributor Author

dnlfm commented Aug 6, 2025

@dnlfm We have provided fix for sorbet. You may like to resolve the conflict.

Thank you, @randhircs, fixed it.

@mtrackeros
Copy link

This PR adds the possibility of specifying exclude-paths in dependabot.yml.

It's a very old issue, and I decided to give a first stab: #4364

End-to-end tests may be required to validate the solution. Unit tests are in place.

Example of dependabot.yml with the new option:

version: 2
updates:
  - package-ecosystem: "npm_and_yarn"
    directory: "/"
    schedule:
      interval: "daily"
    exclude-paths:
      - "src/test/assets"
      - "vendor/**"
      - "src/*.rb"
      - "src/test/helper.rb"

Copy link
Contributor

@randhircs randhircs left a comment

Choose a reason for hiding this comment

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

LGTM.

@linked_paths = T.let({}, T::Hash[T.untyped, T.untyped])
@submodules = T.let([], T::Array[T.untyped])
@options = options

@files = T.let([], T::Array[DependencyFile])
end

# rubocop:disable Style/TrivialAccessors
Copy link
Contributor

Choose a reason for hiding this comment

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

Please avoid using disabling rubocop.

Copy link
Contributor

Choose a reason for hiding this comment

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

@AbhishekBhaskar Could you try removing the RuboCop:disable

@@ -453,14 +462,18 @@ def codecommit_client
params(path: String, fetch_submodules: T::Boolean, raise_errors: T::Boolean)
.returns(T::Array[OpenStruct])
end
def _fetch_repo_contents(path, fetch_submodules: false,
raise_errors: true)
def _fetch_repo_contents(path, fetch_submodules: false, raise_errors: true) # rubocop:disable Metrics/PerceivedComplexity
Copy link
Contributor

Choose a reason for hiding this comment

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

You may create new method and remove this # rubocop:disable.

@@ -541,6 +554,66 @@ def _cloned_repo_contents(relative_path)
size: 0 # NOTE: added for parity with github contents API
)
end
if Dependabot::Experiments.enabled?(:enable_exclude_paths_subdirectory_manifest_files)
Copy link
Contributor

Choose a reason for hiding this comment

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

Try to split method to limit the method size.

@AbhishekBhaskar AbhishekBhaskar merged commit 1b5d971 into dependabot:main Aug 13, 2025
126 of 127 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Dependabot Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L: github:actions GitHub Actions L: java:gradle Maven packages via Gradle
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants