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

Remove Bundler v1 Code and Related Feature Flags #10775

Closed
wants to merge 36 commits into from

Conversation

kbukum1
Copy link
Contributor

@kbukum1 kbukum1 commented Oct 10, 2024

What are you trying to accomplish?

This PR removes all Bundler v1-specific code and deprecation feature flags (add_deprecation_warn_to_pr_message and bundler_v1_unsupported_error) as part of deprecating support for Bundler v1. This cleanup ensures that Dependabot exclusively supports Bundler v2 and higher versions moving forward, aligning with recent changes to our package manager structure.

Anything you want to highlight for special attention from reviewers?

Given the scope of changes, particularly removing legacy Bundler v1 feature flags and related code, this update may impact areas previously conditional on Bundler version checks. I chose to remove the v1-related code and feature flags in favor of a streamlined v2-only approach to simplify the codebase and prevent potential misconfigurations.

When reviewing this PR, please note that although there are changes in over 379 files, the substantial updates are limited to around 60 files. There's no need to go through each file in the following folders, as we are entirely removing Bundler v1 and have comprehensive tests in place for Bundler v2 functionality:

  • bundler/helpers/v1
  • bundler/spec/fixtures/projects/bundler1

How will you know you've accomplished your goal?

  • I will verify that all instances of Bundler v1-related code and feature flags are removed and that Bundler v2 is the only supported version.
  • Testing will confirm that attempts to use Bundler v1 configurations result in expected errors, reinforcing Bundler v2 support.

Checklist

  • I have run the complete test suite to ensure all tests and linters pass.
  • I have thoroughly tested my code changes to ensure they work as expected, including adding additional tests for new functionality.
  • I have written clear and descriptive commit messages.
  • I have provided a detailed description of the changes in the pull request, including the problem it addresses, how it fixes the problem, and any relevant details about the implementation.
  • I have ensured that the code is well-documented and easy to understand.

@github-actions github-actions bot added the L: ruby:bundler RubyGems via bundler label Oct 10, 2024
@abdulapopoola
Copy link
Member

I think we should rename the v2 folder too but that can be a follow up PR

@abdulapopoola
Copy link
Member

Do we have plans for smoke tests removal and all that too?

@@ -11,7 +11,7 @@ function print_usage() {
function handle_args() {
export SUITE_NAME=$1
case $SUITE_NAME in
bundler1 | bundler2)
Copy link
Member

Choose a reason for hiding this comment

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

do we still need the "in" check or can we simplify some more?

Copy link
Contributor Author

@kbukum1 kbukum1 Oct 11, 2024

Choose a reason for hiding this comment

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

I think we can keep that since in future we may also add bundler v3 in case. I tried to keep the syntax of supporting multiple as it is just currently we have one version, v2 now.

Copy link
Member

@jeffwidman jeffwidman Oct 11, 2024

Choose a reason for hiding this comment

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

While it's okay to keep it, I also suspect realistically bundler v3 is very unlikely to ship for a long, long time... if so, it might be simpler to just streamline entirely to remove confusion for developers who wonder "why is this?"... at the very least you'd want a code comment of:

in used here in case bundler v3 ever ships...

btw, @deivid-rodriguez any input on how long it might be til we see bundler v3?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, not really.

Copy link
Contributor Author

@kbukum1 kbukum1 Oct 11, 2024

Choose a reason for hiding this comment

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

The condition is removed and it is simplified.

@@ -35,9 +35,6 @@ def deprecated?

sig { override.returns(T::Boolean) }
def unsupported?
# Check if the feature flag for Bundler v1 unsupported error is enabled.
return false unless Dependabot::Experiments.enabled?(:bundler_v1_unsupported_error)
Copy link
Member

Choose a reason for hiding this comment

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

let's make sure to remove the flag everywhere too :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, actually I am removing from everywhere and not only unsupported but deprecation flag as well. We are done now checking last issues. After core is done, I will also remove them feature flags from dependabot-api as well.

  • add_deprecation_warn_to_pr_message
  • bundler_v1_unsupported_error

Copy link
Contributor Author

@kbukum1 kbukum1 Oct 11, 2024

Choose a reason for hiding this comment

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

The PR is created to remove from dependabot-api.

PR: dependabot-api#5816

@kbukum1 kbukum1 marked this pull request as ready for review October 11, 2024 02:45
@kbukum1 kbukum1 requested a review from a team as a code owner October 11, 2024 02:45
@kbukum1
Copy link
Contributor Author

kbukum1 commented Oct 11, 2024

Do we have plans for smoke tests removal and all that too?

I think we don't need to do anything on smoke tests but I need to check later. We have simple removal job on dependabot-api for feature flags.

@kbukum1 kbukum1 force-pushed the kamil/remove_unsupporter_bundler_v1_related_code branch 2 times, most recently from 21290bf to caab60b Compare October 11, 2024 20:44
else
Dependabot.logger.info("Nothing to update for Dependency Group: '#{group.name}'")
end

dependency_change
rescue ToolVersionNotSupported => e
error_handler.handle_job_error(error: e, dependency_group: group)
nil
Copy link
Contributor Author

@kbukum1 kbukum1 Oct 14, 2024

Choose a reason for hiding this comment

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

When we have unsupported error for any package manager, we are going to stop the group update and handle not supported error.

if target_dependencies.empty?
record_security_update_dependency_not_found
else
target_dependencies.each { |dep| check_and_create_pr_with_error_handling(dep) }
end
rescue StandardError => e
error_handler.handle_dependency_error(error: e, dependency: target_dependencies&.first)
end
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When we have unsupported error for the package manager, we don't want to go over each dependency, instead we want to raise unsupported error for the whole process and handle error properly.

sig { params(group: Dependabot::DependencyGroup).returns(T.nilable(Dependabot::DependencyChange)) }
def compile_all_dependency_changes_for(group)
prepare_workspace

# Raise an error if the package manager version is unsupported
dependency_snapshot.package_manager&.raise_if_unsupported!
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When we have unsupported error for any package manager in the group, we are going to raise error before stating update process.

@@ -118,6 +118,8 @@ def perform # rubocop:disable Metrics/AbcSize

upsert_pull_request_with_error_handling(T.must(dependency_change), job_group)
end
rescue ToolVersionNotSupported => e
error_handler.handle_job_error(error: e, dependency_group: job_group)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When we have unsupported error for any package manager, we are going to stop the group update and handle not supported error.

# Retrieve the list of initial notices from dependency snapshot
@notices = dependency_snapshot.notices
# More notices can be added during the update process

dependencies.each { |dep| check_and_create_pr_with_error_handling(dep) }
rescue StandardError => e
error_handler.handle_dependency_error(error: e, dependency: dependencies.last)
end
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When we have unsupported error for the package manager, we don't want to go over each dependency, instead we want to raise unsupported error for the whole process and handle error properly.

@@ -52,11 +52,16 @@ def perform
Dependabot.logger.info("Starting update job for #{job.source.repo}")
Dependabot.logger.info("Checking all dependencies for version updates...")

# Raise an error if the package manager version is unsupported
dependency_snapshot.package_manager&.raise_if_unsupported!
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When we have unsupported error for the package manager, we don't want to go over each dependency, instead we want to raise unsupported error for the whole process and handle error properly.

target_dependencies = dependency_snapshot.job_dependencies

# Raise an error if the package manager version is unsupported
dependency_snapshot.package_manager&.raise_if_unsupported!
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When we have unsupported error for the package manager, we don't want to go over each dependency, instead we want to raise unsupported error for the whole process and handle error properly.

Copy link
Member

Choose a reason for hiding this comment

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

It would be simpler to not modify these operations, and have DependencySnapshot::dependency_file_parser raise an error right when we calculate the "package_manager".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the problem is we are not catching errors on top of the operations. So when I do that I also need to error handling. I will check the feasibility of that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jakecoffman ,

is it ok to do that after cleaning-up the code. I think this will also need some tests and also after adding it to the DependencySnapshot::dependency_file_parser I need check error handling mechanism for this code the place where is called and handle error properly. Otherwise it is turning to unknown error.

Copy link
Member

Choose a reason for hiding this comment

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

Just for posterity I raised a PR #10794 which is what I was suggesting.

dependency = dependencies.last

# Raise an error if the package manager version is unsupported
dependency_snapshot.package_manager&.raise_if_unsupported!
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When we have unsupported error for the package manager, we don't want to go over each dependency, instead we want to raise unsupported error for the whole process and handle error properly.

Copy link
Contributor

@deivid-rodriguez deivid-rodriguez left a comment

Choose a reason for hiding this comment

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

Thanks for doing this!

@kbukum1
Copy link
Contributor Author

kbukum1 commented Oct 14, 2024

Thanks for doing this!

Thank you for your support and feedback!

@kbukum1 kbukum1 force-pushed the kamil/remove_unsupporter_bundler_v1_related_code branch from 9c056ff to b78c977 Compare October 14, 2024 22:49
Copy link
Member

@jakecoffman jakecoffman left a comment

Choose a reason for hiding this comment

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

I think this PR is difficult to review as it's doing two things:

  • Adding support for deprecating an ecosystem to the updater code
  • Deprecating and deleting bundler v1

target_dependencies = dependency_snapshot.job_dependencies

# Raise an error if the package manager version is unsupported
dependency_snapshot.package_manager&.raise_if_unsupported!
Copy link
Member

Choose a reason for hiding this comment

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

It would be simpler to not modify these operations, and have DependencySnapshot::dependency_file_parser raise an error right when we calculate the "package_manager".

@kbukum1
Copy link
Contributor Author

kbukum1 commented Oct 15, 2024

We are splitting PR in multiple PRs. We created a new PR for moving unsupporting error at the top of update operations.

@kbukum1
Copy link
Contributor Author

kbukum1 commented Oct 16, 2024

@kbukum1 kbukum1 closed this Oct 16, 2024
@kbukum1 kbukum1 deleted the kamil/remove_unsupporter_bundler_v1_related_code branch October 21, 2024 20:32
@kbukum1 kbukum1 self-assigned this Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants