From 5e8912a0e21ee6a1c377dbb35e53c297cdcf1f24 Mon Sep 17 00:00:00 2001 From: podocarp Date: Thu, 2 Oct 2025 11:43:20 +0800 Subject: [PATCH 1/2] add workflow to lint and check for buf diffs --- .github/workflows/buf-check.yml | 54 +++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/buf-check.yml diff --git a/.github/workflows/buf-check.yml b/.github/workflows/buf-check.yml new file mode 100644 index 0000000..1508a85 --- /dev/null +++ b/.github/workflows/buf-check.yml @@ -0,0 +1,54 @@ +name: Buf Checks + +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: {} + +jobs: + buf: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Buf + uses: bufbuild/buf-setup-action@v1 + + - name: Run buf lint + run: buf lint + + - name: Check buf format + id: format + continue-on-error: true + run: | + buf format -w + if [[ -n "$(git status --porcelain)" ]]; then + echo "buf format produced changes. Run 'buf format -w' locally to update your files." + git status --short + git checkout -- . + exit 1 + fi + + - name: Check buf generate output + id: generate + continue-on-error: true + run: | + buf generate + if [[ -n "$(git status --porcelain generated)" ]]; then + echo "buf generate produced changes. Run 'buf generate' locally and commit the results." + git status --short generated + git checkout -- generated || true + git clean -fd generated || true + exit 1 + fi + + - name: Fail if checks detected changes + if: steps.format.outcome == 'failure' || steps.generate.outcome == 'failure' + run: | + echo "::error::buf format or buf generate produced changes." + exit 1 From 24c9e26119ce1279c2eab57930e0b6bb90cc2e19 Mon Sep 17 00:00:00 2001 From: podocarp Date: Thu, 2 Oct 2025 11:48:36 +0800 Subject: [PATCH 2/2] add comments --- .github/workflows/buf-check.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/buf-check.yml b/.github/workflows/buf-check.yml index 1508a85..a37a727 100644 --- a/.github/workflows/buf-check.yml +++ b/.github/workflows/buf-check.yml @@ -29,6 +29,7 @@ jobs: buf format -w if [[ -n "$(git status --porcelain)" ]]; then echo "buf format produced changes. Run 'buf format -w' locally to update your files." + # cleanup for next step git status --short git checkout -- . exit 1 @@ -41,9 +42,8 @@ jobs: buf generate if [[ -n "$(git status --porcelain generated)" ]]; then echo "buf generate produced changes. Run 'buf generate' locally and commit the results." - git status --short generated - git checkout -- generated || true - git clean -fd generated || true + # there's no cleanup since this is the last step, REMEMBER to add + # one if you neeed it! exit 1 fi