Skip to content

Builds: automation rules v2#12848

Open
humitos wants to merge 49 commits intomainfrom
humitos/webhook-filters-v2
Open

Builds: automation rules v2#12848
humitos wants to merge 49 commits intomainfrom
humitos/webhook-filters-v2

Conversation

@humitos
Copy link
Copy Markdown
Member

@humitos humitos commented Mar 16, 2026

This is the initial proposal to migrate our current VersionAutomationRules and RegexAutomationRules to only one model called AutomationRule as discussed.

I created a basic UI just to be able to use the feature; but we need to work on ext-theme for that. I think it won't be a lot of work, but we need:

  • version_types should be a multi-select field
  • version_match_pattern should be shown/hidden based on another input value
List view Detail view
Screenshot_2026-03-16_17-35-11 Screenshot_2026-03-17_15-57-27

@humitos
Copy link
Copy Markdown
Member Author

humitos commented Mar 17, 2026

@copilot can you create a new PR based on this one to update the test cases matching the code changes?

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 17, 2026

@humitos I've opened a new pull request, #12850, to work on those changes. Once the pull request is ready, I'll request review from you.

@read-the-docs-community
Copy link
Copy Markdown

read-the-docs-community bot commented Mar 17, 2026

Documentation build overview

📚 dev | 🛠️ Build #32186922 | 📁 Comparing d46be50 against latest (50e8d78)

  🔍 Preview build  

Show files changed (2 files in total): 📝 2 modified | ➕ 0 added | ➖ 0 deleted
File Status
aws-temporary-credentials.html 📝 modified
tests.html 📝 modified

return diff.seconds


class VersionAutomationRule(PolymorphicModel, TimeStampedModel):
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I will delete this model in a following PR and migration. We are not using it anymore.

@humitos humitos marked this pull request as ready for review March 17, 2026 16:56
@humitos humitos requested a review from a team as a code owner March 17, 2026 16:56
@humitos humitos requested a review from stsewd March 17, 2026 16:56
Copy link
Copy Markdown
Member

@stsewd stsewd left a comment

Choose a reason for hiding this comment

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

Looks like this is missing moving the models and forms to the projects app.

Comment on lines +611 to +618
rule_triggered_for_project = True
rule_triggered_for_version = True
rule.run(version)

# We only trigger the first matching rule,
# We only trigger the first matching rule per version
# to avoid triggering multiple builds for the same tag/branches.
break
if rule_triggered_for_version:
break
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There is no need to track this in two variables. Since you only want to know if at least one rule matched, you can use a single variable.

Suggested change
rule_triggered_for_project = True
rule_triggered_for_version = True
rule.run(version)
# We only trigger the first matching rule,
# We only trigger the first matching rule per version
# to avoid triggering multiple builds for the same tag/branches.
break
if rule_triggered_for_version:
break
rule_triggered = True
rule.run(version)
# We only trigger the first matching rule per version
# to avoid triggering multiple builds for the same tag/branches.
break

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We need to check all the rules for all the versions. Using only one variable, if the first rule is triggered on the first version, we will be skipping the other versions.

Copy link
Copy Markdown
Contributor

@agjohnson agjohnson left a comment

Choose a reason for hiding this comment

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

There's some needed on the UI side but overall this looks good.

project = forms.CharField(widget=forms.HiddenInput(), required=False)

VERSION_TYPE_CHOICES = [
RichChoice(text=name, value=value, description="description", disabled=False)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note to update the description here. The description is a good place to describe the types in more detail, instead of cramming that information into the option name.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I added description because it was mandatory, basically. I don't know what could be a good description here. They are just version types 🤷🏼 . Do you have any suggestion for each of them?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Description is the main reason to use RichSelect. Otherwise if you just need a basic list of items you would just continue using a basic select widget. RichSelect is only needed if you want additional information like a description or image with each option.

In this case, there is a Django multi select widget that you probably want to use. I`m pretty sure we've used it elsewhere, I think with team project selection -- if you need an example.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, I only want a multi select field, but I wasn't able to find an example where we use it. I want exactly what I posted in the video (#12848 (comment)) but without the description.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Great! I found the example you said...

Screenshot_2026-04-09_18-38-23

I will check its code and update this PR. 👍🏼

Comment on lines +729 to +742
class CommaSeparatedMultipleChoiceField(forms.MultipleChoiceField):
"""Handle comma-separated values for a single hidden input."""

hidden_widget = forms.HiddenInput

def to_python(self, value):
if isinstance(value, str):
value = [item.strip() for item in value.split(",") if item.strip()]
return super().to_python(value)

def prepare_value(self, value):
if isinstance(value, (list, tuple)):
return ",".join(value)
return super().prepare_value(value)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is this a comma separated value? It's not really clear what UX you're aiming for here, but I think you likely want something that SUI already gives us.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I had to use a comma separated value because of SUI actually 😄 . That's how it handle multiple choice fields. It ends up with value=branch,tag

The UX is to be able to select multiple items. It works as I want now:

Peek.2026-04-09.10-59.webm

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah that looks great. There are other options for getting that data into the SUI module without altering the data on the application side. But the effect is identical either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build: webhook filters v2

4 participants