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

Improve development experience #410

Merged
merged 5 commits into from Oct 9, 2023
Merged

Conversation

tamird
Copy link
Contributor

@tamird tamird commented Oct 2, 2023

See individual commits.

@tamird tamird force-pushed the workspace branch 7 times, most recently from bffefba to 1d6a879 Compare October 2, 2023 16:11
@mitsuhiko
Copy link
Owner

I'm not entirely opposed to this change, but in the past I decided intentionally against it so I can end up with different .lock files for insta and cargo-insta due to different MSRV support.

@max-sixty
Copy link
Sponsor Contributor

end up with different .lock files for insta and cargo-insta due to different MSRV support.

FWIW for dependencies that are only part of cargo-insta, having the crates as a workspace won't affect MSRVs. We do this in PRQL, where the CLI can be on latest but the library follows debian.

(but maybe the dependencies are overlapping...)

I do think a workspace is a much nicer development experience.

@tamird
Copy link
Contributor Author

tamird commented Oct 7, 2023

@mitsuhiko I don't quite understand the concern. Wouldn't the .lock file only be published for cargo-insta, not for insta? That's my understanding of the usual convention.

@max-sixty
Copy link
Sponsor Contributor

@mitsuhiko I don't quite understand the concern. Wouldn't the .lock file only be published for cargo-insta, not for insta? That's my understanding of the usual convention.

There is only a single Cargo.lock file for a workspace. Unless I'm really mistaken — currently the cargo-insta/Cargo.lock file does nothing. And we should remove it.

@tamird
Copy link
Contributor Author

tamird commented Oct 7, 2023

That's right. I removed it. But my point was that the Cargo.lock should not be published with the insta library, only the cargo-insta CLI.

@tamird tamird force-pushed the workspace branch 4 times, most recently from cdfd93e to 3d2be4e Compare October 7, 2023 21:38
@tamird
Copy link
Contributor Author

tamird commented Oct 7, 2023

Ah, I see what you mean now. Indeed this change means that the versioning restrictions that apply to insta will also apply to cargo-insta.

@tamird
Copy link
Contributor Author

tamird commented Oct 7, 2023

Ugh, this changed the current directory when the integration tests run, and they are not resilient to this. I'll wait for #412 to land first.

@max-sixty
Copy link
Sponsor Contributor

Ah, I see what you mean now. Indeed this change means that the versioning restrictions that apply to insta will also apply to cargo-insta.

Yes cool. Still a big fan of the change!

Do you think we can still get 1.61 tests to pass?

@tamird
Copy link
Contributor Author

tamird commented Oct 7, 2023

Yeah, they were passing before I split out #412.

@mitsuhiko
Copy link
Owner

FWIW I would prefer a workspace as well. I think the way it could be accomplished might be with manually maintaining a secondary Cargo.lock file and move it over in the tests. I am doing something similar for a Cargo.lock.msrv file in some libraries. Eg.: https://github.com/mitsuhiko/similar

@max-sixty
Copy link
Sponsor Contributor

Re the MSRV — FWIW in PRQL we use cargo msrv verify in our CI, which verifies that that the package is valid with its specified MSRV (e.g. here).

It allows different MSRVs by crate.

Relative to maintaining another Cargo.lock.msrv, it requires another dev dependency, but it has worked quite well for us over the past year.

@tamird
Copy link
Contributor Author

tamird commented Oct 9, 2023

Alright I've abandoned the virtual manifest for now. Instead I added cargo-insta and its integration tests to the root manifest workspace.

@tamird
Copy link
Contributor Author

tamird commented Oct 9, 2023

Re the MSRV — FWIW in PRQL we use cargo msrv verify in our CI, which verifies that that the package is valid with its specified MSRV (e.g. here).

It allows different MSRVs by crate.

Relative to maintaining another Cargo.lock.msrv, it requires another dev dependency, but it has worked quite well for us over the past year.

That won't work here because MSRV is 1.51 but the tests also need to run against 1.61.

@mitsuhiko I did what you suggested with Cargo.lock.msrv.

@tamird
Copy link
Contributor Author

tamird commented Oct 9, 2023

At long last this is green.

Clarify that `cargo insta test` is expected to produce a change in the
snaphots.
This allows IDE integration to work when the root of the repository is
opened. Prior to this change, a developer would have to open cargo-insta
to get code completion for that crate.

This also causes clippy to run on all crates, so this commit fixes a few
lints.

The integration-tests crate's test is changed to a proper test function
so that it can rely on always being run from the root of the
integration-tests crate. Care is taken to remove the tests directory
after running to avoid pollution in which `cargo test` attempts to run
those tests.
@mitsuhiko
Copy link
Owner

I'm inclined to merge this (thus the approval). One thing I still need to figure out is if the cargo-insta installation with lockfile continues to work as intended. In particular I'm not sure if cargo publish is clever enough to publish a rewritten version of the workspace lock with the package.

@mitsuhiko mitsuhiko merged commit 452fdc4 into mitsuhiko:master Oct 9, 2023
6 checks passed
@mitsuhiko
Copy link
Owner

Validated: the lock file is handled correctly by cargo package.

@tamird tamird deleted the workspace branch October 9, 2023 21:12
@max-sixty
Copy link
Sponsor Contributor

That won't work here because MSRV is 1.51 but the tests also need to run against 1.61.

FYI this isn't how cargo msrv works — check out the PRQL workflows if you're interested to learn more.

Thanks for this PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants