FAQ | This is a LIVE service | Changelog

Add preset for running a pre-commit hook

As part of generalising some recent work in user-notify, create a preset for running a pre-commit hook as a post-upgrade task. This preset can then be shared between the way we run black hooks and run terraform-docs hooks.

Call the preset postUpgradeRunPreCommitHook and we'd intend it to be used from other presets. For example, for the terraform-docs rule:

{
  // ...
  "packageRules": [
    {
      "extends": [
        "local>uis/devops/renovate-config:postUpgradeRunPreCommitHook(terraform-docs)"
      ],
      "matchManagers": [
        "terraform",
        "copier"
      ],
      "matchDepTypes": [
        "required_provider",
        "template"
      ]
    }
  ]
}

The preset itself will consist of something akin to:

{
  "postUpgradeTasks": {
    "commands": [
      "containerbase-cli install tool python 3.14.2",
        "containerbase-cli install pip pre-commit 4.5.1",
        "pre-commit hazmat ignore-exit-code pre-commit run --all-files {{arg0}}",
        "pre-commit run --all-files {{arg0}}"
      ],
    "executionMode": "branch"
  }
}

Making use of preset parameters.

Add configuration to the renovate.json in this project to keep the containerbase-cli commands fresh:

{
  // ...
  "customManagers": [
    {
      "customType": "regex",
      "managerFilePatterns": [
        "renovate.json"
      ],
      "matchStrings": [
        "\"containerbase-cli install tool (?<tool>\\S+) (?<currentValue>[0-9]+\\.[0-9]+\\.[0-9]+)\""
      ],
      "packageNameTemplate": "containerbase/{{ tool }}-prebuild",
      "depNameTemplate": "containerbase/{{ tool }}",
      "datasourceTemplate": "github-releases",
      "versioningTemplate": "semver-coerced"
    },
    {
      "customType": "regex",
      "managerFilePatterns": [
        "renovate.json"
      ],
      "matchStrings": [
        "\"containerbase-cli install pip (?<depName>\\S+) (?<currentValue>\\S+)\""
      ],
      "datasourceTemplate": "pypi"
    }
  ]
}