Add build-time ceph-nvmeof protobuf generation infrastructure #5
Workflow file for this run
This file contains hidden or 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: Check Proto Changes | |
| on: | |
| pull_request: | |
| paths: | |
| - 'internal/nvme/gateway/proto/gateway.proto' | |
| - 'scripts/generate-proto.sh' | |
| - 'build.env' | |
| push: | |
| branches: | |
| - devel | |
| paths: | |
| - 'internal/nvme/gateway/proto/gateway.proto' | |
| - 'scripts/generate-proto.sh' | |
| - 'build.env' | |
| jobs: | |
| check-proto-changes: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| # yamllint disable-line rule:line-length | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install protobuf tools | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y protobuf-compiler | |
| # Install Go protobuf plugins | |
| curl -L https://go.dev/dl/go1.23.4.linux-amd64.tar.gz | sudo tar -C /usr/local -xzf - | |
| export PATH=/usr/local/go/bin:$PATH | |
| go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.6 | |
| go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1 | |
| - name: Check if proto file changed | |
| id: check-changes | |
| run: | | |
| if git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep -q "internal/nvme/gateway/proto/gateway.proto"; then | |
| echo "proto_changed=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "proto_changed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Generate protobuf stubs | |
| if: steps.check-changes.outputs.proto_changed == 'true' | |
| run: | | |
| ./scripts/generate-proto.sh --force | |
| - name: Check for generated file changes | |
| if: steps.check-changes.outputs.proto_changed == 'true' | |
| run: | | |
| if git diff --name-only | grep -q "internal/nvme/gateway/proto/.*\.pb\.go"; then | |
| echo "Generated files have changed. Please commit the updated generated files." | |
| git diff internal/nvme/gateway/proto/ | |
| exit 1 | |
| else | |
| echo "Generated files are up-to-date." | |
| fi | |
| - name: Verify generated files exist | |
| run: | | |
| if [ ! -f "internal/nvme/gateway/proto/gateway.pb.go" ] || [ ! -f "internal/nvme/gateway/proto/gateway_grpc.pb.go" ]; then | |
| echo "Generated protobuf files are missing. Please run: ./scripts/generate-proto.sh" | |
| exit 1 | |
| fi | |
| echo "Generated protobuf files are present." | |
| - name: Test generated code compilation | |
| run: | | |
| go build -o /dev/null ./internal/nvme/gateway/proto/ |