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

Update to 2021 edition, add ci + clippy fixes #64

Closed
wants to merge 2 commits into from

Conversation

simonsan
Copy link

@simonsan simonsan commented Dec 20, 2023

Tests run through, the benchmark was broken though native_db::Database::create_in_memory() was not existing.

Choose a reason for hiding this comment

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

Nice addition of this workflow file. I see two solutions:

Copy link
Author

Choose a reason for hiding this comment

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

This workflow has the advantage, that it will work with the merge queue. In general, the actions in build_and_test_release.yml are outdated and need a rework, unfortunately. actions-rs as an org is archived, meaning all the actions of them are unmaintained. Maybe we can keep the ci.yml so there are some checks in PRs for now until the build_and_test_release.yml is updated?

Choose a reason for hiding this comment

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

Yes, I know it's no longer maintained, but build_and_test_release.yml allows testing on all platforms, manages releases, etc., while ci.yml does not. It would be wiser to update build_and_test_release.yml and separate these changes into different MRs:

  • One PR for upgrading build_and_test_release.yml tests workflow.
  • One PR to add a job for clippy.
  • One PR for upgrading to 2021.
  • One PR for CI docs.
  • One PR for powerset / cargo hack check.

All these modifications are good to go. I suggest closing this MR and, if you wish, opening specific ones, which I would greatly appreciate :). In any case, it's a great idea, and even if it's not essential, it will be done in the coming weeks!

Copy link
Author

Choose a reason for hiding this comment

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

2023-12-20 20_39_03-rustic_ github_workflows at main · rustic-rs_rustic — Mozilla Firefox

src.: https://github.com/rustic-rs/rustic/tree/main/.github/workflows

I would recommend separating the different workflows by their scope and when they are run. Basic checking and testing, fmt, etc. for PRs. Releasing and running time and resource intense workflows on user request (see prebuilt-pr above) because some resource intense stuff you don't want to run on PRs (environmental impact, not useful, etc.).

Copy link
Author

@simonsan simonsan Dec 20, 2023

Choose a reason for hiding this comment

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

That being said I think build or rather check and test should not be in the same job:

2023-12-20 22_51_05-Update to 2021 edition, add ci + clippy fixes · vincent-herlemont_native_db@f12f

Because one is not dependent on the other, in terms of CI. You want to have output for check/build and a separate output (checkmark) for tests. The more fine-grained the results are, the more useful overall. Otherwise, if that workflow fails, you always need to check, which step of that workflow failed, whereas one job should focus on one thing. And reduce the noise as much as possible.

The current workflow:
2023-12-20 22_59_40-Update to 2021 edition, add ci + clippy fixes · vincent-herlemont_native_db@f12f

Is kind of os specific and doesn't give a lot of information what exactly failed and where the probably lay.

While e.g. the proposed workflow gives you:
2023-12-20 22_57_36-Update to 2021 edition, add ci + clippy fixes · vincent-herlemont_native_db@f12f

An overview of what is happening and doesn't necessarily put os-dependent problems up front, while you still can investigate them, because they are just a build matrix.

Choose a reason for hiding this comment

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

@simonsan Thank you for your explanations. I have started to refactor the CI on main. I've made separate workflows, and the next step will be to remove the deprecated jobs, and split in test, build etc. Please don't hesitate to give me your opinion; it is valuable.

Comment on lines -65 to -73
impl Default for DatabaseSecondaryKeyOptions {
fn default() -> Self {
Self {
unique: false,
optional: false,
}
}
}

Choose a reason for hiding this comment

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

For this part, is it possible to keep the default explicit? Since these are options, it has real logical significance and implications.

Copy link
Author

Choose a reason for hiding this comment

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

Can do, but do you want to keep false or replace it with bool::default() to make it more explicit, that default values are being used?

Choose a reason for hiding this comment

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

No, it's fine, let's leave it as it is. There isn't too much ambiguity at that level ^^

Comment on lines -189 to -192
match self {
Some(value) => value.database_inner_key_value(),
None => DatabaseInnerKeyValue::new(Vec::new()),
}

Choose a reason for hiding this comment

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

Is it possible to keep the match notation? I find it more readable.
Unless there's another interest in using the map_or_else method?

Copy link
Author

Choose a reason for hiding this comment

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

It's less idiomatic, but it is also personal preference. I personally find it more readable with the map, as it makes it more explicit, that we operate on self.

Choose a reason for hiding this comment

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

Follow up #64 (comment)

Comment on lines -18 to -25
pub(crate) fn unwrap_item<T: Input>(item: Option<redb::AccessGuard<&'static [u8]>>) -> Option<T> {
if let Some(item) = item {
let item = item.value();
let item = T::native_db_bincode_decode_from_slice(item);
Some(item)
} else {
None
}

Choose a reason for hiding this comment

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

Is it possible to keep the match notation? I find it more readable.
Unless there's another interest in using the map_or_else method?

Copy link
Author

Choose a reason for hiding this comment

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

It's less idiomatic, I would say. As essentially you are destructing an Option to then return an Option. It would be different, if we would return item. If you are working with Option and returning Option, I find it more idiomatic, work within the option.

Choose a reason for hiding this comment

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

It's less idiomatic, but it is also personal preference. I personally find it more readable with the map, as it makes it more explicit, that we operate on self.
It's less idiomatic, I would say. As essentially you are destructing an Option to then return an Option. It would be different, if we would return item. If you are working with Option and returning Option, I find it more idiomatic, work within the option.

Maybe you are making me change my mind. I understand your arguments are relevant. I just have a problem with the aesthetics/visibility/symmetry of the code...

Comment on lines -29 to -38
impl Default for NativeModelOptions {
fn default() -> Self {
Self {
native_model_id: 0,
native_model_version: 0,
native_model_legacy: false,
}
}
}

Choose a reason for hiding this comment

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

For this part, is it possible to keep the default explicit? Since these are options, it has real logical significance and implications.

Copy link
Author

Choose a reason for hiding this comment

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

Can do, but do you want to keep the 0 or replace it with u32::default() and bool::default() to make it more explicit, that default values are being used?

Choose a reason for hiding this comment

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

Follow up #64 (comment)

src/watch/mod.rs Show resolved Hide resolved
@vincent-herlemont
Copy link
Owner

@simonsan Thank you very much for your merge request!

@vincent-herlemont
Copy link
Owner

All is done now.

@simonsan simonsan deleted the clippy-fixes branch May 1, 2024 17:33
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.

2 participants