Conversation
|
@mpalmer I've added a TODO list above based on your previous comment. It would be good to get an idea of what you think the priority order should be for this. Also which of these you want to check off before merging this PR, and which (if any) you think can be handled separately? If you have any guidance/pointers on that would also be appreciated (I'm relatively new to Rust so this is a bit of a learning experience for me 🙂). |
|
I've been working on improving the Node API with some success but encountered an unexpected behaviour of valicos serialize trait. I've raised an issue to determine if this is intended behaviour or a bug. |
|
I think the critical threshold is to know if/when a future change breaks the node build, so having the test suite run successfully under node, and have workflow jobs that run that test suite, are the "baseline", I think. Having an automated release process is a prerequisite for making WASM/node a "first class citizen", but could be deferred to a separate PR -- although I'm not sure how much use a WASM-capable In summary, then, I'd say the order is:
1 & 2 are the minimum for this PR, IMO; other parts could be deferred to other PRs, but I'm cool with you making this a Mega PR o' Doom if you prefer. |
|
@mpalmer Apologies for leaving this PR dangling. I've been away for work and haven't had much time to work on this. I agree with the priorities as you set them out above. I think a Mega PR 'o Doom is probably the best way since, as you pointed out, we basically need to get to 4. for it to be useful anyway! Current status of the above is: 1. Make it build/functionYes, this is more or less done. The only exception here (afaik) is that the I'm thinking we can probably use a wrapper function with different implementations depending on the build type. This can call into JS to resolve the glob. 2. Test suite, QA jobsIt shouldn't be an issue to adapt/implement a runner for the current test suite, similar to the 3. Ergonomic improvements that will be non-backwards compatibleEDIT: I've gone ahead and done the implementation as described below - hopefully it's ok but any feedback is very welcome! :) I could do with a second opinion on this. It seems we have 3 main errors:
For 3. I was initially thinking to return the Valico's However, I see 2 main disadvantages here:
I think my preference for addressing this would be to implement our own What are your thoughts on this? 4. Automated releasesI haven't started on this but I have some experience with GitHub actions and publishing NPM packages so this should be fairly straightforward. Would you want to continue publishing to 5. Further improvements to docs, API, etcI'll tackle this once the API is finalised :) |
|
Don't worry about leaving things hanging; we've all got things to do.
Interestingly, there's recently been another bug report about how the current globbing support is out-of-step with GitHub's docs. I am in no way married to the current crate for globbing, so if you find one that's WASM-friendly and better than the current one (in terms of GitHub compatibility) I would be entirely open to a switch.
I'll level with you: the "failure reporting" in
I lean towards publishing it under a namespace that "the project" controls, so I'd probably go with |
Ah good to know! Maybe an opportunity to kill two birds with one stone :)
Thanks for confirming :) The simplicity is definetly appreciated as somone relatively new to Rust - it's very easy to understand what the code is doing!!
My initial thought was to publish it under |
src/validation_error.rs
Outdated
| pub enum ValidationError { | ||
| // Schema Validation Errors | ||
| WrongTypeSchemaError { | ||
| meta: ValidationErrorMetadata, |
There was a problem hiding this comment.
I think it would be better to remove the meta field and elevate all the meta.* properties to the top level of the error. I've implemented like this for now but I'm intending to re-factor it.
There was a problem hiding this comment.
Is this re-factor still planned, for this or a future PR?
There was a problem hiding this comment.
I would like to. Tbh I was procrastinating because I wasn't sure what the best way would be, since I wanted a solution which would work well for serialising to JS but also makes it easy to work with in Rust in case this is distributed as a crate.
For me, the current front runner solution would be:
'''rs
enum ValidationError {
SomeError {
path: String,
...fields
}
}
impl ValidationError {
pub fn get_path(): String {
...
}
}
'''
Since this allows matching over error types but also just quickly grabbing the value of a given field depending on the use case.
Let me know if you think this is ok or if you have another suggestion for how we couple refactor this :)
| Validation failed: ValidationState { | ||
| errors: [ | ||
| NoFilesMatchingGlobError { | ||
| meta: ValidationErrorMetadata { | ||
| code: "glob_not_matched", | ||
| path: "/on/push/paths", | ||
| title: "Glob does not match any files", | ||
| detail: Some( | ||
| "Glob \"004_bad_globs/*.txt\" in /on/push/paths does not match any files", | ||
| ), | ||
| }, | ||
| }, | ||
| ], | ||
| } |
There was a problem hiding this comment.
Because all the errors are now handled internally using the same data-structures, I have removed any special cases for now and just logged the validation state. I think it would be nice to implement a pretty printer for errors - maybe something that could be controlled by a CLI flag e.g. --format=pretty, --format=json, --format=debug. What do you think?
There was a problem hiding this comment.
I'll never say "no" to UI improvements, if you're willing to code them up, but in the interests of getting the WASM support landed, perhaps it'd be best to defer pretty-printing for a future PR. 😁
CODE_OF_CONDUCT.md
Outdated
| - The use of sexualized language or imagery | ||
| - Personal attacks | ||
| - Trolling or insulting/derogatory comments | ||
| - Public or private harassment | ||
| - Publishing other's private information, such as physical or electronic |
There was a problem hiding this comment.
There's some unrelated changes from running prettier. I can configure prettier to only run on JavaScript files and revert the changes if you prefer @mpalmer.
There was a problem hiding this comment.
Yes, it would be best if you didn't modify the CoC file -- it's taken directly from upstream, and reformatting would make it harder to incorporate changes from upstream in the future.
There was a problem hiding this comment.
Cool, I will add it to the .prettierignore file and revert the changes :) prettier also formats any other YAML, JSON and Markdown files by default. Let me know if you want me to disable it - I personally don't mind it but appreciate it could be annoying especially given it will fail the CI.
There was a problem hiding this comment.
Changes reverted and CODE_OF_CONDUCT.md added to .prettierignore
If that's a common idiom in the NPM ecosystem, I'm fine with going with that. |
|
@mpalmer I think this is now ready for review :) I haven't made any changes to glob yet since this PR is already quite big and I figured maybe we can defer the glob implementation to a separate PR. Would you be happy with this? I also didn't do any changes to the UI yet since I will defer this to another PR as you suggested 👍 I can't think of anything else that needs to be done but let me know if I've missed something! Once this is merged, you will need to create the NPM organisation "action-validator" and add NPM_TOKEN as a secret for the repo. Then you can create a release and it will automatically publish both the Technically, since the two packages deploy in parallel and |
mpalmer
left a comment
There was a problem hiding this comment.
This is a monster PR, and nice work getting through it. I've dropped a couple of questions, but I can't see anything that needs changing.
For the merge, I like to have a relatively "clean" commit history -- while multiple commits in a PR are cool, when they touch different things or are for different purposes, I prefer to git rebase -i and squash "fixup" / "tidyup" commits into the commits they're fixing, to keep the commit history more readable. To put it another way, I like PRs to represent the finished thing, rather than the "stream of consciousness" of changes as they happened.
Of course, since I do those cleanups to the commit history of my own PRs, I understand that it can be a PITA to do a git rebase -i+selective squash on a huge PR like this, so the other alternative is just to squash everything into one commit and land that. If you'd prefer to go that way, I can do that when I merge the PR. Otherwise, tidy up the commit history and force-push to the PR branch, and I can merge the branch clean once the open questions are answered.
src/validation_error.rs
Outdated
| pub enum ValidationError { | ||
| // Schema Validation Errors | ||
| WrongTypeSchemaError { | ||
| meta: ValidationErrorMetadata, |
There was a problem hiding this comment.
Is this re-factor still planned, for this or a future PR?
|
@mpalmer Thanks for reviewing this 🙂 Normally I am a proponent of squash on merge since I prefer to keep my PRs small and focussed, but in this case I think it makes sense to break it up a bit. I have quite a busy schedule this weekend but I'll try and address the implementation of ValidationError and tidy up the commits if I can make time or if not then ASAP next week. |
| @@ -1,10 +1,10 @@ | |||
| * If you have found a discrepancy in documented and observed behaviour, that | |||
There was a problem hiding this comment.
Sorry to put another thing on you, but I've pondered these (presumably prettier-inspired) formatting changes a bit longer, and I've decided that I can't live with prettier trying to copy-edit my markdown. I'll be spending the rest of my life making "make prettier happy" commits, to comply with a markdown style that I find pretty unpleasant and unnatural. Please revert the formatting-only changes to markdown files, and teach prettier to leave them alone for the future. Thanks.
There was a problem hiding this comment.
I'll get prettier to ignore everything that isn't a JavaScript file (since that's what I originally added it for) and revert all other changes
af7dbc2 to
5ec7714
Compare
|
@mpalmer I've made the requested changes and tidied up the commit history =) |
mpalmer
left a comment
There was a problem hiding this comment.
I've got one question about a recent feature that I worry you might have nuked, but apart from that, your changes look reasonable, and ready to merge as soon as we've cleared up the merge issue.
| use clap::Parser; | ||
| use std::process; | ||
|
|
||
| // Run the validator on each file and collect any errors |
There was a problem hiding this comment.
I can't seem to find where this code has gotten to. I suspect your merge conflict resolution might have nuked it.
There was a problem hiding this comment.
Yeah the merge conflicts were pretty bad - there was basically no overlap 😬 this code has moved to cli::run but looks a bit different now. Functionality is the same as far as I can tell from a few manual tests. I can refactor to make it more similar if that's preferable and/or add some automated tests for the new functionality?
There was a problem hiding this comment.
I really should have put automated tests in when #31 was merged, shouldn't I... I'll add one to main now, for cleanliness, and then if your PR is still clean against that, I think we're ready for merge.
There was a problem hiding this comment.
Exellent! Thanks for picking that up =) Let me know if there's anything I can do to help
|
WE ARE LANDED! I'll create an NPM account/key/etc, add it as a repo secret, and then make a release to see this puppy fly! |
|
The release CI job seemed to run OK, so I presume that everything is hunky dory in NPM land. Winnah! |
I've tested it out and it seems to be working perfectly :) Thanks for your support and guidance on this @mpalmer! There's a couple things which were left out of this PR that I'll probably look into soon if you're happy to accept PRs for them?
|
|
More than happy to accept PRs for both of those. Also, what's the chances of getting the testsuite to use |
|
@mpalmer I completely agree. Initially I hadn't planned to add For now, I have raised a PR to update the snapshot so the CI will pass (#34). When I add multi-file support to |
Closes #25
Adds support for use as an NPM/Node module.
TODO: