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

feat(config): add validation #645

Merged
merged 4 commits into from
May 21, 2024
Merged

feat(config): add validation #645

merged 4 commits into from
May 21, 2024

Conversation

ICavlek
Copy link
Contributor

@ICavlek ICavlek commented May 17, 2024

Workflow summary

  1. Introduced Validator crate that has trait Validate which can be used on Structs and it's attributes
  2. Check for poll_secs
  3. Check for URLs - Check whether the String is ok and perform a post on the url. If the returned http answer is ok, than the url is valid
  4. Check for data dir - If the folder exists, check if is read only or not. If it doesn't exist, trace a warning.
  5. Unit tests for behaviour validation

@ICavlek ICavlek linked an issue May 17, 2024 that may be closed by this pull request
@sergey-melnychuk sergey-melnychuk requested review from LKozlowski and a team May 17, 2024 08:28
crates/core/src/config.rs Outdated Show resolved Hide resolved
crates/core/src/config.rs Outdated Show resolved Hide resolved
@sergey-melnychuk
Copy link
Contributor

Great work, thank you! I like the decoupling of validation that allows reasonably easy testing.

One nitpick though: we're trying to use conventional commits approach. I'd imagine the commit message (and maybe a PR title to avoid confusion) along the lines of feat(config): add validation.

@ICavlek ICavlek changed the title Introduced checks for Config params feat(config): add validation May 17, 2024
@ICavlek
Copy link
Contributor Author

ICavlek commented May 17, 2024

I have changed the title of the PR so that it is according to the conventional commits. I guess that this is sufficient to have that message displayed with the final commit in main branch.

@ICavlek
Copy link
Contributor Author

ICavlek commented May 20, 2024

@sergey-melnychuk @LKozlowski I have updated the PR based on the comments. Please review it again

Copy link
Contributor

@sergey-melnychuk sergey-melnychuk left a comment

Choose a reason for hiding this comment

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

LGTM,

Only one nitpick: please amend & rename commits according to conventional commits format.

@ICavlek
Copy link
Contributor Author

ICavlek commented May 20, 2024

conventional commits

Not sure that I follow. After finished PR, all commits should be squashed and there should be only one commit with name of the PR feat(config): add validation, which is according to conventional commits format. This branch would be deleted, so everything looks good to me. Please correct me if I understood something wrong

@LKozlowski
Copy link
Contributor

conventional commits

Not sure that I follow. After finished PR, all commits should be squashed and there should be only one commit with name of the PR feat(config): add validation, which is according to conventional commits format. This branch would be deleted, so everything looks good to me. Please correct me if I understood something wrong

The idea behind that convention is that we only want meaningful commits with a bit of metadata in commit messages in the git history. In this case, we want to avoid introducing commits like "fixed clippy" into history and leave one commit that would tell us what was changed.
You are right, and as a result of your work in this pull request you should have one commit with the message "feat(config): add validation".
Of course, in the future, there might be cases where the scope of the pull request is bigger so you'll end up with more commits, but all of them should follow that convention 😄

@ICavlek
Copy link
Contributor Author

ICavlek commented May 21, 2024

conventional commits

Not sure that I follow. After finished PR, all commits should be squashed and there should be only one commit with name of the PR feat(config): add validation, which is according to conventional commits format. This branch would be deleted, so everything looks good to me. Please correct me if I understood something wrong

The idea behind that convention is that we only want meaningful commits with a bit of metadata in commit messages in the git history. In this case, we want to avoid introducing commits like "fixed clippy" into history and leave one commit that would tell us what was changed. You are right, and as a result of your work in this pull request you should have one commit with the message "feat(config): add validation". Of course, in the future, there might be cases where the scope of the pull request is bigger so you'll end up with more commits, but all of them should follow that convention 😄

Understood, I completely agree with only meaningful commits in history. I will pay attention to it in future work :)

@LKozlowski
Copy link
Contributor

conventional commits

Not sure that I follow. After finished PR, all commits should be squashed and there should be only one commit with name of the PR feat(config): add validation, which is according to conventional commits format. This branch would be deleted, so everything looks good to me. Please correct me if I understood something wrong

The idea behind that convention is that we only want meaningful commits with a bit of metadata in commit messages in the git history. In this case, we want to avoid introducing commits like "fixed clippy" into history and leave one commit that would tell us what was changed. You are right, and as a result of your work in this pull request you should have one commit with the message "feat(config): add validation". Of course, in the future, there might be cases where the scope of the pull request is bigger so you'll end up with more commits, but all of them should follow that convention 😄

Understood, I completely agree with only meaningful commits in history. I will pay attention to it in future work :)

As long as you're working on something, you can have all sorts of commits as it sometimes might help to review PRs, but when you are about to merge it into the main branch then it is a time for a cleanup :)

@sergey-melnychuk
Copy link
Contributor

We're trying to keep the history linear (basically only fast-forward merges are allowed on the main branch), thus also try avoiding merge commits. We also don't require to squash all the commits in the PR into one, even though you can do that if you want to, so there is flexibility. If you want the PR to take only single commit - please rebase & then squash all the remaining ones.

The goal is to make small "atomic" changes that are easier to review and potentially troubleshoot. We don't have a limit on number of commits. My personal preference is to keep each change small and meaningful, even keeping fmt & clippy results (such commits are easily skipped during review and don't hurt when they sit in the branch).

@ICavlek ICavlek merged commit e16a436 into main May 21, 2024
7 checks passed
@ICavlek ICavlek deleted the ic/sanity_checks_config_params branch May 21, 2024 09:55
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.

feat: add sanity checks for configuration parameters
3 participants