-
-
Notifications
You must be signed in to change notification settings - Fork 0
File count validator #44
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
Conversation
|
@illicitonion Here is the validator for checking the right files are committed. Let me know what you think, in particular if I've made any faux-pas in rust, re the matching and error handling. I'm still getting used to that. |
illicitonion
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay here! This looks good, but I left a few comments about some general Rust things :)
|
Thanks for the suggestions, Ive made some changes to improve them. I am a bit unhappy about how I am accessing the assignment issue ids, notably my comment in line 256 of pr-metadata-validator seems to be hinting at me that there's probably a cleaner way to access these. But it works now. |
illicitonion
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a bit unhappy about how I am accessing the assignment issue ids, notably my comment in line 256 of pr-metadata-validator seems to be hinting at me that there's probably a cleaner way to access these.
Yeah... Not suggesting necessarily making a change, but it feels like the mismatch here is that the existing APIs are very "match all the PRs" centric, whereas the API you really want in this functionality is "match me this one PR" - in the type system we're losing the information that "this one PR has already been matched" so you need to assert it. If we wanted to change this in a simple way, I think it would take the shape of combining lines 210-214 into this check, into a function on ModuleWithSubmissions along the lines of:
fn get_matched_pr(&self, pr_number: u64) -> Option<Submission>whose body largely matches get_descriptor_id_for_pr (but returning the Submission rather than the u64) so that lines 210-214 would become something like:
let Some(Submission::PullRequest { assignment_issue_id, .. }) = matched.get_matched_pr(pr_number) else {
return Ok(ValidationResult::CouldNotMatch);
}and then you wouldn't need to separately check for the descriptor ID.
Co-authored-by: Daniel Wagner-Hall <daniel@codeyourfuture.io>
illicitonion
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful, thank you!
Co-authored-by: Daniel Wagner-Hall <daniel@codeyourfuture.io>
Adds a file validator for PR submissions.
The directory files should be changed in is defined in an issue body, in a comment, like so:
If it is not present, the bot does not do this check
If it is present, this regexp is checked against every changed file present in a PR submission
If any fail to match, i.e. something in a wrong directory was changed, then the bot issues a warning
If no files are submitted at all, the bot issues a warning
I propose any metadata that needs checked be included in these style of comments, and this metadata will need to be added for every task submission before the bot will be able to perform checks
Currently only supports checking a single directory, but could be extended to have multiple, could also extend to do things like checking max number of committed files or any other metadata visible to PRs
You can see an example of output of this check here: CodeYourFuture/Module-Structuring-and-Testing-Data#873