-
Notifications
You must be signed in to change notification settings - Fork 21
Configure Renovate to update descriptor dependencies #201
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
Thank you very much for this PR! It really makes sense to add automation here, but changes in the kernel are of course required first. And not to break existing notebooks, old JSON files should be left in place for some time. We can possibly stop updating them now, and as people will gradually switch to the new version of kernel, remove them. The logic for As it is quite a big change, I'd like to think twice. Also, isn't it possible to add automation without adding comments? For example, it's the way we do versions completion for our descriptors. doesn't Renovate allow to run any code on demand to extract dependencies? |
Hello there!
To be honest, I only realized it'd break usages of 1. "Fake" properties instead of the comments (I prefer this one)
{
"properties": {
- // update: package=org.jetbrains.kotlinx:kotlinx-coroutines-core
+ "v-metadata": "update: package=org.jetbrains.kotlinx:kotlinx-coroutines-core",
"v": "1.5.2"
},
"dependencies": [
"org.jetbrains.kotlinx:kotlinx-coroutines-core:$v",
]
} 2. Add one matcher in Renovate config per library descriptor
"regexManagers": [
- // Matches properties commented with "// update: package=group:artifact"
- {
- "datasourceTemplate": "maven",
- "versioningTemplate": "maven",
- "fileMatch": [".*\\.json5"],
- "matchStrings": [
- "\/\/ update: package=(?<packageName>\\S+)\\s+\"(?<depName>.*?)\": ?\"(?<currentValue>.+?)\"",
- "\/\/ update: package=(?<packageName>\\S+)\\s+{\"name\": \"(?<depName>.*?)\", \"value\": \"(?<currentValue>.+?)\"",
- ]
- },
+ // Matches coroutines / 'v' property
+ {
+ "datasourceTemplate": "maven",
+ "versioningTemplate": "maven",
+ "fileMatch": ["coroutines\\.json"],
+ "depNameTemplate": "v",
+ "packageNameTemplate": "org.jetbrains.kotlinx:kotlinx-coroutines-core"
+ "matchStrings": [
+ "\"v\": ?\"(?<currentValue>.+?)\"",
+ ]
+ },
+ // Matches coroutines / 'extrasVersion' property
+ {
+ "datasourceTemplate": "maven",
+ "versioningTemplate": "maven",
+ "fileMatch": ["coroutines\\.json"],
+ "depNameTemplate": "extrasVersion",
+ "packageNameTemplate": "org.jetbrains.kotlinx:kotlinx-coroutines-extras"
+ "matchStrings": [
+ "\"extrasVersion\": ?\"(?<currentValue>.+?)\"",
+ ]
+ },
+ // Matches example / 'version' property
+ {
+ "datasourceTemplate": "maven",
+ "versioningTemplate": "maven",
+ "fileMatch": ["example\\.json"],
+ "depNameTemplate": "version",
+ "packageNameTemplate": "group:artifact"
+ "matchStrings": [
+ "\"version\": ?\"(?<currentValue>.+?)\"",
+ ]
+ },
], |
Yes, I like the first approach. It shouldn't cause any issues. I'm only concerned about naming, maybe we should call these properties like |
Just updated with the first approach. Your name suggestion was better, I used it :) I verified that Renovate and descriptors (a few, locally) are still working fine. Shouldn't require any changes to Kernel now, right? I only think there should a note to new contributors about the hints in the "adding libraries" doc. Would you rather update it yourself or can I open a PR? |
I thought a bit, and it seems that this change is also a bit incompatible. Namely, for descriptors that had only one property it was possible to write And one more concern here. We have ordered syntax for properties:
This allows users to write |
Sure, I can work on that.
You mean this, just so that "v" comes first, or something else (like alphabetically)? "properties": {
- "v-renovate-hint": "update: package=org.jetbrains.kotlinx:kotlinx-coroutines-core",
- "v": "1.5.2",
- "api-renovate-hint": "update: package=org.jetbrains.kotlinx:kotlinx-coroutines-core",
- "api": "1.5.2"
+ "v": "1.5.2",
+ "v-renovate-hint": "update: package=org.jetbrains.kotlinx:kotlinx-coroutines-core"
+ "api": "1.5.2"
+ "api-renovate-hint": "update: package=org.jetbrains.kotlinx:kotlinx-coroutines-core",
}, |
No, I mean using JSON array instead of JSON object for {
- "properties": {
- "v-renovate-hint": "update: package=org.jetbrains.kotlinx:kotlinx-coroutines-core",
- "v": "1.5.2",
- "api-renovate-hint": "update: package=org.jetbrains.kotlinx:kotlinx-coroutines-core",
- "api": "1.5.2"
- }
+ "properties": [
+ {"name": "v", "value": "1.5.2"},
+ {"name": "api", "value": "1.5.2"},
+ {"name": "v-renovate-hint", "value": "update: package=org.jetbrains.kotlinx:kotlinx-coroutines-core"},
+ {"name": "api-renovate-hint", "value": "update: package=org.jetbrains.kotlinx:kotlinx-coroutines-core"}
+ ],
} |
Unfortunately, we're limited when it comes to sorting. We need the hint properties to be either immediately above or below its "target" property. Renovate uses RE2 for Regex, which means I cannot backreference like However, I think we could preserve the current behavior of |
Ok, let's then unite these approaches:
|
So I updated for hints to come after their target properties (number 2). Correct me if I'm wrong, but number 3 (removing hints kernel-side) will already restore number 1 (using ordered syntax). Also, do we still need to move properties to the full syntax |
Add a Renovate config with regex matchers for dependencies of library descriptors, matching hint properties added to each descriptor. Hint properties are an alternative to comments, which aren't supported in JSON. Migrating to another format isn't feasible because it'd make descriptors incompatible with existing Kernel versions when `%useLatestDescriptors` is used. Migrate descriptors to ordered properties syntax to preserve behavior of single-property unnamed overrides in old Kernel versions. Multi-property unnamed overrides will break.
@gabrielfeo Thank you, it works cool! I just wanted to ask, can we somehow skip updates to the versions containing "dev" and "SNAPSHOT"? Could you please adjust the config correspondingly? |
@ileasile glad to see it working! The dev and SNAPSHOT updates are unexpected, however. Based on the docs, PRs like #218 and #222 shouldn't exist. I'll look into it
|
Maybe versions starting with 0. are also considered unstable? IDK |
Yep, I'm thinking the same thing. Let me confirm and we can make a custom rule to match those currently at 0.x, if that's the case. |
This PR configures Renovate to open PRs updating versions of library descriptor dependencies automatically, aiming to ease the burden on maintainers and contributors :)
The end result can be seen in the fork:
Problem
Dependency descriptors are a good solution and easy to contribute to. However, the common issue of keeping dependencies up-to-date also applies to descriptor dependencies. As a result, when one wants to write a quick-and-dirty notebook today, without the need to pin versions, one gets very old versions of libraries. Pinning versions can be recommended for various reasons, but the default (no pinning) should bring in the latest version.
For example, the notebook below would fail to compile, because while
shutdown
was introduced in1.6.0
(and the latest is1.6.4
), the descriptor is still a minor behind at1.5.2
.There are other examples, like slf4j still at
1.7.25
while2.0.7
is the latest.Solution
A Renovate config is added. Basically, descriptor properties which refer to a package's version now have a "hint property" below them stating on which package updating should be based on.
The Renovate config has a regex to parse such properties as long as it's immediately followed by a hint property, as well as any dependencies that hardcode versions without properties. More details in the config.
Hint properties are an alternative to comments, which aren't supported in JSON. Migrating to another format isn't feasible because it'd make descriptors incompatible with existing Kernel versions when
%useLatestDescriptors
is used.Behavior in old kernel versions
Usages of unnamed properties in notebooks together with
%useLatestDescriptors
in old versions of the Kernel (before the Kernel was updated to disregard hint properties), will break for multiple-property overrides:But unnamed overrides of single-property descriptors as below will still work, thanks to migrating all descriptors to the "ordered properties syntax":
Enabling Renovate
Renovate can either be activated as a GitHub App or as a GitHub action. It works better as a GitHub app because it responds instantly when a PR checkbox is checked, just like Dependabot, but it'll probably require installation at the Kotlin org-level. If that's not possible, I can add the action to this PR, set to run in a schedule.