Switch to npm binary for license headers #34
Workflow file for this run
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 action CI | |
on: | |
push: | |
pull_request: | |
branches: | |
- main | |
permissions: | |
contents: read | |
pull-requests: write | |
env: | |
BUF_VERSION: "1.32.2" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: "^1.22" | |
cache: false | |
- uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go-cache-${{ hashFiles('Makefile') }} | |
restory-keys: ${{ runner.os }}-go-cache- | |
- name: Build | |
run: | | |
make build | |
- name: Generate | |
run: | | |
make generate | |
- name: Check diff | |
run: | | |
make checkgenerate | |
setup: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./ | |
with: | |
setup_only: true | |
- run: buf --version | grep $BUF_VERSION | |
setup-latest: | |
runs-on: ubuntu-latest | |
needs: build | |
env: | |
BUF_VERSION: "" # Use the latest version | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./ | |
with: | |
setup_only: true | |
- run: buf --version | |
setup-macos: | |
needs: setup | |
if: github.event_name == 'push' | |
runs-on: macos-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./ | |
with: | |
setup_only: true | |
- run: buf --version | grep $BUF_VERSION | |
setup-windows: | |
needs: setup | |
if: github.event_name == 'push' | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./ | |
with: | |
setup_only: true | |
- run: buf --version | Select-String -Pattern $env:BUF_VERSION -CaseSensitive -SimpleMatch | |
setup-self-hosted: | |
needs: setup | |
# Disable this job, only for testing. | |
if: false | |
runs-on: self-hosted | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./ | |
with: | |
setup_only: true | |
- run: buf --version | grep $BUF_VERSION | |
lint: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
- run: | | |
mkdir -p proto/test/v1 | |
printf 'version: v2\nmodules:\n - path: proto' > buf.yaml | |
printf 'syntax = "proto3"; package test.v1; message A { string a = 1; }' > proto/test/v1/test.proto | |
- uses: ./ | |
with: | |
lint: true | |
format: false | |
breaking: false | |
push: false | |
archive: false | |
comment: false | |
format: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
- run: | | |
mkdir -p proto | |
printf 'version: v2\nmodules:\n - path: proto' > buf.yaml | |
printf 'syntax = "proto3";\n\nmessage A {\n string a = 1;\n}\n' > proto/test.proto | |
- uses: ./ | |
with: | |
lint: false | |
format: true | |
breaking: false | |
push: false | |
archive: false | |
comment: false | |
breaking: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
- run: | | |
mkdir -p proto | |
printf 'version: v2\nmodules:\n - path: proto' > buf.yaml | |
printf 'syntax = "proto3"; message A { string a = 1; }' > proto/test.proto | |
- uses: ./ | |
with: | |
lint: false | |
format: false | |
breaking: true | |
breaking_against: . | |
push: false | |
archive: false | |
comment: false | |
comment: | |
runs-on: ubuntu-latest | |
if: github.event_name == 'pull_request' | |
needs: [lint,format,breaking] | |
steps: | |
- uses: actions/checkout@v4 | |
- env: | |
BUF_USERNAME: ${{ secrets.BUF_USERNAME }} | |
run: | | |
# Lint skipped, format fails, breaking succeeds | |
mkdir -p proto | |
printf 'version: v2\nmodules:\n - path: proto' > buf.yaml | |
printf 'syntax = "proto3"; message A { string a = 1; }' > proto/test.proto | |
- uses: ./ | |
continue-on-error: true # format fails | |
with: | |
username: ${{ secrets.BUF_USERNAME }} | |
token: ${{ secrets.BUF_TOKEN }} | |
lint: false # lint skipped | |
format: true | |
breaking: true | |
breaking_against: . | |
push: false | |
archive: false | |
comment: true | |
push: | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'push' }} # --git-metadata is only available on push | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
- env: | |
BUF_USERNAME: ${{ secrets.BUF_USERNAME }} | |
run: | | |
mkdir -p proto/foo/v1 | |
printf "version: v2\nmodules:\n - path: proto\n name: buf.build/${BUF_USERNAME}/foo\n" > buf.yaml | |
printf "syntax = \"proto3\";\npackage foo.v1;\nmessage Bar {}\n" > proto/foo/v1/bar.proto | |
- uses: ./ | |
with: | |
username: ${{ secrets.BUF_USERNAME }} | |
token: ${{ secrets.BUF_TOKEN }} | |
lint: false | |
format: false | |
breaking: false | |
push: true | |
archive: false | |
comment: false | |
archive: | |
if: github.event_name == 'push' && github.ref_name != github.event.repository.default_branch | |
runs-on: ubuntu-latest | |
needs: push | |
steps: | |
- uses: actions/checkout@v4 | |
- env: | |
BUF_USERNAME: ${{ secrets.BUF_USERNAME }} | |
run: | | |
mkdir -p proto/foo/v1 | |
printf "version: v2\nmodules:\n - path: proto\n name: buf.build/${BUF_USERNAME}/foo\n" > buf.yaml | |
printf "syntax = \"proto3\";\npackage foo.v1;\nmessage Bar {}\n" > proto/foo/v1/bar.proto | |
- uses: ./ | |
with: | |
username: ${{ secrets.BUF_USERNAME }} | |
token: ${{ secrets.BUF_TOKEN }} | |
lint: false | |
format: false | |
breaking: false | |
push: false | |
archive: true | |
comment: false |