Skip to content

Conversation

@Flickdm
Copy link
Member

@Flickdm Flickdm commented May 5, 2025

Description

This workflow ensures that cherry-picks are consistent and retain the relevant history for integrations.

Any PR with [Cherry Pick] or [Cherry-Pick] will trigger this workflow

It will check the following:

  1. Cherry picks contain "[CHERRY-PICK/*] *"
  2. (cherry picked from commit )

If it's a "Merge" commit the commit will be ignored. (Needed during PR)

If the commit violates one of these policies, then the PR gate will fail with the failing commit

  • Impacts functionality?
  • Impacts security?
  • Breaking change?
  • Includes tests?
  • Includes documentation?
  • Backport to release branch?

How This Was Tested

Flickdm/mu_tiano_plus#1

Integration Instructions

N/A

@Flickdm Flickdm requested review from Javagedes, apop5 and makubacki May 5, 2025 20:40
This workflow ensures that cherry-picks are consistent and
retain the relevant history for integrations.
@Flickdm Flickdm force-pushed the feature/add/cherry-pick-workflow branch from db2f817 to a15b90e Compare May 5, 2025 20:43

jobs:
cherry-pick-job:
if: contains(github.event.pull_request.title, '[cherry pick]') || contains(github.event.pull_request.title, '[cherry-pick]')
Copy link
Contributor

@Javagedes Javagedes May 5, 2025

Choose a reason for hiding this comment

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

This if seems pretty finicky to me. because someone could mess this up in many different ways with capitlization and such.

I see two good ways to solve this:

  1. Always run this, but have the first step run validation (so maybe lowercase this, remove any "-", "_", or " " in the commit message, and see if [cherrypick] is contained. Produce a variable that is used in the if check of all other steps
  2. Base this off of a label being added or removed with the trigger labeled. with the if statement being if: github.event.label.name == 'cherry-pick'

With (2) we could also have a check box in the PR for marking something as a cherry-pick. If it is a cherry-pick the auto-labeler will add the cherry-pick label, which would then cause this action to fire.

Copy link
Member Author

Choose a reason for hiding this comment

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

Honestly I would like a label but then we would need to identify a thing to be labeled and run into the same problem but I agree this is more brittle than I would like. Maybe we move this logic to the labler and then check for the existence of the label here?

Copy link
Member Author

Choose a reason for hiding this comment

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

This if seems pretty finicky to me. because someone could mess this up in many different ways with capitlization and such.

I see two good ways to solve this:

  1. Always run this, but have the first step run validation (so maybe lowercase this, remove any "-", "_", or " " in the commit message, and see if [cherrypick] is contained. Produce a variable that is used in the if check of all other steps
  2. Base this off of a label being added or removed with the trigger labeled. with the if statement being if: github.event.label.name == 'cherry-pick'

With (2) we could also have a check box in the PR for marking something as a cherry-pick. If it is a cherry-pick the auto-labeler will add the cherry-pick label, which would then cause this action to fire.

I see you edited your comment - a new box for a "cherry-pick" could be a good idea

Copy link
Contributor

Choose a reason for hiding this comment

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

As You commented on Olivers message, you confirmed contains is not case sensitive, so this is less of a concern for me. I would maybe just add cherry_pick as a possible option, worst case.

https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/evaluate-expressions-in-workflows-and-actions#contains

Copy link
Member

Choose a reason for hiding this comment

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

If we want this, I suggest the checkbox + label. Then, it is a straightforward opt-in with the label attached for further filtering versus the opportunity for typos and/or misunderstanding what the tag in the PR title means.

Copy link
Member

Choose a reason for hiding this comment

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

Can this just be added to Pull Request Formatting Validator?

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you think it makes sense to add this to the general pull request formatter? I'm happy to add it there if you think it's worth it. I was just trying to create it as a separate workflow to separate the logic

Copy link
Member

Choose a reason for hiding this comment

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

That's meant to be a collection of checks for formatting. You can still conditionalize this on a "cherry-pick trigger".

continue
fi

if [[ ! $(echo "$commit_message" | tr '[:upper:]' '[:lower:]') =~ \[cherry-pick\/.+\] ]] || [[ ! "$commit_message" =~ \(cherry\ picked\ from\ commit\ [0-9a-f]{40}\) ]]; then
Copy link
Member

Choose a reason for hiding this comment

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

The user visible messages are going to need to be more visible in the PR (comments). Many people don't know to look at actions log messages.

@makubacki
Copy link
Member

Closing for now. @Flickdm agrees.

@makubacki makubacki closed this May 22, 2025
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.

4 participants