Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Add support for renovate bot #970

Open
prabirshrestha opened this issue Jul 10, 2023 · 7 comments
Open

[feature] Add support for renovate bot #970

prabirshrestha opened this issue Jul 10, 2023 · 7 comments
Labels
enhancement New feature or request

Comments

@prabirshrestha
Copy link

One thing I have noticed when configuring rennovate bot is that I get PRs to update package.json version for pnpm but not for moon.yml. Probably worth adding official support for moon in renovate bot. In the meantime another workaround would be to allow custom update via https://docs.renovatebot.com/configuration-options/#postupgradetasks.

@prabirshrestha prabirshrestha added the enhancement New feature or request label Jul 10, 2023
@milesj
Copy link
Collaborator

milesj commented Jul 10, 2023

@prabirshrestha I'm not very familiar with renovate. What would it do with moon.yml specifically?

@prabirshrestha
Copy link
Author

I mean .moon/toolchain.yml. It is like depandabot but works in github and you can also self host.

When I get PRs like these it only updates package.json instead of moon.yml.

prabirshrestha/moonrepo-rust-vite-template#10
prabirshrestha/moonrepo-rust-vite-template#5

-  "packageManager": "pnpm@8.6.5",
+  "packageManager": "pnpm@8.6.7",
 "engines": {
-    "node": "18.16.0"
+    "node": "18.16.1"
 }

.moon/toolchain.yml is now out of sync.

node:
  version: '18.16.0'
  packageManager: 'pnpm'
  pnpm:
    version: '8.6.5'

@vilkinsons
Copy link

Just spotted this, which would block our adoption. Unfortunately we use Renovate's hosted offering on GitHub, rather than their self-hosted version, so the workaround mentioned above doesn't work for our use case.

I've started a discussion over on the Renovate repo for anybody else tracking this.

@vilkinsons
Copy link

Renovate have responded requesting we copy/paste their template into the aforementioned discussion thread on their repo, and fill it out in full. I'm not sure I know enough about Moon at this point to do that, but if someone with more knowledge could pick this up I'd be grateful.

@prabirshrestha
Copy link
Author

The other workaround is to use regexManager and group them together. Here is an example where I have done it for other files that are not supported by renovate.

https://github.com/prabirshrestha/synology-nomad/blob/a1e955b7825b115ba1061e2c66dbf363a6e53370/renovate.json#L6-L13
https://github.com/prabirshrestha/synology-nomad/blob/a1e955b7825b115ba1061e2c66dbf363a6e53370/build.sh#L5

Would be great if someone can try it for moon. Though I would still love to have an official support in renovate for moon.

@milesj
Copy link
Collaborator

milesj commented Aug 25, 2023

I don't have time to work on this myself, and I never use renovate. But if someone wants to tackle it, I can answer any questions you may have in the Discord.

@prabirshrestha
Copy link
Author

I have got this working with custom renovate.json config with regex manager. Once you configure renovate in your repo update your renovate.json with the following config. Currently this works for moon, proto, node and rust updates. For other packages such as npm or crates it should automatically work due to config:base.

renovate.json
{
  "$schema": "https://docs.renovatebot.com/renovate-schema.json",
  "extends": [
    "config:base"
  ],
  "packageRules": [
    {
      "matchPackagePatterns": ["@adobe/*", "@react-spectrum/*", "@spectrum-icons/*", "@react-types/", "react-aria-components"],
      "groupName": "react-spectrum"
    },
    {
      "matchPackagePatterns": ["cornerstone-*", "dicom-parser", "hammerjs", "react-cornerstone-viewport", "@types/cornerstone-*", "@types/hammerjs"],
      "groupName": "dicom-cornerstone"
    },
    {
      "matchPackagePatterns": ["video.js", "videojs-*", "@types/video.js"],
      "groupName": "videojs"
    },
    {
      "matchPackageNames": ["node", "@types/node", "nodejs/node"],
      "groupName": "Node.js"
    }
  ],
  "regexManagers": [
    {
      "fileMatch": [
        "^.moon\/.*\.ya?ml$",
        "^.github\/workflows\/.*\.ya?ml$",
        "^.prototools$"
      ],
      "matchStrings": [
        ".*?(:|=)\\s+('|\\\")(=?)(?<currentValue>.*)('|\\\")\\s+#\\s+renovate: datasource=(?<datasource>.+?) depName=(?<depName>.+?)( versioning=(?<versioning>.*?))?( extractVersion=(?<extractVersion>.*?))?\\n"
      ]
    },
    {
      "fileMatch": ["^rust-toolchain\\.toml$"],
      "matchStrings": [
        "channel\\s*=\\s*\"(?<currentValue>\\d+\\.\\d+(\\.\\d+)?)\""
      ],
      "depNameTemplate": "rust-lang/rust",
      "lookupNameTemplate": "rust-lang/rust",
      "datasourceTemplate": "github-releases"
    }
  ]
}
rust

Update .moon/toolchain.yml with version: '1.73.0' # renovate: datasource=github-releases depName=rust-lang/rust

image

moon

Update ci.yml with moon-version: '1.15.3' # renovate: datasource=github-releases depName=moonrepo/moon extractVersion=^v(?<version>.*)$

update .moon/workspace.yml with versionConstraint: '=1.15.3' # renovate: datasource=github-releases depName=moonrepo/moon extractVersion=^v(?<version>.*)$

update .prototools with moon = "1.15.3" # renovate: datasource=github-releases depName=moonrepo/moon extractVersion=^v(?<version>.*)$

image

proto

Update ci.yml with proto-version: 'v0.20.1' # renovate: datasource=github-releases depName=moonrepo/proto

image

nodejs

Update .moon/toolchain.yml with version: '18.18.2' # renovate: datasource=github-tags depName=nodejs/node extractVersion=^v(?<version>.*)$

image

As you can see the moon configs now auto syncs with appropriate files when renovatebot detects a new dependency. Renovatebot allows us to run custom task. What moon needs is moon sync toolchains which we can run and will update nodejs engine version in package.json and channel version in .rust-toolchain.toml which would simplify custom configs from us. It is still worth having official support in the future but for now this should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

3 participants