-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 automation for proto generation #10971
Open
emmyoop
wants to merge
2
commits into
main
Choose a base branch
from
er/run-make-commands
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# **what?** | ||
# Updates a file via a make command in CI workflow | ||
|
||
# **why?** | ||
# Ensure dbt-core has up to date files | ||
|
||
# **when?** | ||
# This will be called by another workflow in a PR. | ||
|
||
name: "Run Make Command & Commit Changes" | ||
run-name: "Run make ${{ inputs.make_command}}" | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
file_path: | ||
type: string | ||
required: true | ||
make_command: | ||
type: string | ||
required: true | ||
pr-branch: | ||
type: string | ||
required: true | ||
|
||
jobs: | ||
update-file: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Checkout Repository at ${{ inputs.pr-branch }}" | ||
uses: actions/checkout@v4 | ||
with: | ||
# define this to make to obvious what repo/ref is being checked out | ||
repository: ${{ github.repository }} | ||
ref: ${{ inputs.pr-branch }} | ||
token: ${{ secrets.FISHTOWN_BOT_PAT }} | ||
fetch-depth: 100 | ||
|
||
# use python 3.11 since it is what we use in the docker image | ||
- name: "Setup Python 3.11" | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.11' | ||
|
||
- name: "Install protoc v26.1" | ||
# version specified for 26.1 because this is the most recent version that can also be installed on macos | ||
if: ${{ inputs.make_command == 'core_proto_types' }} | ||
run: | | ||
PB_REL="https://github.com/protocolbuffers/protobuf/releases" | ||
curl -LO $PB_REL/download/v26.1/protoc-26.1-linux-x86_64.zip | ||
unzip protoc-26.1-linux-x86_64.zip -d $HOME/.local | ||
rm protoc-26.1-linux-x86_64.zip | ||
export PATH="$PATH:$HOME/.local/bin" | ||
protoc --version | ||
|
||
- name: "make ${{ inputs.make_command }}" | ||
run: | | ||
make ${{ inputs.make_command }} | ||
|
||
- name: "check state of git repo" | ||
run: | | ||
git status | ||
|
||
- name: "Diff changes to check if commit is needed" | ||
id: check_changes | ||
run: | | ||
git diff --quiet ${{ inputs.file_path }} || echo "diff=found" >> $GITHUB_OUTPUT | ||
|
||
- name: "check state of git repo" | ||
run: | | ||
git status | ||
|
||
- name: "Commit changes" | ||
if: ${{ steps.check_changes.outputs.diff == 'found' }} | ||
id: pr | ||
run: | | ||
git config --global user.email "[email protected]" | ||
git config --global user.name "BuildBot" | ||
git add ${{ inputs.file_path }} | ||
git commit -m "Update ${{ inputs.file_path }}" || true | ||
git push | ||
|
||
- name: "[Notification] Job Status" | ||
run: | | ||
if [[ "${{ steps.check_changes.outputs.diff }}" != "found" ]]; then | ||
message="${{ inputs.file_path }} update skipped. No changes found." | ||
elif [ -n "${{ steps.pr.outputs.nbr }}" ]; then | ||
message="${{ inputs.file_path }} updated." | ||
fi | ||
title="Update dbt-core ${{ inputs.file_path }} File" | ||
echo "::notice title=$title::$message" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# **what?** | ||
# Updates core_types_pb2.py in CI workflow | ||
|
||
# **why?** | ||
# Ensure dbt-core has an up to date proto file | ||
|
||
# **when?** | ||
# This will run on a PR when the `proto update` label is added. | ||
# If it generates a new commit the rest of CI will retrigger. | ||
|
||
name: Update Core Proto | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- labeled | ||
- synchronize | ||
- opened | ||
|
||
jobs: | ||
update-proto: | ||
if: ${{ contains(github.event.pull_request.labels.*.name, 'proto update') }} | ||
uses: ./.github/workflows/make-file-update.yml | ||
with: | ||
file_path: "core/dbt/events/core_types_pb2.py" | ||
make_command: "core_proto_types" | ||
pr-branch: ${{ github.event.pull_request.head.ref }} | ||
secrets: inherit |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
really cool!