scala-steward
scala-steward copied to clipboard
A CLI command to validate repo configs
Attempt to solve #2638. Can be invoked like this (as a subcommand):
java -jar scala-steward-assembly-VERSION.jar validate-repo-config .scala-steward.conf
Sample input (with error):
.scala-steward.conf:
updatePullRequests = 123
Output:
2022-07-12 11:17:08,589 ERROR Configuration file at /home/nikololiahim/scala/scala-steward/.scala-steward.conf contains errors:
Decoding failed with:
Got value '123' with wrong type, expecting string:
updatePullRequests
Now that I think of it, this doesn't solve the "actually valid config" problem described here. It still just runs the file through a circe parser, and doesn't perform any additional checks.
It also feels weird to make --validate-repo-config an option, it should rather be a subcommand (IMO).
Codecov Report
Merging #2662 (5568b6f) into main (c17d367) will decrease coverage by
0.44%. The diff coverage is70.00%.
@@ Coverage Diff @@
## main #2662 +/- ##
==========================================
- Coverage 81.32% 80.88% -0.45%
==========================================
Files 146 147 +1
Lines 2592 2673 +81
Branches 43 49 +6
==========================================
+ Hits 2108 2162 +54
- Misses 484 511 +27
| Impacted Files | Coverage Δ | |
|---|---|---|
| ...re/src/main/scala/org/scalasteward/core/Main.scala | 0.00% <0.00%> (ø) |
|
| ...ala/org/scalasteward/core/application/Config.scala | 100.00% <ø> (ø) |
|
| ...la/org/scalasteward/core/application/Context.scala | 68.91% <21.42%> (-1.67%) |
:arrow_down: |
| .../scala/org/scalasteward/core/application/Cli.scala | 100.00% <100.00%> (ø) |
|
| ...teward/core/repoconfig/ValidateRepoConfigAlg.scala | 100.00% <100.00%> (ø) |
|
| ...a/org/scalasteward/core/coursier/CoursierAlg.scala | 71.11% <0.00%> (-14.19%) |
:arrow_down: |
| .../org/scalasteward/core/buildtool/mill/parser.scala | 66.66% <0.00%> (-1.52%) |
:arrow_down: |
| ...ain/scala/org/scalasteward/core/data/Version.scala | 100.00% <0.00%> (ø) |
|
| ...in/scala/org/scalasteward/core/data/Resolver.scala | 100.00% <0.00%> (ø) |
|
| ...ala/org/scalasteward/core/nurture/NurtureAlg.scala | 0.00% <0.00%> (ø) |
|
| ... and 6 more |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
In case you haven't seen it, a scala-cli version of this idea was proposed in https://github.com/typelevel/steward/pull/7#discussion_r903318794. Not sure if that's basically what you were doing here already.
In case you haven't seen it, a scala-cli version of this idea was proposed in typelevel/steward#7 (comment). Not sure if that's basically what you were doing here already.
Yes, I have seen this comment, and this is basically what I am doing here. I'm just wondering if this solution is good enough (or even necessary at all).
I'm just wondering if this solution is good enough (or even necessary at all).
Not entirely sure what you mean, but it's definitely necessary :) basically it helps validate two things:
- the config file is valid HOCON format (extraneous commas have messed us up multiple times)
- furthermore, it's consistent with the Steward config "schema"
Of course, this won't guarantee that it "works", but it's a huge improvement over the status quo.
See also: https://github.com/scala-steward-org/scala-steward/pull/2446.
So I tried to use the --validate-repo-config as it was prior to https://github.com/scala-steward-org/scala-steward/pull/2662/commits/7be5f91fa90f2879ee1a023ee1f1e8e127b030df and it turns out there are several required flags which are not relevant to the config validation part. So, I decided that it would be better to make a separate validate-repo-config subcommand. It can now be invoked like this:
java -jar scala-steward-assembly-VERSION.jar validate-repo-config .scala-steward.conf
That being said, I had to touch a lot of things, which doesn't feel right. So if somethings seems in need of refactoring, don't hesitate to ping!
I was editing a .scala-steward.conf a little earlier and missed this :) I hope a maintainer may be able to take a look soon, thanks!
@armanbilge yeah, it's basically ready (at least functionality-wise), just needs a review
@nikololiahim Thanks for your contribution. I've added change requests regarding the naming convention. Other parts look great to me.
@exoego Thank you! Will fix the comments shortly.
@exoego https://github.com/scala-steward-org/scala-steward/pull/2662/commits/5568b6f21d7be97a07eaac6c0e80f795372e034e addresses all the naming comments.
Sorry for late review
I am fine with a little coverage down and minor Codacy issues. https://app.codacy.com/gh/scala-steward-org/scala-steward/pullRequest?prid=9766981