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

[Do not merge] Prototype GitHub workflows #106

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .github/workflows/buf-delete.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Buf delete
nicksnyder marked this conversation as resolved.
Show resolved Hide resolved
on:
delete
permissions: read-all
jobs:
buf-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Buf setup
uses: bufbuild/buf-setup-action@v1
with:
version: 1.32.0-beta.1
- run: buf --version
- name: Buf delete
run: echo "Action not supported for buf"
Copy link
Member

Choose a reason for hiding this comment

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

I would add a comment for the command that we want to run when it is implemented (presumably buf beta registry label archive)

31 changes: 31 additions & 0 deletions .github/workflows/buf-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Buf PR
on:
pull_request:
types: [opened,synchronize,reopened,labeled,unlabeled]
permissions: read-all
jobs:
buf-pr:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Buf setup
uses: bufbuild/buf-setup-action@v1
with:
version: 1.32.0-beta.1
- run: buf --version
- name: Buf build
run: buf build . --error-format github-actions
emcfarlane marked this conversation as resolved.
Show resolved Hide resolved
- name: Buf format
if: ${{ !contains(github.event.pull_request.labels.*.name, 'Buf Skip Format') }}
nicksnyder marked this conversation as resolved.
Show resolved Hide resolved
run: buf format . --diff --error-format github-actions --exit-code
- name: Buf lint
if: ${{ !contains(github.event.pull_request.labels.*.name, 'Buf Skip Lint') }}
run: buf lint . --error-format github-actions
- name: Checkout base
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.sha }}
path: .base
- name: Buf breaking
if: ${{ !contains(github.event.pull_request.labels.*.name, 'Buf Skip Breaking') }}
run: buf breaking . --error-format github-actions --against .base
32 changes: 32 additions & 0 deletions .github/workflows/buf-push-checks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Buf push checks
on:
push:
branches:
- main
Copy link
Member

Choose a reason for hiding this comment

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

I think it will be better to have a single workflow file for all pushes.

Needing to hard code main here isn't great. In a unified workflow we can use ${{ github.event.repository.default_branch }} to detect if we are on the right branch and behave accordingly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Starter workflows have $default-branch templating: https://docs.github.com/en/actions/using-workflows/creating-starter-workflows-for-your-organization#creating-a-starter-workflow
And other workflow files will specify the default as part of their config. I don't think it's possible to access the github event as part of the specification of what events it listens on as the definition would be circular.

Copy link
Member

Choose a reason for hiding this comment

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

Is buf-action using starter workflows?

I don't think it's possible to access the github event as part of the specification of what events it listens on as the definition would be circular.

No you can't, but you can use if: statements for the jobs or steps.
https://stackoverflow.com/questions/64781462/github-actions-default-branch-variable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not currently, but it's something we could provide in addition to reusable workflows. I could see the use case where a user wants to edit the pre-defined workflow and this would provide an eject mechanism.

permissions: read-all
jobs:
buf-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Buf setup
uses: bufbuild/buf-setup-action@v1
with:
version: 1.32.0-beta.1
- run: buf --version
- name: Buf build
run: buf build . --error-format github-actions
- name: Buf format
if: ${{ !contains(github.event.head_commit.message, 'buf skip format') }}
run: buf format . --diff --error-format github-actions --exit-code
- name: Buf lint
if: ${{ !contains(github.event.head_commit.message, 'buf skip lint') }}
run: buf lint . --error-format github-actions
- name: Checkout base
uses: actions/checkout@v4
with:
ref: ${{ gihub.event.before }}
path: .base
- name: Buf breaking
if: ${{ !contains(github.event.head_commit.message, 'buf skip breaking') }}
run: buf breaking . --error-format github-actions --against .base
16 changes: 16 additions & 0 deletions .github/workflows/buf-push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Buf push
on:
push
permissions: read-all
jobs:
buf-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Buf setup
uses: bufbuild/buf-setup-action@v1
with:
version: 1.32.0-beta.1
- run: buf --version
- name: Buf push
run: buf push . --error-format=github-actions --git-metadata
Loading