Skip to content

Conversation

@stuqdog
Copy link
Member

@stuqdog stuqdog commented Mar 20, 2025

  • Creates a parent test to check so we don't have to mark 10 separate tests as required
  • Switches to using the peter-evans workflow for
  • Provides support for automatic approval and merging of these PRs when all tests pass

Note to reviewers: see inline notes for thoughts/explanations on the code and how it was tested (or why I believe leaving it untested is acceptable)

TODO:

  • once this is merged, update the required status checks to only include the umbrella test, rather than all the individual ones

Comment on lines +58 to +66
test_passing:
if: github.repository_owner == 'viamrobotics'
needs: test
runs-on: ubuntu-latest
steps:
- name: Check Results
run: |
echo Python tests: ${{ needs.test.result }}
[ "${{ needs.test.result }}" == "success" ]
Copy link
Member Author

Choose a reason for hiding this comment

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

This creates a new single test that ensures that all our tests from the test matrix have passed. This is important because we want to have tests be marked as required so that we don't auto merge a proto PR where tests have failed, but without this we need to mark all our current tests (3.8 max, 3.10 min, etc) as required. Not only is this annoying, but it's error prone because certain cases might get phased out of the matrix or new cases might get added, and we could forget to update our required list. By having a single catch-all here and marking that as required, we ensure that we're always expecting the entire matrix to pass.

This has been tested on my local branch to ensure it works.

Comment on lines +48 to +57
uses: peter-evans/create-pull-request@v7
with:
commit-message: '[WORKFLOW] Updating protos from ${{ github.event.client_payload.repo_name }}, commit: ${{ github.event.client_payload.sha }}'
branch: 'workflow/update-protos'
delete-branch: true
title: Automated Protos Update
body: This is an auto-generated PR to update proto definitions. Check the commits to see which repos and commits are responsible for the changes
assignees: njooma
reviewers: njooma
token: ${{ secrets.GIT_ACCESS_TOKEN }}
Copy link
Member Author

@stuqdog stuqdog Mar 21, 2025

Choose a reason for hiding this comment

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

Switching to peter-evans/create-pull-request. This hasn't been tested in python specifically but it has been tested insofar as we are using this same workflow and version in the typescript SDK, which is passing (the historical failures in TS were related to the token we used and have been resolved since we switched to the REPO_READ_TOKEN).

Comment on lines +59 to +65
- name: Enable Pull Request Automerge
if: steps.cpr.outputs.pull-request-operation == 'created'
uses: peter-evans/enable-pull-request-automerge@v3
with:
token: ${{ secrets.GIT_ACCESS_TOKEN }}
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
merge-method: squash
Copy link
Member Author

Choose a reason for hiding this comment

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

This has not been tested because I didn't want to auto-merge anything into the repo. I think this is fine; in the worst case, we fail to automerge, get am "update protos job failed" warning which immediately alerts us to it, and then we're back where we were before (merging by hand) but with error logs that can help us understand what went wrong.

Comment on lines +67 to +69
- name: Auto approve
if: steps.cpr.outputs.pull-request-operation == 'created'
run: gh pr review --approve "${{ stps.cpr.outputs.pull-request-number }}"
Copy link
Member Author

Choose a reason for hiding this comment

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

This has not been tested. I don't have any tokens in my local repo and I didn't want to try messing around with auto-approval and merging of PRs, running non-main versions of the yml file, etc. etc.

Again, I think this is fine. If it doesn't work then we're back where we were already (merging by hand) and we have more info on how to fix this.

# if not, then this won't work. but that's not particularly bad! it just means we'll still
# have to merge by hand, but then we can add `viambot` as a code owner and then automatic
# merging will start to work.
GH_TOKEN: ${{ secrets.GIT_ACCESS_TOKEN }}
Copy link
Member Author

Choose a reason for hiding this comment

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

It's possible this token is incorrect. This token causes actions to run as viambot but it's unclear to me without actually trying to merge something whether an approval from viambot satisfies the merge requirements. I think it might not, but viambot does have override permission in this repo so perhaps I'm wrong.

If this doesn't satisfy, then it's easy to add viambot to the list of reviewers from whom a review is required. However, I'd prefer to actually see a failure before doing that and avoid making such a change unless necessary.

@stuqdog stuqdog changed the title RSDK-10294 - automatically merge proto PRs when tests pass RSDK-10294 & RSDK-9902 - automatically merge proto PRs when tests pass Mar 21, 2025
@stuqdog stuqdog marked this pull request as ready for review March 21, 2025 19:31
@stuqdog stuqdog requested a review from a team as a code owner March 21, 2025 19:31
@stuqdog stuqdog requested review from lia-viam and njooma March 21, 2025 19:31
@njooma
Copy link
Member

njooma commented Apr 1, 2025

Looks good, but lets see how it actually works

@stuqdog stuqdog merged commit 95ff017 into viamrobotics:main Apr 1, 2025
12 checks passed
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