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

ci: add PR chart version validation #62

Merged
merged 3 commits into from
Oct 27, 2023
Merged

ci: add PR chart version validation #62

merged 3 commits into from
Oct 27, 2023

Conversation

tplessas
Copy link
Contributor

Tested in #61; will remove both branches once merged.

@tplessas tplessas requested a review from a team as a code owner October 25, 2023 10:09
Copy link
Contributor

@anton-delphai anton-delphai left a 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:
Copy link
Contributor

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?

Copy link
Contributor Author

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]).

Copy link
Contributor

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

Comment on lines 17 to 19
- name: Install dependencies
run: sudo snap install yq

Copy link
Contributor

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

Comment on lines 56 to 61
- 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
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops

Comment on lines 41 to 54
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 }}
Copy link
Contributor

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

Copy link
Contributor Author

@tplessas tplessas Oct 27, 2023

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.

@tplessas
Copy link
Contributor Author

Alternatively we can just compare versions and block merges without autobumping

A much better idea overall – gives more control and needs less compute time.

anton-delphai
anton-delphai previously approved these changes Oct 27, 2023
Copy link
Contributor

@anton-delphai anton-delphai left a 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!

.github/workflows/check-pr-version.yml Outdated Show resolved Hide resolved
Co-authored-by: Anton Ryzhov <[email protected]>
@tplessas tplessas merged commit 4d7e3e1 into master Oct 27, 2023
1 check passed
@tplessas tplessas deleted the add-autobump branch October 27, 2023 14:08
@tplessas tplessas changed the title ci: add chart version auto-bump ci: add PR chart version validation Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants