Skip to content

Make gix crates ready for automatic cfg checking #1123

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
merged 6 commits into from
Nov 19, 2023

Conversation

Urgau
Copy link
Contributor

@Urgau Urgau commented Nov 19, 2023

This PR makes the necessary changes to make gitoxide crates ready for -Zcheck-cfg (automatic cfgs checking) being enabled by default.

  • It first removes all the --cfg docsrs and #[cfg_attr(docsrs, ...)] which are an anti-pattern and simply use the already existing feature document-features.
  • It also add a missing serde feature in gix-fs and remove a dead code from the now non-existing lean-cli feature.
  • I also added the async-io feature to gix-packetline-blocking since being a symlink to gix-packetline it needs to have all the feature of the former.
    Maybe instead of adding the async-io feature we could allow the lint for gix-packetline-blocking?
  • And finally it adds a new CI job lint-nightly to run nightly tools, in particular cargo check -Zcheck-cfg.

@Urgau
Copy link
Contributor Author

Urgau commented Nov 19, 2023

The CI failures are related to some new clippy lints and the nightly feature activation being now tied to an actual feature making them fail with --all-features.

Let me know how you want to proceed?
One "hack" I see could be to only make the nightly feature activation on when documenting, ie doc cfg.

@Byron
Copy link
Member

Byron commented Nov 19, 2023

Thanks a lot for contributing the preparation for the upcoming check-cfg feature 🙏🎉!

  • I also added the async-io feature to gix-packetline-blocking since being a symlink to gix-packetline it needs to have all the feature of the former.
    Maybe instead of adding the async-io feature we could allow the lint for gix-packetline-blocking?

This whole crate is a hack, unfortunately, so that there is a blocking version of the crate that can be used internally, without having the overhead of a real copy. Thus, I don't think one should add anything else to it - it fulfils its purpose and ideally won't be used. I hope that once there are new async-related features, it can be removed entirely. Or in other words, gitoxide currently has a couple of non-additive feature-flags around async-support and this will be a problem for all the usual reason. It desperately needs to be made so sync and async can both be managed without duplicating everything, and we are not there yet.

  • And finally it adds a new CI job lint-nightly to run nightly tools, in particular cargo check -Zcheck-cfg.

It's a very nice gesture, but I think if it should be useful it needs to be made so it can't actually fail a build. Ideally, it provides a preview of what's to come, but I can't have failures on a daily basis because new lint was added. Right now, I see this every 6 weeks or so when a new stable release trickles down, and that seems good enough.

One "hack" I see could be to only make the nightly feature activation on when documenting, ie doc cfg.

Everything you think would work also works for me. There is just this one requirement that docs.rs still needs to be able to build these crates,

@Urgau
Copy link
Contributor Author

Urgau commented Nov 19, 2023

Regarding the changes to gix-packetline-blocking. Should I remove them? They currently result in 20ish warnings.

  • And finally it adds a new CI job lint-nightly to run nightly tools, in particular cargo check -Zcheck-cfg.

It's a very nice gesture, but I think if it should be useful it needs to be made so it can't actually fail a build. Ideally, it provides a preview of what's to come, but I can't have failures on a daily basis because new lint was added. Right now, I see this every 6 weeks or so when a new stable release trickles down, and that seems good enough.

Completely agree, it's unreasonable to expect someone to block on nightly. My idea is to run the job as normal but to mark it as not failling, that's why I added continue-on-error: true to the job so that it doesn't fail but that didn't work out.

Changed to if: '!cancelled() to always run every steps. Seems now I need a way to not mark it as failing the whole workflow.

One "hack" I see could be to only make the nightly feature activation on when documenting, ie doc cfg.

Everything you think would work also works for me. There is just this one requirement that docs.rs still needs to be able to build these crates,

Seems to work and it-fact it was even used before, so.

@Byron
Copy link
Member

Byron commented Nov 19, 2023

Completely agree, it's unreasonable to expect someone to block on nightly. My idea is to run the job as normal but to mark it as not failling, that's why I added continue-on-error: true to the job so that it doesn't fail but that didn't work out.

Changed to if: '!cancelled() to always run every steps. Seems now I need a way to not mark it as failing the whole workflow.

Let's remove nightly, it's clean and will definitely work. It's also only tangentially related to this PR, so I think it's the right thing to do.

I will probably just do that myself before merging, so nothing left to be done here.

Thanks again for your help, it's much appreciated!

And even if it was advisory only, what good does it do if nobody looks
at it? And I know myself :D.
@@ -12,8 +12,13 @@ include = ["src/**/*", "LICENSE-*"]
[lib]
doctest = false

[features]
Copy link
Member

Choose a reason for hiding this comment

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

A great catch, thank you!

@epage
Copy link
Contributor

epage commented Dec 1, 2023

It first removes all the --cfg docsrs and #[cfg_attr(docsrs, ...)] which are an anti-pattern and simply use the already existing feature document-features.

According to whom is it an anti-pattern? I've not seen any talk of that and found it much better than using features.

@Urgau
Copy link
Contributor Author

Urgau commented Dec 1, 2023

It first removes all the --cfg docsrs and #[cfg_attr(docsrs, ...)] which are an anti-pattern and simply use the already existing feature document-features.

According to whom is it an anti-pattern? I've not seen any talk of that and found it much better than using features.

I meant that with check-cfg+Cargo it's a bit of "anti-pattern" since enabling the docsrs cfg (or any custom cfg) is not free and easy, since it requires a build.rs with cargo:rustc-check-cfg.

@epage
Copy link
Contributor

epage commented Dec 1, 2023

Its not sufficient with build.rs because that will produce the warning as well.

I wouldn't classify that as an anti-pattern but a relevant use case for us to consider.

EliahKagan added a commit to EliahKagan/gitoxide that referenced this pull request Apr 7, 2025
This adds a `futures-lite` feature to `gix-packetline-blocking`.

The new feature is undocumented except for the warning not to use
it. It does nothing, and its purpose is to support an existing
internal use of `gix-packetline-blocking` through an alias named
`gix-packetline`.

This new feature should never be used except to keep `cargo check`
commands with `--workspace` that list `gix-packetline/futures-lite`
from failing due to the absent feature. Such `cargo check` commands
are rare and `cargo check` should not typically be used this way.
But RustRover automatically composes and runs such a command. This
fixes a RustRover project discovery breakage commented on in GitoxideLabs#1929.

This "ghost feature" may be removed without warning. Nothing should
rely on it in production or otherwise in a significant way. It is a
bug for any software to break or change behavior if it is removed.

This addition is similar to the addition in be4de0d (GitoxideLabs#1123) of the
`async-io` feature of `gix-packetline-blocking`, which likewise
shouldn't be used. However, `gix-packetline-blocking/futures-lite`
is even less elegant than `gix-packetline-blocking/async-io`,
since `gix-packetline` doesn't explicitly delcare a `futures-lite`
feature. Instead, we currrently don't use `dep:` for `futures-lite`
because it breaks `cargo-auditable` (GitoxideLabs#1929).
EliahKagan added a commit to EliahKagan/gitoxide that referenced this pull request Apr 8, 2025
This removes the `gix-packetline-blocking/futures-lite` "ghost
feature" added in the previous commit, and instead changes
`gix-filter` so that it depends on `gix-packetline-blocking`
without aliasing it `gix-packetline`, instead replacing each use of
`gix_packetline` with `gix_packetline_blocking` in the code of
`gix-filter`.

The long-standing `gix-packetline-blocking/async-io` feature added
in be4de0d (GitoxideLabs#1123), though it should not be used, is *not* removed.
This is because it is referenced in attributes in the code of
`gix-packetline-blocking` (because `gix-packetline-blocking/src` is
copied from `gix-packetline/src` via `etc/copy-packetline.sh`). So
removing it would cause the `clippy` run in the CI `lint` job to
fail, as well as likely causing various other reasonable operations
to fail.
EliahKagan added a commit to EliahKagan/gitoxide that referenced this pull request Apr 8, 2025
This removes the `gix-packetline-blocking/futures-lite` "ghost
feature" added in the previous commit, and instead changes
`gix-filter` so that it depends on `gix-packetline-blocking`
without aliasing it `gix-packetline`, instead replacing each use of
`gix_packetline` with `gix_packetline_blocking` in the code of
`gix-filter`.

The long-standing `gix-packetline-blocking/async-io` feature added
in be4de0d (GitoxideLabs#1123), though it should not be used, is *not* removed.
This is because it is referenced in attributes in the code of
`gix-packetline-blocking` (because `gix-packetline-blocking/src` is
copied from `gix-packetline/src` via `etc/copy-packetline.sh`). So
removing it would cause the `clippy` run in the CI `lint` job to
fail, as well as likely causing various other reasonable operations
to fail.
EliahKagan added a commit to EliahKagan/gitoxide that referenced this pull request Apr 8, 2025
This removes the `gix-packetline-blocking/futures-lite` "ghost
feature" added in d5dd239 (GitoxideLabs#1939), and instead:

- Changes `gix-filter` to depends on `gix-packetline-blocking`
  without aliasing it `gix-packetline`.

- Replaces uses of `gix_packetline` with `gix_packetline_blocking`
  in the code of `gix-filter`.

Thus, this replaces the solution in GitoxideLabs#1939 for the problem discussed
in GitoxideLabs#1929 (comment)
with a different solution that avoids carrying a "ghost feature."

In contrast, the long-standing `gix-packetline-blocking/async-io`
feature added in be4de0d (GitoxideLabs#1123), though it should not be used,
is *not* removed, because:

- It is referenced in attributes in `gix-packetline-blocking` code
  (because `gix-packetline-blocking/src` is copied from
  `gix-packetline/src` via `etc/copy-packetline.sh`). So removing
  it would cause the `clippy` run in the CI `lint` job to fail, as
  well as likely making various other reasonable operations fail.
EliahKagan added a commit to EliahKagan/gitoxide that referenced this pull request Apr 8, 2025
This removes the `gix-packetline-blocking/futures-lite` "ghost
feature" added in d5dd239 (GitoxideLabs#1939), and instead:

- Changes `gix-filter` to depends on `gix-packetline-blocking`
  without aliasing it `gix-packetline`.

- Replaces uses of `gix_packetline` with `gix_packetline_blocking`
  in the code of `gix-filter`.

Thus, this replaces the solution in GitoxideLabs#1939 for the problem discussed
in GitoxideLabs#1929 (comment)
with a different solution that avoids carrying a "ghost feature."

In contrast, the long-standing `gix-packetline-blocking/async-io`
feature added in be4de0d (GitoxideLabs#1123), though it should not be used,
is *not* removed, because:

- It is referenced in attributes in `gix-packetline-blocking` code
  (because `gix-packetline-blocking/src` is copied from
  `gix-packetline/src` via `etc/copy-packetline.sh`).

- For that reason, removing it would cause the `clippy` run in the
  CI `lint` job to fail, as well as likely making various other
  reasonable operations fail.
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.

3 participants