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

cargo-marker: add git support #126

Merged
merged 1 commit into from
May 7, 2023
Merged

Conversation

Niki4tap
Copy link
Member

@Niki4tap Niki4tap commented Apr 20, 2023

Its been a while since I've worked on this, but I've finally took the time to finish it.

This PR adds git support to marker so this now works:

[workspace.metadata.marker.lints]
marker_lints = { git = "https://github.com/rust-marker/marker" }

It makes use of cargo_fetch library which I made for this specific use-case, which is essentially just a thin wrapper around cargo library (so the builds are now way slower :p).

I'll try to maintain the library to my best capacity, and prioritize marker's goals whenever needed.

Addition of the library also technically allows for any kind of package to be downloaded, so this also technically supports registries, though this PR does not implement it, because this is blocked on marker APIs being released.


In total this checks out... *looks up the issue*... one task from #81!
But also technically closes #87 whenever APIs are published.

review side note: most changes are from Cargo.lock

@Niki4tap Niki4tap requested a review from xFrednet April 20, 2023 19:52
@Niki4tap Niki4tap added C-enhancement Category: New feature or request A-marker-cargo Area: All things connected to `cargo_marker` S-waiting-on-review Status: Awaiting review labels Apr 20, 2023
@xFrednet
Copy link
Member

This is awesome, I was super happy when I saw the notification! I haven't taken a look at it yet, I'll do so next week :)

@xFrednet
Copy link
Member

It makes use of cargo_fetch library which I made for this specific use-case

That is super cool! I'm not 100% sure if git dependencies work for crates we want to push to crates.io. But if that becomes a problem, we could move it to here or publish it. Let me know if you need any help with the maintenance!

@Niki4tap
Copy link
Member Author

That is super cool! I'm not 100% sure if git dependencies work for crates we want to push to crates.io

Oh I know, that's why I've published it ;)

Copy link
Member

@xFrednet xFrednet left a comment

Choose a reason for hiding this comment

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

I'm honestly impressed. Thank you very much for all the work you put into this, even making a new library. This is so much more than I hoped!

I still want to do some small tests before merging it, but currently everything looks, awesome!

Btw, do you have a lint/repo, that you tested this implementation with? Otherwise, I might look into adding a repo to rust-marker and hacking a test together :)

@xFrednet
Copy link
Member

Btw, let's make sure it runs everywhere:

bors try

bors bot added a commit that referenced this pull request Apr 25, 2023
@bors
Copy link
Contributor

bors bot commented Apr 25, 2023

@Niki4tap
Copy link
Member Author

Btw, do you have a lint/repo, that you tested this implementation with? Otherwise, I might look into adding a repo to rust-marker and hacking a test together :)

Yeah some tests would be great, but yes, I've tested locally with the marker repo itself, you can just do:

[workspace.metadata.marker.lints]
marker_lints = { git = "https://github.com/rust-marker/marker" }

in the Cargo.toml, and it should fetch the test lints from the repo

@xFrednet
Copy link
Member

xFrednet commented May 5, 2023

Hey, I finally found some time to test this. Sorry, for my inactivity. My semester will end in about one month and then I'll have more time, also to (hopefully) make the final push for v0.0.1.

Anyways, I see what you mean, that the compile time increased significantly. In the future, I would be in favor of having such a functionality in Cargo itself, there is already an issue for that. However, in the meantime, this is the best solution I can think of, and I'm really grateful that you created the library ❤️


Now, related to testing:

I've reserved the marker_lint_crate_test crate name and would like to later include a fetch test for both git and crates.io in the CI. However, having a test crate for that (besides marker_lints) sounds a bit painful, until we have a working template and an idea of the stable API. AKA v0.0.1. I crated #127 to create a template create we can use for testing, once we reach that point. Until then, I think we should merge this without CI tests.

I've tested the implementation locally. The git fetching works 🎉 However, the normal path dependency:

[workspace.metadata.marker.lints]
marker_lints = { path = "marker_lints" }

is sadly broken. I get the following error when running cargo dogfood on this branch. (Without any further modifications)

$ c clean
# (Yes, I have an alias cargo, and I can highly recommend it xD)
$ c dogfood
   Compiling proc-macro2 v1.0.49
   [..]
   Compiling cargo_marker v0.1.0 (./marker/cargo-marker)
    Finished dev [unoptimized + debuginfo] target(s) in 59.85s
     Running `target/debug/cargo-marker --forward-rust-flags`
Compiling rustc driver
   Compiling proc-macro2 v1.0.49
   [...]
   Compiling marker_driver_rustc v0.1.0 (./marker/marker_driver_rustc)
    Finished dev [unoptimized + debuginfo] target(s) in 7.38s

Compiling Lints:
Failed fetching lint crates: invalid path url `marker_lints`
Error: LintCrateFetchFailed

Could you take a look at this? :) Once that is fixed, the PR is ready to be merged.

@xFrednet xFrednet self-assigned this May 5, 2023
@Niki4tap
Copy link
Member Author

Niki4tap commented May 5, 2023

Hey, I finally found some time to test this. Sorry, for my inactivity.

No problem, I'm not rushing, I have other things to deal with myself.

Anyways, I see what you mean, that the compile time increased significantly. In the future, I would be in favor of having such a functionality in Cargo itself, there is already an issue for that.

Yeah the library seems like a hacky solution, and I would like to see it in the cargo too, but this works for now :p

However, the normal path dependency is sadly broken.

Nice catch, funny enough it was a typo (PackageSource::Path the enum variant vs PackageSource::path the helper method), rust may protect you from memory errors, but not from typos I guess 😄

Everything should be good now I think

Copy link
Member

@xFrednet xFrednet left a comment

Choose a reason for hiding this comment

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

Alright, this version looks good to me. Thank you!!!

bors r+

bors bot added a commit that referenced this pull request May 7, 2023
126: cargo-marker: add git support r=xFrednet a=Niki4tap

Its been a while since I've worked on this, but I've finally took the time to finish it.

This PR adds git support to marker so this now works:
```toml
[workspace.metadata.marker.lints]
marker_lints = { git = "https://github.com/rust-marker/marker" }
```

It makes use of [`cargo_fetch`](https://github.com/Niki4tap/cargo_fetch) library which I made for this specific use-case, which is essentially just a thin wrapper around `cargo` library (so the builds are now way slower :p).

I'll try to maintain the library to my best capacity, and prioritize marker's goals whenever needed.

Addition of the library also technically allows for any kind of package to be downloaded, so this also *technically* supports registries, though this PR does not implement it, because this is blocked on marker APIs being released.

---

In total this checks out... *\*looks up the issue\**... one task from #81!
But also *technically* closes <!-- do not close this issue github please --> #87 whenever APIs are published.

review side note: most changes are from `Cargo.lock`

Co-authored-by: Niki4tap <rombiklol2@gmail.com>
@bors
Copy link
Contributor

bors bot commented May 7, 2023

This PR was included in a batch that successfully built, but then failed to merge into master. It will not be retried.

Additional information:

Response status code: 422
{"message":"Validation Failed","documentation_url":"https://docs.github.com/articles/about-protected-branches"}

@xFrednet
Copy link
Member

xFrednet commented May 7, 2023

Looks like my tests with merge queues broke bors 😅

Now it should work again

bors r+

@bors
Copy link
Contributor

bors bot commented May 7, 2023

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot merged commit bb02eb1 into rust-marker:master May 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-marker-cargo Area: All things connected to `cargo_marker` C-enhancement Category: New feature or request S-waiting-on-review Status: Awaiting review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants