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

Impl/create actions #3

Merged
merged 16 commits into from Mar 25, 2024
Merged

Impl/create actions #3

merged 16 commits into from Mar 25, 2024

Conversation

DrewMcArthur
Copy link
Contributor

@DrewMcArthur DrewMcArthur commented Mar 22, 2024

let me know if you have any thoughts - happy to add/remove any tests that you do or don't want, as well as adjust any to your preferences as far as flags and whatnot. i figured serde was a good starting place, and we can make adjustments as necessary.

what the PR changes

this PR adds two actions, test.yml and deploy.yml

  • test.yml is copied from serde's ci.yml
  • deploy.yml is copied from this blog post, it pushes a new version to crates.io whenever you publish a new tag on GitHub.

it also makes some small changes, mostly to get clippy's approval.

test.yml

two of the checks i copied over are checking for clippy warnings and minimal version checks

clippy

  • most of the changes are to resolve clippy warnings, i'll add comments to specific spots that you might want to double check
  • i made clippy just run at default levels, rather than pedantic, as serde has. let me know if you have preferences there

minimal-versions

i made some of the version requirements slightly stricter (e.g. requiring at least v0.1.78 of async-trait rather than just v0.1), as a result of the minimal check in test.yml, but ended up commenting that out since some dependencies within number-general cause it to fail. if/when we want to add that in, we can add these checks to those repositories as well in order to get that passing.

fuzz testing

fuzz testing async code seems tough to setup, so that's commented out for now.

running actions

i'm not sure if there's something you have to approve in order to let the actions run, but you can see them passing (and a bit more detail) in my initial PR into my own repo

Copy link
Contributor Author

@DrewMcArthur DrewMcArthur left a comment

Choose a reason for hiding this comment

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

commented explaining some specific changes. everything else is just following clippy's suggestions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this will auto-publish the crate to crates.io any time you publish a new tag. just need to setup your token in the repository's secrets. see this blogpost for more detail, or send me an email and i'd be happy to help get this setup.

Comment on lines +77 to +78
- run: cargo clippy --tests # -- -Dclippy::all -Dclippy::pedantic
- run: cargo clippy --all-features --tests # -- -Dclippy::all -Dclippy::pedantic
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 commented out these flags that make clippy stricter. things pass right now with the default flags, but let me know if you have any preferences for the settings to use here.

Comment on lines +58 to +68
# this fails right now because of errors in get-size-derive.
# number-general should require 0.1.3
# minimal:
# name: Minimal versions
# runs-on: ubuntu-latest
# timeout-minutes: 45
# steps:
# - uses: actions/checkout@v4
# - uses: dtolnay/rust-toolchain@nightly
# - run: cargo generate-lockfile -Z minimal-versions
# - run: cargo check --locked
Copy link
Contributor Author

Choose a reason for hiding this comment

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

enabling this test would require fixing some version requirements in some of the upstream crates, specifically updating number-general to require v0.1.3 of get-size-derive. maybe more, but that's where this broke and I didn't go any further with testing it.

Comment on lines +92 to +101
# fuzz testing async code seems hard
# fuzz:
# name: Fuzz
# runs-on: ubuntu-latest
# timeout-minutes: 45
# steps:
# - uses: actions/checkout@v4
# - uses: dtolnay/rust-toolchain@nightly
# - uses: dtolnay/install@cargo-fuzz
# - run: cargo fuzz check
Copy link
Contributor Author

Choose a reason for hiding this comment

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

idk if you wanna eventually get fuzz testing to work, but doing it async is a bit more of a lift than i wanted to get into for this PR

Cargo.toml Outdated
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these version bumps shouldn't change much, but were just made to start satisfying requirements of the minimal check, i.e.

cargo generate-lockfile -Z minimal-versions
cargo check --locked

Comment on lines -582 to -584
} else if self.buffer.len() >= FALSE.len() && self.buffer.starts_with(FALSE) {
self.decode_bool(visitor).await
} else if self.buffer.len() >= TRUE.len() && self.buffer.starts_with(TRUE) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

would maybe want to make sure that a test hits this, but clippy essentially complained that since the two conditional blocks are the same, the conditions should just be merged, so that's what i did here. the logic should be identical though.

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 could be wrong, but after trying to set some breakpoints and running the existing tests, it doesn't look like anything hits this condition.

before this gets merged, i'll update one of the tests so that these lines have coverage!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated this test here, and confirmed it hits this code path.

Comment on lines -48 to -51
match ready!(this.value.as_mut().poll_next(cxt)) {
Some(result) => Some(result),
None => None,
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this match doesn't actually do anything, since the output of ready! is already either None or Some(result)

Comment on lines -52 to -58
struct Error;

impl<'en> IntoStream<'en> for Error {
fn into_stream<E: Encoder<'en>>(self, encoder: E) -> Result<E::Ok, E::Error> {
"an error!".into_stream(encoder)
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

clippy complained that this was unused, so i got rid of it. is that accurate? is it used anywhere?

@DrewMcArthur
Copy link
Contributor Author

okay @haydnv this is ready for a review! most of the open threads are just a heads up / pointing something out, so feel free to resolve them as you see fit. let me know if there's anything you'd like to add/remove etc. hope this is helpful!

@haydnv haydnv merged commit 4186d53 into haydnv:main Mar 25, 2024
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

2 participants