Update README.md #106
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
name: buf | |
on: | |
pull_request: | |
branches: | |
- "main" | |
jobs: | |
lint: | |
name: lint | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.ref }} | |
- uses: bufbuild/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- uses: bufbuild/buf-lint-action@v1 | |
verify_formatting: | |
name: verify_formatting | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.ref }} | |
- uses: bufbuild/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Verify the code pushed in formatted | |
run: | | |
buf format -w | |
if git diff --quiet --exit-code ; then | |
echo "Code is formatted!"; | |
exit 0 | |
else | |
echo "Code isn't formatted!"; | |
exit 1 | |
fi | |
verify_compiled_code: | |
name: verify_compiled_code | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.ref }} | |
- uses: bufbuild/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: verify generated code is not altered | |
run: | | |
BIN="/usr/local/bin" && \ | |
VERSION="1.18.0" && \ | |
curl -sSL \ | |
"https://github.com/bufbuild/buf/releases/download/v${VERSION}/buf-$(uname -s)-$(uname -m)" \ | |
-o "${BIN}/buf" && \ | |
chmod +x "${BIN}/buf" | |
buf generate -o verify_compiled_code | |
if diff -qr gen verify_compiled_code/gen ; then | |
echo "generated code is valid"; | |
else | |
echo "There seem to be some extra/missing generated files!"; | |
exit 1 | |
fi | |
rm -rf verify_compiled_code/ | |
buf generate | |
if git diff --quiet --exit-code ; then | |
echo "Unaltered code has been pushed"; | |
else | |
echo "Code pushed seems to be altered"; | |
exit 1 | |
fi | |
breaking_action: | |
name: breaking_action | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.ref }} | |
- uses: bufbuild/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- uses: bufbuild/buf-breaking-action@v1 | |
with: | |
against: "https://github.com/goakshit/buf.git#branch=main" |