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

add checks for PRs to release branchs #7

Merged
merged 7 commits into from
Feb 6, 2025

Conversation

achou11
Copy link
Member

@achou11 achou11 commented Feb 6, 2025

Towards #4

Adds the following checks:

  1. Makes sure any PR to a release/* branch is an RC branch (i.e. starts with rc/)

  2. Makes sure the version introduced by the RC PRs:

  • is not a pre-release
  • matches the branch name

Still missing:

  • check to make sure the version bump is correct EDIT: to be done as a follow-up

Question: should we rename the workflow file? Introducing the job that has these checks makes the name Check Release Branch a little unclear to me. EDIT: I've renamed the worfklow file to be more explicit (see 8ca1c89)

@achou11 achou11 requested a review from gmaclennan February 6, 2025 18:46
@achou11 achou11 force-pushed the ac/assert-rc-branch-to-release-branch branch from 638bb4b to 8b20418 Compare February 6, 2025 18:58
@achou11 achou11 changed the title assert PR to release branch is from RC branch add checks for PRs to release branchs Feb 6, 2025
Comment on lines 50 to 54
- name: Get branch name of the PR
id: pr_branch_name
run: |
pr_branch_name=$(git branch --show-current)
echo "result=$PR_BRANCH_NAME" >> $GITHUB_OUTPUT
Copy link
Member Author

Choose a reason for hiding this comment

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

there might be a better way of doing this

Copy link
Member

Choose a reason for hiding this comment

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

yes, github.head_ref (doesn't require checkout)

Copy link
Member Author

Choose a reason for hiding this comment

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

does parsing the version (used in other steps) need checkout though?

Copy link
Member

Choose a reason for hiding this comment

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

yes

.github/workflows/check-release-branch.yml Outdated Show resolved Hide resolved
@achou11 achou11 force-pushed the ac/assert-rc-branch-to-release-branch branch from abcf624 to 6fa5629 Compare February 6, 2025 20:57
Copy link
Member

@gmaclennan gmaclennan left a comment

Choose a reason for hiding this comment

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

Is fine as-is, but left some suggestions if you want to save some character :)

Comment on lines 56 to 64
- name: Assert pull request is created from a RC branch
env:
PR_BRANCH_NAME: ${{ steps.pr_branch_name.outputs.result }}
run: |
set -x
if [ $PR_BRANCH_NAME != rc/* ]; then
echo "Pull request to release branch must come from RC branch"
exit 1
fi
Copy link
Member

Choose a reason for hiding this comment

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

Could be worth asserting PR is from an RC branch with a separate job to keep it simple:

    check_source_branch:
        name: Check Source Branch
        runs-on: ubuntu-latest

        steps:
            - name: Check Source Branch
              if: ${{ !startsWith(github.head_ref, 'rc/') }}
              run: exit 1

Copy link
Member Author

Choose a reason for hiding this comment

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

addressed via 2ad1832

Comment on lines 50 to 54
- name: Get branch name of the PR
id: pr_branch_name
run: |
pr_branch_name=$(git branch --show-current)
echo "result=$PR_BRANCH_NAME" >> $GITHUB_OUTPUT
Copy link
Member

Choose a reason for hiding this comment

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

yes, github.head_ref (doesn't require checkout)

Comment on lines 71 to 79
env:
RELEASE_VERSION: ${{ steps.version.outputs.releaseVersion }}
run: |
set -x
echo $RELEASE_VERSION
if [ $RELEASE_VERSION = *-pre ]; then
echo "Release version cannot be pre-release"
exit 1
fi
Copy link
Member

@gmaclennan gmaclennan Feb 6, 2025

Choose a reason for hiding this comment

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

This works, and briefer isn't necessarily better, but this would also work I think:

Suggested change
env:
RELEASE_VERSION: ${{ steps.version.outputs.releaseVersion }}
run: |
set -x
echo $RELEASE_VERSION
if [ $RELEASE_VERSION = *-pre ]; then
echo "Release version cannot be pre-release"
exit 1
fi
if: endsWith(steps.version.outputs.releaseVersion, '-pre')
run: exit 1

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah a matter of portability vs readability. think for this readability is probably preferable so applying this suggestion seems reasonable

Copy link
Member Author

Choose a reason for hiding this comment

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

addressed via 2ad1832

Comment on lines 82 to 92
env:
PR_BRANCH_NAME: ${{ steps.pr_branch_name.outputs.result }}
RELEASE_SHORT: ${{ steps.version.outputs.releaseShort }}
run: |
set -x
echo $PR_BRANCH_NAME
echo $RELEASE_SHORT
if [ $PR_BRANCH_NAME != "rc/v$RELEASE_SHORT" ]; then
echo "Release version does not match RC branch"
exit 1
fi
Copy link
Member

Choose a reason for hiding this comment

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

Similar to above, if we want to lean into github actions syntax

Suggested change
env:
PR_BRANCH_NAME: ${{ steps.pr_branch_name.outputs.result }}
RELEASE_SHORT: ${{ steps.version.outputs.releaseShort }}
run: |
set -x
echo $PR_BRANCH_NAME
echo $RELEASE_SHORT
if [ $PR_BRANCH_NAME != "rc/v$RELEASE_SHORT" ]; then
echo "Release version does not match RC branch"
exit 1
fi
if: format('rc/{0}', steps.version.outputs.release) != github.head_ref
run: exit 1

Copy link
Member Author

Choose a reason for hiding this comment

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

addressed via 2ad1832

@achou11
Copy link
Member Author

achou11 commented Feb 6, 2025

[ ] check to make sure the version bump is correct

@gmaclennan any thoughts on whether I should address this in this PR or do in a follow up?

Separately, is it necessary to add a check to make sure the RC branch name is aligned with the release branch name? I'm leaning towards no because of the rulesets making a situation where they're misaligned unlikely

@gmaclennan
Copy link
Member

[ ] check to make sure the version bump is correct

@gmaclennan any thoughts on whether I should address this in this PR or do in a follow up?

This one is a bit trickier so I think can be done (much) later - it's an edge case.

Separately, is it necessary to add a check to make sure the RC branch name is aligned with the release branch name? I'm leaning towards no because of the rulesets making a situation where they're misaligned unlikely

Since the user can't rename either branch or create either branch I think we don't need a check.

@gmaclennan
Copy link
Member

Since the user can't rename either branch or create either branch I think we don't need a check.

I mean I guess someone could edit a PR and change the base of the PR to a different release/** branch... So maybe a check to add to the backlog, but this would be covered by checking the version bump as above. Hopefully no-one would do that anyway!

@achou11 achou11 requested a review from gmaclennan February 6, 2025 21:27
run: exit 1

- name: Assert release version matches RC branch name
if: format('rc/{0}', steps.version.outputs.release) != github.head_ref
Copy link
Member Author

@achou11 achou11 Feb 6, 2025

Choose a reason for hiding this comment

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

maybe i'm missing something, but what is steps.version.outputs.release? I don't see any reference to it in the parse-versions.yml file?

Maybe i'm supposed to use releaseShort instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

using my intuition and adjusted via 685dff8

Copy link
Member

@gmaclennan gmaclennan left a comment

Choose a reason for hiding this comment

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

Looks solid to me!

.github/workflows/check-pr-to-release.yml Show resolved Hide resolved
@achou11 achou11 merged commit 92f2c31 into develop Feb 6, 2025
2 checks passed
@achou11 achou11 deleted the ac/assert-rc-branch-to-release-branch branch February 6, 2025 21:50
achou11 added a commit that referenced this pull request Feb 6, 2025
@achou11 achou11 mentioned this pull request Feb 6, 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.

2 participants