-
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
ci: add PR chart version validation #62
Conversation
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.
These autobump solutions have so many edgecases and can mess a lot of things
But as this repo is not changed often, that might work.
Alternatively we can just compare versions and block merges without autobumping
@@ -0,0 +1,68 @@ | |||
name: Bump PR chart version | |||
on: | |||
pull_request: |
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.
On all events on PRs?
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.
Definitely on the three defaults ([opened, reopened, synchronized]
).
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. It's too late on closed
- name: Install dependencies | ||
run: sudo snap install yq | ||
|
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.
It's installed by default
- name: Bump base version and set to chart | ||
run: | | ||
yq -i ".version=\"$( | ||
echo ${{ needs.compare.outputs.base-version }} | \ | ||
awk -F. '/[0-9]+\./{$NF++;print}' OFS=.)\"" \ | ||
./charts/delphai-deployment/Chart.yaml |
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.
Oh wow, awk is here
Check that:
https://github.com/madhead/semver-utils#usage
echo "${{ steps.version.outputs.release }}" # 1.2.3
echo "${{ steps.version.outputs.inc-minor }}" # 1.3.0
echo "${{ steps.version.outputs.inc-patch }}" # 1.2.4
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.
Oops
bump: | ||
name: Bump PR head version if not bigger than base | ||
runs-on: ubuntu-latest | ||
needs: compare | ||
if: ${{ !(needs.compare.outputs.comparison-result == '>') }} | ||
steps: | ||
- name: Install dependencies | ||
run: sudo snap install yq | ||
|
||
- name: Checkout PR head | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
ref: ${{ github.event.pull_request.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.
If you'd merge jobs and add this step to previous one — it won't run another executor, won't checkout the code second time — should work 2 times faster
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.
Had an inkling that it might be possible to conditionally execute steps, but I only found if
conditions for jobs when I was searching. Will adapt.
A much better idea overall – gives more control and needs less compute time. |
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.
Current version gives control over which subversion to bump depending on the changes
Like that!
Co-authored-by: Anton Ryzhov <[email protected]>
Tested in #61; will remove both branches once merged.