Skip to content

Commit

Permalink
cleanup: Generate proto with go generate only if proto tag is provided
Browse files Browse the repository at this point in the history
Avoids generating proto files unless explicitly requested.

As per this it's now an error if the generation script is called during
package build.
  • Loading branch information
3v1n0 committed Jul 3, 2024
1 parent dd7d4ce commit 3e8f4dd
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/qa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ jobs:
run: |
set -eu
go run -tags pam_binary_cli ./pam login --exec-debug
- name: Generate Proto files
run: |
set -eu
find -name "*.pb.go" -delete -print
go generate -x -tags proto ./...
find -name "*.pb.go"
- name: Generate PAM module
run: |
set -eu
Expand Down
2 changes: 1 addition & 1 deletion generate.go → generate_proto.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build generate
//go:build generate && proto

//go:generate tools/generate-proto.sh --with-grpc authd.proto

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build generate
//go:build generate && proto

//go:generate ../../../../tools/generate-proto.sh --with-grpc grpctestservice.proto

Expand Down
5 changes: 5 additions & 0 deletions pam/internal/gdm/generate_proto.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//go:build generate && proto

//go:generate ../../../tools/generate-proto.sh -I../../.. -I../proto gdm.proto

package gdm
2 changes: 0 additions & 2 deletions pam/internal/gdm/protocol.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:generate ../../../tools/generate-proto.sh -I../../.. -I../proto gdm.proto

// Package gdm is the package for the GDM pam module handing.
package gdm

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//go:build generate
//go:build generate && proto

//go:generate ../../../tools/generate-proto.sh pam.proto

Expand Down
2 changes: 1 addition & 1 deletion tools/generate-proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail

if [ -v DEB_HOST_GNU_TYPE ]; then
echo "Proto files should not be regenerated during package building"
exit 0
exit 1
fi

# TODO: Watch https://github.com/protocolbuffers/protobuf for any changes on the
Expand Down

0 comments on commit 3e8f4dd

Please sign in to comment.