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

feat(autodiscover): allow usage of regex patterns #13243

Merged
merged 12 commits into from Jan 18, 2022

Conversation

secustor
Copy link
Collaborator

Changes:

Allow to use regex for autodiscoverFilter.

Context:

Discussion: #13168 (comment)
Part of #8763

Documentation (please check one with an [x])

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

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

I have verified these changes via:

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

viceice
viceice previously approved these changes Dec 22, 2021
Copy link
Collaborator

@rarkins rarkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we validate the regex too?

docs/usage/self-hosted-configuration.md Show resolved Hide resolved
Co-authored-by: Rhys Arkins <rhys@arkins.net>
@secustor
Copy link
Collaborator Author

The regex is validated implicitly in https://github.com/renovatebot/renovate/blob/main/lib/util/regex.ts#L35

@rarkins
Copy link
Collaborator

rarkins commented Dec 22, 2021

What's the CLI output look like if it's invalid regex?

@secustor
Copy link
Collaborator Author

There are no explicit lines in that case, as Renovate tries to parse it with minimatch

--autodiscover-filter="/secustor/renovate.**/"

DEBUG: Adding token authentication for api.github.com to hostRules
DEBUG: Using baseDir: /tmp/renovate
DEBUG: Using cacheDir: /tmp/renovate/cache
DEBUG: Initializing Renovate internal cache into /tmp/renovate/cache/renovate/renovate-cache-v1
DEBUG: Commits limit = null
DEBUG: Autodiscovering GitHub repositories
DEBUG: None of the discovered repositories matched the filter
DEBUG: Renovate exiting
Done in 19.16s.

@rarkins
Copy link
Collaborator

rarkins commented Dec 22, 2021

That's what I wanted to avoid. If they wrap it in /.../ then we need to validate it as regex and throw an error

@secustor
Copy link
Collaborator Author

new output:

DEBUG: Adding token authentication for api.github.com to hostRules
DEBUG: Using baseDir: /tmp/renovate
DEBUG: Using cacheDir: /tmp/renovate/cache
DEBUG: Initializing Renovate internal cache into /tmp/renovate/cache/renovate/renovate-cache-v1
DEBUG: Commits limit = null
DEBUG: Autodiscovering GitHub repositories
ERROR: Failed to parse regex pattern
       "autodiscoverFilter": "/secustor/renovate.**/"
DEBUG: Renovate exiting
 INFO: Renovate is exiting with a non-zero code due to the following logged errors
       "loggerErrors": [
         {
           "name": "renovate",
           "level": 50,
           "logContext": "BVXKuSQ9RE7oWF7FrLw8u",
           "autodiscoverFilter": "/secustor/renovate.**/",
           "msg": "Failed to parse regex pattern"
         }
       ]

docs/usage/self-hosted-configuration.md Outdated Show resolved Hide resolved
docs/usage/self-hosted-configuration.md Outdated Show resolved Hide resolved
Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
viceice
viceice previously approved these changes Jan 5, 2022
@rarkins rarkins enabled auto-merge (squash) January 18, 2022 15:53
@rarkins rarkins merged commit e406cd1 into renovatebot:main Jan 18, 2022
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 31.30.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@@ -72,4 +72,42 @@ describe('workers/global/autodiscover', () => {
const res = await autodiscoverRepositories(config);
expect(res).toEqual(config);
});
it('filters autodiscovered github repos with regex', async () => {
config.autodiscover = true;
config.autodiscoverFilter = '/project/re*./';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This expression isn't wrong per se, but I would consider it confusing.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2022
@secustor secustor deleted the discoveryFilterRegex branch December 4, 2022 15:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants