renovate icon indicating copy to clipboard operation
renovate copied to clipboard

feat(datasource): Add python-version datasource

Open not7cd opened this issue 11 months ago • 5 comments

Changes

Adds Python releases as Datasource.

Context

https://github.com/renovatebot/renovate/discussions/27581

Documentation (please check one with an [x])

  • [x] I have updated the documentation, or
  • [ ] No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • [ ] Code inspection only, or
  • [x] Newly added/modified unit tests, or
  • [ ] No unit tests but ran on a real repository, or
  • [ ] Both unit tests + ran on a real repository

not7cd avatar Feb 27 '24 13:02 not7cd

re: request hungry

This is data source is cached. And I see 3 requests if Python version is detected:

  • python.org for all versions
  • endoflife.date for EOL status
  • github releases for prebuilt versions

I don't see any way around it. No data source has all the data. Maybe python.org could be dropped in favour of using only containerbase/python, but this is the source of truth.

not7cd avatar Mar 29 '24 22:03 not7cd

I found that Python versioning is not returning newValue. I have implemented proper function by reusing poetry.getNewValue. It worked, and it created a PR.

Here is a working config.

"customManagers": [
    {
      "description": "Extract Python version",
      "customType": "regex",
      "fileMatch": ["^Dockerfile$"],
      "matchStringsStrategy": "any",
      "matchStrings": ["ARG PYTHON_VERSION=\"?(?<currentValue>3(?<minor>\\d+))\"?\\s"],
      "autoReplaceStringTemplate": "ARG PYTHON_VERSION={{{replace '\\.' '' newValue}}}\n",
      "currentValueTemplate": "3.{{{minor}}}",
      "datasourceTemplate": "python-version",
      "versioningTemplate": "python",
      "depNameTemplate": "python"
    }
  ]
My debugging process I'm testing this PR with above configuration.

The package is found, but no updates are assigned

{
             "deps": [
               {
                 "depName": "python",
                 "currentValue": "3.11",
                 "datasource": "python-version",
                 "versioning": "python",
                 "replaceString": "ARG PYTHON_VERSION=311\n",
                 "updates": [],
                 "packageName": "python",
                 "warnings": [],
                 "sourceUrl": "https://github.com/python/cpython",
                 "registryUrl": "https://www.python.org/api/v2/downloads/release",
                 "homepage": "https://python.org",
                 "currentVersion": "3.11.8",
                 "fixedVersion": "3.11"
               }
             ],
             "matchStrings": [
               "ARG PYTHON_VERSION=\"?(?<currentValue>3(?<minor>\\d+))\"?\\s"
             ],
             "matchStringsStrategy": "any",
             "depNameTemplate": "python",
             "currentValueTemplate": "3.{{{minor}}}",
             "datasourceTemplate": "python-version",
             "versioningTemplate": "python",
             "autoReplaceStringTemplate": "ARG PYTHON_VERSION={{{newValue}}}",
             "packageFile": "Dockerfile"
}
           

I think this is somehow connected with python versioning module.

For example Dockerfile:

ARG PYTHON_VERSION=311
ARG BASE_IMAGE_TAG=2.1.12

FROM baseimage-python${PYTHON_VERSION}-builder:${BASE_IMAGE_TAG}

Proper versions are detected in lookupUpdates

 "allSatisfyingVersions": [
         {
           "version": "3.11.0",
           "isStable": true,
           "isDeprecated": false,
           "releaseTimestamp": "2022-10-24T19:19:12.000Z"
         },
         {
           "version": "3.11.1", ...
         },
        ...
         {
           "version": "3.11.8", ...
         }
       ],
 "filteredReleases": [
         {
           "version": "3.12.0",
           "isStable": true,
           "isDeprecated": false,
           "releaseTimestamp": "2023-10-02T12:50:09.000Z"
         },
         {
           "version": "3.12.1", ...
         },
         {
           "version": "3.12.2", ...
         }
       ]

I have debugged generateUpdate

      "newVersion": "3.12.2",
      "compareValue": "3.11",
      "bucket": "non-major",
      "release": {
        "version": "3.12.2",
        "isStable": true,
        "isDeprecated": false,
        "releaseTimestamp": "2024-02-06T21:40:35.000Z"
      },
      "update": {
        "bucket": "non-major",
        "newVersion": "3.12.2",
        "newValue": null,
        "releaseTimestamp": "2024-02-06T21:40:35.000Z",
        "newMajor": 3,
        "newMinor": 12,
        "updateType": "minor",
        "isRange": true
      }

not7cd avatar Apr 02 '24 19:04 not7cd

The docs look okay to me. I'll let a maintainer check for technical accuracy.

can you please create an issue to validate relative links with docs tests?

viceice avatar Apr 21 '24 19:04 viceice

Is there anything blocking release of this data source?

not7cd avatar May 02 '24 13:05 not7cd

I think we're good to go.

HonkingGoose avatar May 02 '24 13:05 HonkingGoose

:tada: This PR is included in version 37.366.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

renovate-release avatar May 16 '24 10:05 renovate-release