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

Introduce selective triggers #1001

Merged
merged 16 commits into from
Sep 24, 2024
Merged

Introduce selective triggers #1001

merged 16 commits into from
Sep 24, 2024

Conversation

godrei
Copy link
Contributor

@godrei godrei commented Sep 16, 2024

Checklist

Version

Requires a MINOR version update

Context

This PR introduced bitrise.yml data model changes to support selective build triggering (per workflow and pipeline build triggers).

Changes

  • WorkflowModel and PipelineModel got a new Triggers property
  • the new Triggers property is a structure with (for now) tree fields, that reflect the matching git event type:PushTriggers,PullRequestTriggers, and TagTriggers
  • PushTriggers ,PullRequestTriggers , andTagTriggers are lists of the related trigger items
  • trigger items follow the same structure as currently, except that type, workflow, and pipeline fields are not needed anymore and event type related parts are removed from the filter field names:
    • push trigger items' fields:
      • push_branchbranch
      • commit_message
      • changed_files
      • enabled
    • pull_request trigger items' fields:
      • pull_request_source_branchsource_branch
      • pull_request_target_branchtarget_branch
      • pull_request_labellabel
      • draft_pull_request_enableddraft_enabled
      • pull_request_commentcomment
      • commit_message
      • changed_files
      • enabled
    • tag trigger item’s fields:
      • tagname
      • enabled

Since the new triggers follow a slightly different structure than the original trigger map, the new Triggers model is manually parsed by implementing the yaml.Unmarshaler interface, to be able to warn users about misconfiguration.

E.g.: if you simply move an existing trigger map under a workflow's triggers, with the default yaml parsing bitrise validate would give this error message:

Config is valid: false
Error: config (./bitrise.yml) is not valid: yaml: unmarshal errors:
  line 12: cannot unmarshal !!seq into models.Triggers

with the custom parsing, this is the error message:

Config is valid: false
Error: config (./bitrise.yml) is not valid: 'triggers': should be a map with 'push', 'pull_request' and 'tag' keys

@godrei godrei marked this pull request as ready for review September 19, 2024 08:12
Name any `json:"name,omitempty" yaml:"name,omitempty"`
}

func (pushItem PushGitEventTriggerItem) toString() string {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: why not Stringer.String()? https://pkg.go.dev/fmt#Stringer

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because these toString functions are helper functions for finding duplicated items, the Enabled property is omitted when comparing two items.

ofalvai
ofalvai previously approved these changes Sep 20, 2024
@godrei godrei requested a review from ofalvai September 24, 2024 08:32
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.

2 participants