jycouet / VSTSExtensions

MIT License
30 stars 11 forks source link

Invalid renovate.json does not fail the Azure DevOps pipeline #70

Closed KaVeKa closed 4 months ago

KaVeKa commented 4 months ago

Describe the bug When the renovate.json configuration file is invalid, the renovate Azure DevOps pipeline does not fail, but reports that everything went OK.

Maybe there is some configuration in the pipeline we are missing?

To Reproduce Steps to reproduce the behavior:

  1. Provide an incorrect renovate.json config file in your Git repository.
  2. Run renovate Azure DevOps pipeline
  3. Wait for the pipeline to be finished.

Expected behavior The Azure DevOps Pipeline fails

Screenshots image

Additional context Here is the logging output from the pipeline task:

npm WARN
 exec The following package was not found and will be installed: renovate@37.218.0

...

 INFO: Repository has invalid config (repository=<your Azure DevOps git repository>)
       "error": {
         "validationSource": "renovate.json",
         "validationError": "Duplicate keys in JSON",
         "validationMessage": "\"Syntax error: duplicated keys \\\"prConcurrentLimit\\\" near imit\\\" : 10\"",
         "message": "config-validation",
         "stack": "Error: config-validation\n    at checkForRepoConfigError (/home/vsts/.npm/_npx/59c0475bfd22776c/node_modules/renovate/lib/workers/repository/init/merge.ts:213:17)\n    at mergeRenovateConfig (/home/vsts/.npm/_npx/59c0475bfd22776c/node_modules/renovate/lib/workers/repository/init/merge.ts:237:3)\n    at getRepoConfig (/home/vsts/.npm/_npx/59c0475bfd22776c/node_modules/renovate/lib/workers/repository/init/config.ts:12:12)\n    at initRepo (/home/vsts/.npm/_npx/59c0475bfd22776c/node_modules/renovate/lib/workers/repository/init/index.ts:53:12)\n    at Object.renovateRepository (/home/vsts/.npm/_npx/59c0475bfd22776c/node_modules/renovate/lib/workers/repository/index.ts:56:14)\n    at attributes.repository (/home/vsts/.npm/_npx/59c0475bfd22776c/node_modules/renovate/lib/workers/global/index.ts:200:11)\n    at start (/home/vsts/.npm/_npx/59c0475bfd22776c/node_modules/renovate/lib/workers/global/index.ts:185:7)\n    at /home/vsts/.npm/_npx/59c0475bfd22776c/node_modules/renovate/lib/renovate.ts:18:22"
       }

...

 INFO: Renovate was run at log level "info". Set LOG_LEVEL=debug in environment variables to see extended debug logs.
jycouet commented 4 months ago

πŸ‘‹ Hi, Thank you for reporting.

I'm wondering if we can catch this as in renovate it's just an INFO: as showed in the logs. πŸ€”

KaVeKa commented 4 months ago

Thanks for the quick response!

I was also surprised to see that this was logged as INFO and not as WARN or ERROR.

However, there is clearly a structured error response from somewhere inside the renovate process. I don't know if that is accessible from somewhere in your plugin code.

KaVeKa commented 4 months ago

Not sure if this maybe helps? https://docs.renovatebot.com/config-validation/

Seems like an additional command/call that can be ran to validate the renovate config which returns a non-zero exit code?

jycouet commented 4 months ago

Okay πŸ‘

You can probably add this step in your yaml ? πŸ‘€

KaVeKa commented 4 months ago

I wouldn't know how? Can we directly call that config-validation command from the Azure DevOps pipeline? I assume that it can more easily be ran from the index.ts file in your task?

jycouet commented 4 months ago

The thing is that I'm not use Azure for a long time now. So I can't really test it... If you do the PR, I can try to build and publish and see if it's working for you?

If not, adding on your yaml, would look like:

pool:
  name: Azure Pipelines
  vmImage: ubuntu-latest

variables:
  - name: LOG_LEVEL
    value: debug
  - name: System.Debug
    value: true

steps:
  - task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@3
    displayName: 'Use Yarn 1.x'

  - task: NodeTool@0
    displayName: 'Use Node 14.15.4'
    inputs:
      versionSpec: 14.15.4

# new stuff to add πŸ‘‡πŸ‘‡πŸ‘‡
  - task: CmdLine@2
    inputs:
      script: npx THE THING HERE TO ADD

  - task: jyc.vsts-extensions-renovate-me.default-build-task.RenovateMe@0
    displayName: Renovate
KaVeKa commented 4 months ago

It took me a while to get back to, but I created a PR :) I based myself on the renovate documentation: https://docs.renovatebot.com/config-validation/

jycouet commented 4 months ago

It doesn't build on my MAC. I'll try thiw week on windows 🀞

jycouet commented 4 months ago

Should be in 1.0.3. Let me know. πŸ₯³