renovatebot / renovate

Home of the Renovate CLI: Cross-platform Dependency Automation by Mend.io
https://mend.io/renovate
GNU Affero General Public License v3.0
16.51k stars 2.12k forks source link

Regex versioning relies on semver in a way which blocks 4-part versions #27510

Open rarkins opened 4 months ago

rarkins commented 4 months ago

Describe the proposed change(s).

Example code: https://github.com/renovatebot/renovate/blob/fe56ee0d7c4160838a7f3b5ac6fe44d838b57a5f/lib/modules/versioning/regex/index.ts#L116-L130

This means that regex versioning like this isn't fully supported: "versioning": "regex:^(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)\\.(?<build>\\d+)$"

viceice commented 4 months ago

🤔 it's working fine for bitnami docker image updates which have 5 parts.

rarkins commented 4 months ago

Maybe getSatisfyingVersion() wasn't ever called except when my changes triggered it

viceice commented 4 months ago

maybe. do you have a reproduction?

viceice commented 4 months ago

oh, I see. here are some versions no longer detected

so this is a critical bug

viceice commented 4 months ago

repro: https://github.com/renovate-reproductions/27510-multipart-regex-versioning

bitnami versioning works, but forgejo not 🤔

DEBUG: packageFiles with updates (repository=renovate-reproductions/27510-multipart-regex-versioning, baseBranch=main)
       "config": {
         "dockerfile": [
           {
             "deps": [
               {
                 "depName": "codeberg.org/forgejo/forgejo",
                 "currentValue": "1.21.5-0-rootless",
                 "replaceString": "codeberg.org/forgejo/forgejo:1.21.5-0-rootless",
                 "autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
                 "datasource": "docker",
                 "depType": "stage",
                 "updates": [],
                 "packageName": "codeberg.org/forgejo/forgejo",
                 "versioning": "regex:^(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)-(?<build>\\d+)(?:-(?<compatibility>.+))?$",
                 "warnings": [],
                 "registryUrl": "https://codeberg.org",
                 "currentVersion": "1.21.5",
                 "skipReason": "invalid-version"
               },
               {
                 "depName": "codeberg.org/forgejo/forgejo",
                 "currentValue": "1.21.5-0-rootless",
                 "currentDigest": "sha256:f23f56a0a1f53fa9f3ffbbb19aad3afef180fad7f8d4250174363ecab80d5166",
                 "replaceString": "codeberg.org/forgejo/forgejo:1.21.5-0-rootless@sha256:f23f56a0a1f53fa9f3ffbbb19aad3afef180fad7f8d4250174363ecab80d5166",
                 "autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
                 "datasource": "docker",
                 "depType": "stage",
                 "updates": [],
                 "packageName": "codeberg.org/forgejo/forgejo",
                 "versioning": "regex:^(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)-(?<build>\\d+)(?:-(?<compatibility>.+))?$",
                 "warnings": [],
                 "registryUrl": "https://codeberg.org",
                 "currentVersion": "1.21.5",
                 "skipReason": "invalid-version"
               },
               {
                 "depName": "bitnami/nginx",
                 "currentValue": "1.24.0-debian-12-r15",
                 "replaceString": "bitnami/nginx:1.24.0-debian-12-r15",
                 "autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
                 "datasource": "docker",
                 "depType": "stage",
                 "updates": [
                   {
                     "bucket": "non-major",
                     "newVersion": "1.25.4-debian-12-r2",
                     "newValue": "1.25.4-debian-12-r2",
                     "newMajor": 1,
                     "newMinor": 25,
                     "updateType": "minor",
                     "branchName": "renovate-test/bitnami-nginx-1.x"
                   }
                 ],
                 "packageName": "bitnami/nginx",
                 "versioning": "regex:^(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)(:?-(?<compatibility>.+)-(?<build>\\d+)(?:-r(?<revision>\\d+))?)?$",
                 "warnings": [],
                 "registryUrl": "https://index.docker.io",
                 "currentVersion": "1.24.0",
                 "isSingleVersion": true,
                 "fixedVersion": "1.24.0-debian-12-r15"
               },
               {
                 "depName": "bitnami/nginx",
                 "currentValue": "1.24.0-debian-12-r15",
                 "currentDigest": "sha256:a842d93d1903fab7b7cf01a226331bd62e45dc5e39a5e19517e054d977ef9bc3",
                 "replaceString": "bitnami/nginx:1.24.0-debian-12-r15@sha256:a842d93d1903fab7b7cf01a226331bd62e45dc5e39a5e19517e054d977ef9bc3",
                 "autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
                 "datasource": "docker",
                 "depType": "final",
                 "updates": [
                   {
                     "bucket": "non-major",
                     "newVersion": "1.25.4-debian-12-r2",
                     "newValue": "1.25.4-debian-12-r2",
                     "newMajor": 1,
                     "newMinor": 25,
                     "updateType": "minor",
                     "newDigest": "sha256:8936f5a21ad81326147fc75795222882a083bec04e8e46e4b22adb5ef56d662f",
                     "branchName": "renovate-test/bitnami-nginx-1.x"
                   }
                 ],
                 "packageName": "bitnami/nginx",
                 "versioning": "regex:^(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)(:?-(?<compatibility>.+)-(?<build>\\d+)(?:-r(?<revision>\\d+))?)?$",
                 "warnings": [],
                 "registryUrl": "https://index.docker.io",
                 "currentVersion": "1.24.0",
                 "isSingleVersion": true,
                 "fixedVersion": "1.24.0-debian-12-r15"
               }
             ],
             "packageFile": "Dockerfile"
           }
         ]
       }
viceice commented 4 months ago

my repro is a different issue

https://github.com/renovatebot/renovate/blob/29e9707a6cc0f98ab97ddf1f2e50daa33606d64a/lib/workers/repository/process/lookup/index.ts#L319-L323

currentVersion is of cause not a valid version on my regex!

viceice commented 4 months ago

https://github.com/renovatebot/renovate/blob/29e9707a6cc0f98ab97ddf1f2e50daa33606d64a/lib/workers/repository/process/lookup/current.ts#L40-L47

getSatisfyingVersion needs to return the original version, not the coerced.