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

Verify the example .scala-steward.conf #3571

Merged
merged 4 commits into from
Feb 3, 2025
Merged

Verify the example .scala-steward.conf #3571

merged 4 commits into from
Feb 3, 2025

Conversation

fthomas
Copy link
Member

@fthomas fthomas commented Feb 1, 2025

This checks that the example .scala-steward.conf in the docs is equivalent to the JSON one gets when parsing, decoding and encoding that example. It ensures that the values used in the example are the same as the values in the decoded RepoConfig.

With this change, the docs/mdoc task fails currently with:

error: repo-specific-configuration.md:211:1: Diff between parsed input (-) and encoded object (+):
         "groupId" : "com.example",
-        "version" : "2."
+        "version" : {
+          "prefix" : "2."
+        }
       },
       "pullRequests" : {
-        "frequency" : "30 day"
+        "frequency" : "30 days"
       }
       "pullRequests" : {
-        "frequency" : "14 day"
+        "frequency" : "14 days"
       }
   "signoffCommits" : true,
-  "updatePullRequests" : "always | on-conflicts | never",
+  "updatePullRequests" : "on-conflicts",
   "updates" : {
         "groupId" : "org.acme",
-        "version" : "1.0"
+        "version" : {
+          "prefix" : "1.0"
+        }
       }
         "groupId" : "com.example",
-        "version" : "1.1."
+        "version" : {
+          "prefix" : "1.1."
+        }
       }

In subsequent commits I'll will fix these reported differences.

Closes: #1341

@fthomas fthomas added this to the 0.33.0 milestone Feb 1, 2025
@fthomas fthomas marked this pull request as draft February 1, 2025 13:29
This checks that the example `.scala-steward.conf` in the docs is equivalent
to the JSON one gets when parsing, decoding and encoding that example.

With this change, the `docs/mdoc` task fails currently with:
```diff
error: repo-specific-configuration.md:211:1: Diff between parsed input (-) and encoded object (+):
         "groupId" : "com.example",
-        "version" : "2."
+        "version" : {
+          "prefix" : "2."
+        }
       },
       "pullRequests" : {
-        "frequency" : "30 day"
+        "frequency" : "30 days"
       }
       "pullRequests" : {
-        "frequency" : "14 day"
+        "frequency" : "14 days"
       }
   "signoffCommits" : true,
-  "updatePullRequests" : "always | on-conflicts | never",
+  "updatePullRequests" : "on-conflicts",
   "updates" : {
         "groupId" : "org.acme",
-        "version" : "1.0"
+        "version" : {
+          "prefix" : "1.0"
+        }
       }
         "groupId" : "com.example",
-        "version" : "1.1."
+        "version" : {
+          "prefix" : "1.1."
+        }
       }
```
In subsequent commits I'll will fix these reported differences.

Closes: #1341
@fthomas
Copy link
Member Author

fthomas commented Feb 1, 2025

a99bde2 reduces the diff to:

error: repo-specific-configuration.md:211:1: Diff between parsed input (-) and encoded object (+):
         "groupId" : "com.example",
-        "version" : "2."
+        "version" : {
+          "prefix" : "2."
+        }
       },
   "signoffCommits" : true,
-  "updatePullRequests" : "always | on-conflicts | never",
+  "updatePullRequests" : "on-conflicts",
   "updates" : {
         "groupId" : "org.acme",
-        "version" : "1.0"
+        "version" : {
+          "prefix" : "1.0"
+        }
       }
         "groupId" : "com.example",
-        "version" : "1.1."
+        "version" : {
+          "prefix" : "1.1."
+        }
       }

@fthomas
Copy link
Member Author

fthomas commented Feb 1, 2025

f3c58cc reduces the diff to:

error: repo-specific-configuration.md:211:1: Diff between parsed input (-) and encoded object (+):
   "signoffCommits" : true,
-  "updatePullRequests" : "always | on-conflicts | never",
+  "updatePullRequests" : "on-conflicts",
   "updates" : {

Copy link

codecov bot commented Feb 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.81%. Comparing base (3f58890) to head (c8743ba).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3571      +/-   ##
==========================================
+ Coverage   89.79%   89.81%   +0.01%     
==========================================
  Files         174      174              
  Lines        5029     5038       +9     
  Branches      491      489       -2     
==========================================
+ Hits         4516     4525       +9     
  Misses        513      513              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fthomas
Copy link
Member Author

fthomas commented Feb 1, 2025

This machinery also detects typos in the example options like this:

--- a/modules/docs/mdoc/repo-specific-configuration.md
+++ b/modules/docs/mdoc/repo-specific-configuration.md
@@ -144,7 +144,7 @@ updates.fileExtensions = [".scala", ".sbt", ".sbt.shared", ".sc", ".yml", ".md",
 # you don't change it yourself.
 # If "never", Scala Steward will never update the PR
 # Default: ${PullRequestUpdateStrategy.default.asJson.noSpaces}
-updatePullRequests = "always"
+updatePullRequest = "always"

which results in a build failure:

error: repo-specific-configuration.md:211:1: Diff between parsed input (-) and encoded object (+):
   "signoffCommits" : true,
-  "updatePullRequest" : "always",
   "updates" : {

The encoded RepoConfig has no updatePullRequest field because that field does not exist.

@fthomas fthomas marked this pull request as ready for review February 1, 2025 14:22
Copy link
Member

@mzuehlke mzuehlke left a comment

Choose a reason for hiding this comment

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

Less likely to sneak in typos in the future 😄

@fthomas fthomas merged commit 8cb08ea into main Feb 3, 2025
18 checks passed
@fthomas fthomas deleted the topic/check-doc-2 branch February 3, 2025 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.scala-steward.conf documentation should be machine-checked
2 participants