How to run/test renovate bot locally?
Asked Answered
T

2

7

Before I configure renovate to work with my Azure pipeline, how can I run npx renovate locally to check does it work as I expect and does my config file is well configured. I'm trying with npx renovate --platform local command.

My project is based on JS/React so I have installed renovate via npm.

I'm getting warn message: Unknown error fetching default owner preset

this is my config.js file: `const config = { extends: ['config:recommended'], };

export default config;`

I've found inside renovate documentation something related to local presets but not sure how can I configure or set it.

documentation: Local presets¶ Renovate also supports local presets, e.g. presets that are hosted on the same platform as the target repository. This is especially helpful in self-hosted scenarios where public presets cannot be used. Local presets are specified either by leaving out any prefix, e.g. owner/name, or explicitly by adding a local> prefix, e.g. local>owner/name. Renovate will determine the current platform and look up the preset from there.

info from console:

INFO: Repository finished (repository=local) "cloned": undefined, "durationMs": 434 INFO: Renovate is exiting with a non-zero code due to the following logged errors "loggerErrors": [ { "name": "renovate", "level": 50, "logContext": "LHh5xmukB832iVr6l_qFS", "repository": "local", "err": { "message": "Cannot read properties of undefined (reading '')", "stack": "TypeError: Cannot read properties of undefined (reading '')\n

this is my renovate.json file:

{
  "onboardingConfig": { "extends": ["config:recommended"] },
  "packageRules": [
    {
      "matchPackageNames": ["*"],
      "automerge": false
    }
  ]
}

this is my config.js file

module.exports = {
  platform: 'azure',
  endpoint: 'https://dev.azure.com/myend-point/',
  token: process.env.TOKEN,
  hostRules: [
    {
      hostType: 'npm',
      matchHost: 'pkgs.dev.azure.com',
      username: 'apikey',
      password: process.env.TOKEN,
    },
  ],
  repositories: ['my repository'],
};

Any help is more than welcome!

Thrashing answered 25/12, 2023 at 16:53 Comment(2)
Enable more logs maybe? There's a log level variable that you can set to DEBUG. Maybe it'll give you more info about the error.Drachm
@GaëlJ question has been updated with more info.Thrashing
P
2

It looks like there may be a problem with renovate detecting the onboarding status, as the stack trace from the full error mentions checkOnboardingBranch.

I was able to debug my renovate configuration locally by skipping the onboarding check:

LOG_LEVEL=debug npx renovate --platform=local --onboarding=false
Proliferous answered 1/8 at 2:45 Comment(0)
L
-1

If you want to validate the renovate.json only then you can use the following command to validate it locally.

npx --package renovate -c 'renovate-config-validator'

You could automate it and put the following action in the github actions to make it as part of your CI/CD workflow.

name: Renovate

on:
  pull_request_target:
    types:
    - opened
    - edited
    - synchronize
    paths:
    - .github/workflows/renovate.yaml
    - renovate.json

jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout
      uses: actions/checkout@v4
    - name: Renovate Config Validation
      uses: rinchsan/[email protected]
      with:
        pattern: 'renovate.json'

Lovel answered 23/1 at 10:47 Comment(1)
No my config is valid. I want to see what it's doing.Whiffler

© 2022 - 2024 — McMap. All rights reserved.