Skip to content

github/ci: Check if backport is opened against the expected branch#47647

Merged
thaJeztah merged 1 commit intomoby:masterfrom
vvoland:ci-backport-title
Apr 8, 2024
Merged

github/ci: Check if backport is opened against the expected branch#47647
thaJeztah merged 1 commit intomoby:masterfrom
vvoland:ci-backport-title

Conversation

@vvoland
Copy link
Contributor

@vvoland vvoland commented Mar 28, 2024

- What I did
Added a GHA check for the expected target branch on backport PRs.

- How to verify it
CI: https://github.com/moby/moby/actions/runs/8466474413/job/23195302313?pr=47647
Tested with this PR titled as [1337.0 backport] github/ci: Check if backport is opened against the expected branch

Run branch=$(echo "[1337.0 backport] github/ci: Check if backport is opened against the expected branch" | sed -n 's/^\[\([0-9]*\.[0-9]*\) backport\].*/\1/p')
PR title suggests backport to 1337.0, but PR is opened against master
Error: Process completed with exit code 1.

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

@vvoland vvoland added kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny area/testing process/cherry-pick area/project process/cherry-pick/24.0 process/cherry-pick/25.0 labels Mar 28, 2024
@vvoland vvoland added this to the 27.0.0 milestone Mar 28, 2024
@vvoland vvoland self-assigned this Mar 28, 2024
@vvoland vvoland changed the title github/ci: Check if backport is opened against the expected branch [backport 25.0] github/ci: Check if backport is opened against the expected branch Mar 28, 2024
@vvoland vvoland changed the title [backport 25.0] github/ci: Check if backport is opened against the expected branch [25.0 backport] github/ci: Check if backport is opened against the expected branch Mar 28, 2024
@vvoland vvoland force-pushed the ci-backport-title branch from fb6a8f6 to 2219548 Compare March 28, 2024 11:15
@vvoland vvoland marked this pull request as ready for review March 28, 2024 11:18
@vvoland vvoland changed the title [25.0 backport] github/ci: Check if backport is opened against the expected branch [1337.0 backport] github/ci: Check if backport is opened against the expected branch Mar 28, 2024
@vvoland vvoland changed the title [1337.0 backport] github/ci: Check if backport is opened against the expected branch github/ci: Check if backport is opened against the expected branch Mar 28, 2024
Copy link
Member

@rumpl rumpl left a comment

Choose a reason for hiding this comment

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

LGTM

@vvoland vvoland force-pushed the ci-backport-title branch from 2219548 to 8836380 Compare March 28, 2024 11:30
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

Nice!!

@thaJeztah
Copy link
Member

Left those comments; perhaps no "blockers", but as we're planning to cherry-pick this to various branches, let me know if you think they make sense (could safe time if we can cherry-pick all at once, instead of follow-up backports)

Copy link
Member

@crazy-max crazy-max left a comment

Choose a reason for hiding this comment

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

LGTM!

If we want to make this logic more readable in follow-up we could switch to https://github.com/actions/github-script and handle step context by its outcome to display an error message: https://docs.github.com/en/actions/learn-github-actions/contexts#steps-context

Also we could move this job to a reusable workflow so we would cancel all workflows at once like we do with dco: https://github.com/moby/moby/blob/master/.github/workflows/.dco.yml
see

validate-dco:
uses: ./.github/workflows/.dco.yml

@vvoland vvoland force-pushed the ci-backport-title branch from 8836380 to e533fec Compare April 3, 2024 10:38
@vvoland vvoland changed the title github/ci: Check if backport is opened against the expected branch [66.0 backport] github/ci: Check if backport is opened against the expected branch Apr 3, 2024
@vvoland vvoland force-pushed the ci-backport-title branch 3 times, most recently from c8b6a97 to c2448e9 Compare April 3, 2024 11:00
@vvoland vvoland changed the title [66.0 backport] github/ci: Check if backport is opened against the expected branch [65.0 backport] github/ci: Check if backport is opened against the expected branch Apr 3, 2024
@vvoland
Copy link
Contributor Author

vvoland commented Apr 3, 2024

Also we could move this job to a reusable workflow so we would cancel all workflows at once like we do with dco

That would mean duplicating the PR checks for every workflow though? There's also no need to re-run the PR checks with every force-push, as it only checks the PR description/labels. It only triggers on PR edits.

Unless we can keep the validate-pr as a separate workflow and then make a reusable workflow .check-validate-pr.yml that would only check the output of validate-pr.

@vvoland vvoland changed the title [65.0 backport] github/ci: Check if backport is opened against the expected branch github/ci: Check if backport is opened against the expected branch Apr 3, 2024
@vvoland vvoland force-pushed the ci-backport-title branch from c2448e9 to d6dd445 Compare April 3, 2024 11:12
@vvoland vvoland changed the title github/ci: Check if backport is opened against the expected branch github/ci: Check if backport is opened against the expected branch. Apr 3, 2024
@vvoland vvoland changed the title github/ci: Check if backport is opened against the expected branch. github/ci: Check if backport is opened against the expected branch Apr 3, 2024
@vvoland vvoland requested a review from thaJeztah April 3, 2024 11:57
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
@vvoland vvoland force-pushed the ci-backport-title branch from d6dd445 to 61269e7 Compare April 5, 2024 09:55
@vvoland vvoland requested a review from tianon April 5, 2024 09:55
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

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

Labels

area/project area/testing kind/feature Functionality or other elements that the project doesn't currently have. Features are new and shiny process/cherry-picked

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants