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

Automation Rules: support external versions #7664

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stsewd
Copy link
Member

@stsewd stsewd commented Nov 12, 2020

Allow to build an external version based on its source and base branch.

  • Use a namedtuple to pass more data about the external version around
  • Automation rules can now receive extra kwargs to be passed down to the match and action functions
  • Automation rules now return a tuple, the first element indicate if rule matched and the second is the return value from the action,
    this was done, so we can know if the build was triggered or not for external versions.
  • Moved the actions to the base class, since it doesn't look like we are going to have a different set of actions
  • If the user doesn't have automation rules for external versions we just build everything as before,
    but if the user has at least one, we use the rules to trigger the build.

Maybe wait for the new templates? Or maybe not as this is modifying just the js code.

Screenshot_2020-11-12 Automation Rule Read the Docs

Ref #7653

Front logo Front conversations

@stsewd stsewd added the PR: work in progress Pull request is not ready for full review label Nov 12, 2020
@stsewd stsewd force-pushed the automation-rules-pr branch 8 times, most recently from c4c6dc9 to 1aaa918 Compare November 16, 2020 22:18
for regex in GITHUB_REGEXS:
match = regex.search(url)
for pattern in GITHUB_REGEXS:
match = pattern.search(url)
Copy link
Member Author

Choose a reason for hiding this comment

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

the linter doesn't like having these named regex.

- Use a namedtuple to pass more data about the external version around
- Automation rules can now receive extra kwargs to be passed down to the match and action functions
- Automation rules now return a tuple, the first element indicate if rule matched and the second is the return value from the action,
this was done, so we can know if the build was triggered or not for external versions.
- Moved the actions to the base class, since it doesn't look like we are going to have a different set of actions
- If the user doesn't have automation rules for external versions we just build everything as before,
  but if the user has at least one, we use the rules to trigger the build.

Ref #7653
@stsewd stsewd force-pushed the automation-rules-pr branch from 1aaa918 to de246b9 Compare November 16, 2020 22:38
@stsewd stsewd removed the PR: work in progress Pull request is not ready for full review label Nov 16, 2020
@stsewd stsewd marked this pull request as ready for review November 16, 2020 22:39
@stsewd
Copy link
Member Author

stsewd commented Nov 16, 2020

This is ready, but maybe wait for the new templates? Or maybe not as this is modifying just the js code.

Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

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

This looks like a good refactor. I didn't do a full review of it, but wanted to throw a couple comments in here.

This feels really valuable, especially the bits around limiting PR building based on regex. I think reducing our PR build load is going to be important going forward, so having more options for this would be really useful. Another area I've thought about having the option to build PR's is on the list of modified files. That's a larger change though for sure :)

- Base branch: ``^main$``
- Action: ``Build version``

Build all pull request where the source branch has the ``docs/`` prefix
Copy link
Member

Choose a reason for hiding this comment

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

This is super useful, and we should probably be promoting this more.

@@ -133,6 +138,7 @@ def __init__(self, *args, **kwargs):
(None, '-' * 9),
(BRANCH, BRANCH_TEXT),
(TAG, TAG_TEXT),
(EXTERNAL, EXTERNAL_TEXT),
Copy link
Member

Choose a reason for hiding this comment

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

Pretty sure we aren't meant to show this to users. I think we want

GITHUB_EXTERNAL_VERSION_NAME = 'Pull Request'

)
return match
except TimeoutError:
log.warning(
Copy link
Member

Choose a reason for hiding this comment

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

We should probably make this an error, so we get it in Sentry if someone is messing with things.

pattern, text,
)
except Exception as e:
log.info('Error parsing regex: %s', e)
Copy link
Member

Choose a reason for hiding this comment

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

Similarly here -- seems bad to just log this exception. We probably want log.exception

stsewd added a commit that referenced this pull request Nov 23, 2020
stsewd added a commit that referenced this pull request Nov 23, 2020
Some times we may want to pass additional data around to the match and
action functions.

This is data that isn't available in the version object.
Like the extra data needed to match external versions.

We also need to return the response of the action,
this is to allow the caller know what happened in the action.

This was extracted from #7664
stsewd added a commit that referenced this pull request Nov 23, 2020
Some times we may want to pass additional data around to the match and
action functions.

This is data that isn't available in the version object.
Like the extra data needed to match external versions.

We also need to return the response of the action,
this is to allow the caller know what happened in the action.

This was extracted from #7664
@stsewd
Copy link
Member Author

stsewd commented Nov 23, 2020

I have split this into 2 PRs

There would be third if we agree with #7653 (comment)

After those PRs are merged I'll update this one, the changes should be more small :)

@stale
Copy link

stale bot commented Jan 17, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: stale Issue will be considered inactive soon label Jan 17, 2021
@stsewd stsewd removed the Status: stale Issue will be considered inactive soon label Jan 19, 2021
@stale
Copy link

stale bot commented Jun 2, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: stale Issue will be considered inactive soon label Jun 2, 2021
@ericholscher ericholscher added the Accepted Accepted issue on our roadmap label Jun 2, 2021
@stale stale bot removed the Status: stale Issue will be considered inactive soon label Jun 2, 2021
stsewd added a commit that referenced this pull request Mar 2, 2022
@humitos
Copy link
Member

humitos commented Mar 15, 2022

Today I had a user request wanting to "exclude PR builds on matching branch names". As an example, they don't want to build PR when the branch starts with dependabot/. Would this PR allow this use case?

@stsewd
Copy link
Member Author

stsewd commented Mar 28, 2022

Today I had a user request wanting to "exclude PR builds on matching branch names". As an example, they don't want to build PR when the branch starts with dependabot/. Would this PR allow this use case?

that should be supported with this PR, yeah.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Accepted issue on our roadmap
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants