-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
638bb4b
to
8b20418
Compare
- 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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
abcf624
to
6fa5629
Compare
There was a problem hiding this 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 :)
- 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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed via 2ad1832
- 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 |
There was a problem hiding this comment.
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)
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 |
There was a problem hiding this comment.
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:
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed via 2ad1832
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 |
There was a problem hiding this comment.
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
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed via 2ad1832
@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 |
This one is a bit trickier so I think can be done (much) later - it's an edge case.
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 |
run: exit 1 | ||
|
||
- name: Assert release version matches RC branch name | ||
if: format('rc/{0}', steps.version.outputs.release) != github.head_ref |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this 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!
Towards #4
Adds the following checks:
Makes sure any PR to a
release/*
branch is an RC branch (i.e. starts withrc/
)Makes sure the version introduced by the RC PRs:
Still missing:
check to make sure the version bump is correctEDIT: to be done as a follow-upQuestion: should we rename the workflow file? Introducing the job that has these checks makes the nameEDIT: I've renamed the worfklow file to be more explicit (see 8ca1c89)Check Release Branch
a little unclear to me.