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

Reimplement support retrieving workspace of path dependencies in cargo #10629

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Jefffrey
Copy link
Contributor

@Jefffrey Jefffrey commented Sep 18, 2024

What are you trying to accomplish?

Reattempting #10550 after it was reverted in #10599 due to regression, see #10584

Anything you want to highlight for special attention from reviewers?

Changes are largely the same as #10550, with some changes:

How will you know you've accomplished your goal?

Unit tests passed. Also ran dry run against the repos that were listed as affected in #10584

bin/dry-run.rb cargo divviup/janus
bin/dry-run.rb cargo servo/servo

Both executed successfully.

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.

@Jefffrey Jefffrey requested a review from a team as a code owner September 18, 2024 12:15
@github-actions github-actions bot added the L: rust:cargo Rust crates via cargo label Sep 18, 2024
Copy link
Contributor Author

@Jefffrey Jefffrey left a comment

Choose a reason for hiding this comment

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

return nil
end

parent_dirs = current_dir.scan("/").length
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Previously did current_dir.scan("/").length - 1 here which was root cause of error that caused regression, fixed to not do this subtraction

Comment on lines +257 to +258
# To avoid accidentally breaking backward compatibility, we don't throw errors
return nil
Copy link
Contributor Author

Choose a reason for hiding this comment

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

To avoid any other regressions, relax this to not throw error

Comment on lines +276 to +277
# To avoid accidentally breaking backward compatibility, we don't throw errors
nil
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here too

Comment on lines +746 to +779
context "with a workspace root containing a path dependency to a member" do
before do
stub_request(:get, url + "?ref=sha")
.with(headers: { "Authorization" => "token token" })
.to_return(
status: 200,
body: fixture("github", "contents_cargo_without_lockfile.json"),
headers: json_header
)
stub_request(:get, url + "Cargo.toml?ref=sha")
.with(headers: { "Authorization" => "token token" })
.to_return(
status: 200,
body: fixture("github", "path_dependency_in_workspace_root",
"contents_cargo_manifest_workspace.json"),
headers: json_header
)
stub_request(:get, url + "child/Cargo.toml?ref=sha")
.with(headers: { "Authorization" => "token token" })
.to_return(
status: 200,
body: fixture("github", "path_dependency_in_workspace_root",
"contents_cargo_manifest_child.json"),
headers: json_header
)
end

it "fetches the dependencies successfully" do
expect(file_fetcher_instance.files.map(&:name))
.to match_array(%w(.cargo/config.toml Cargo.toml child/Cargo.toml))
expect(file_fetcher_instance.files.map(&:path))
.to match_array(%w(/.cargo/config.toml /Cargo.toml /child/Cargo.toml))
end
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.

Based on https://github.com/Jefffrey/dependabot-cargo-test-2

Where the scenario is having a workspace, where in the workspace root it specifies members via path dependencies. Looks like this test case was absent before, so adding to prevent further regressions

@abdulapopoola
Copy link
Member

Thanks @Jefffrey , we'll try to get this tested and merged on our end

@kbukum1 kbukum1 self-requested a review January 9, 2025 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L: rust:cargo Rust crates via cargo
Projects
Status: Ready
Development

Successfully merging this pull request may close these issues.

2 participants