Replace glob with compare-changes#113
Conversation
379fdd3 to
3010328
Compare
9f1c3e0 to
a830265
Compare
5fbdf60 to
a830265
Compare
|
Broken cache setup is causing the CI failures, it is referring to output of a step that hasn't been executed yet, defaulting to empty. See: and I would just manually delete the caches at https://github.com/mpalmer/action-validator/actions/caches and rerun the ci, but I can't. For a proper fix something more involved is required and I don't have easy answers for that. CI passes fine in my fork: |
a830265 to
5fbdf60
Compare
5fbdf60 to
c0a9294
Compare
This unlocks helpful syntax in compare-changes edition 2024 mandates minimum 1.86 as well, but had some CI issues so bumping directly to 1.92
6793c47 to
9055611
Compare
|
Fixed CI with 0de554d, it may need further work later but for now should be ok |
|
@mpalmer happy new year, this PR is ready for review |
The library hasn't really changed, just packaging & other updates.
be69f1b to
5f2453d
Compare
|
OK, back in the saddle... thoughts:
After those observations, the important news: the code that switches from glob to compare-changes itself seems entirely fine and reasonable, so I've cherry-picked that into main. If you want any of the changes from the other commits to go in, it's probably best to open a new PR. |
|
Thanks Matt! Very happy to see the important change merged. Hope it also gets released 😄: I have no strong opinions on the rest, and actually learned a few things from your comment! For the sake of completeness:
I thought Rust version would be covered by: Line 18 in 4249884
This is indeed quite cumbersome. Glad you found a better fix!
I think it is related to the attempted Rust edition update. You can reproduce 9055611 by having
With edition 2024 the mod.rs of my library could have had a little bit less nesting, see here, but thankfully as you say these are indeed per-crate so I can do it and
So it was just confusion on my part, sorry. Still a bit new to Rust 😄 To avoid the crates.io publish loop for every little change, I had copied over the files locally, which of course makes them part of the same crate and breaks the build due to incompatible syntax. Should have used staging.crates.io to do it properly. |
A change to the MSRV (Minimum Supported Rust Version) would be covered by a change to Cargo.toml, but the Rust version actually used by the build run wouldn't be picked up -- a lot of CI jobs just say "use nightly" or "use latest stable", and that'll change on a regular cadence determined by Rust releases, not changes that I make.
Oooh, yeah, that'd do it. I didn't look at the ordering of the commits.
Alternately, you could temporarily use a local override to point at a local copy of [patch.crates-io]
# point to a pushed branch, but which is as-yet unreleased
compare-changes = { git = "https://github.com/...", branch = "some-new-feature" }
# or else even point to uncommitted changes
compare-changes = { path = "../compare-changes" }I use that approach all the time when I'm testing out changes to crates for features and bugfixes that I'll use elsewhere, it's fantastic. |
Oh this one is really cool. Somehow missed it when trying to Google about how to do it 😄 Thanks!! |
What / Why
How
I had some free time on my hands so I spent Nov 21 to Nov 30 on building a Rust library called compare-changes that is a reimplementation of GitHub's workflow syntax.
While setting up a trivial parser/pattern matcher is easy enough, one will soon start to learn about things like memoization, backtracking, pathological patterns, automatas and such, which are interesting, but would take me ages to use / account for, so instead the library relies on chumsky and regex for the difficult runtime bits.
Overview of compare-changes
globforaction-validatorand how the library works:
While GitHub's Documentation is helpful, it doesn't cover various edge cases of how pattern validation should behave. Therefore I've used various temporary repositories to run dummy workflows to see the actual behavior and eventually settled on the use of anttiharju/tmp for the purpose.
Now while I am quite happy with the state of the library, it of course could be that I've missed some edge cases and such, even if I am aware of a decent chunk of them. In case people encounter further issues with
action-validatorin regards to path patterns, feel free to point them to open an issue in anttiharju/compare-changes. These are fairly easy to provide repros for and it should be easy enough for me to update the library.Testing
Library has plenty of automated tests. Also tested manually:
Benchmarks
Main motivator for me here was fixing the slow Git hook so here are some numbers from a repo that uses a lot of glob patterns (anttiharju/relcheck@v1.8.13).
worst case: from
7.883 sto118.5 ms, a 66x improvement (7883/118=66,8050847458)best case: from
92.4 msto119.0 ms, a26.6 msoverheadthe multiplier may change a lot depending on the repo picked for running the benchmarks. In the performance issue discussion the multiplier was
19x[comment] because the worst case was not as bad. I did check that the numbers here were from0.8.0and not0.6.0, with0.6.0worst case went up to ~10s.Benchmarks ran on a 2021 14" MBP using hyperfine:
hyperfine --warmup 3 "git ls-files -z '.github/workflows/*.yml' '*/action.yml' | xargs -0 action-validator --verbose"details
worst-case
with a gitignored
.direnvfrom nix-direnvaction-validator@27-fix-wildcards-105-fix-gitignore-perfaction-validator@v0.8.0best case
no gitignored files ensured with
git reset --hard && git clean -dfxaction-validator@27-fix-wildcards-105-fix-gitignore-perfaction-validator@v0.8.0Anything else
tests/fixtures/012_github_glob_syntax/glob.yml) did not match GitHub's behavior, so went ahead and fixed them.action-validatornow shells out togitforls-filesto solve the performance issue when a repository has a lot of gitignored files.Comments on the code in the library (
lib.rs,path/mod.rs,convert/mod.rs) are also welcome, but not expected.