Skip to content

Commit

Permalink
ci: run go generate as part of the go-check workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Jan 8, 2023
1 parent c22b7f5 commit 30b84fa
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 21 deletions.
10 changes: 10 additions & 0 deletions .github/actions/go-check-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
runs:
using: "composite"
steps:
- name: Install Protoc
uses: trail-of-forks/setup-protoc@a97892a429d98fae78d26f40334ab7eb616d08b9 # include https://github.com/arduino/setup-protoc/pull/58
with:
version: '21.12'
- name: Install Protobuf compiler
shell: bash
run: go install google.golang.org/protobuf/cmd/protoc-gen-go
3 changes: 3 additions & 0 deletions .github/workflows/go-check-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"gogenerate": true
}
10 changes: 5 additions & 5 deletions core/network/mocks/network.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package mocknetwork

//go:generate sh -c "mockgen -package mocknetwork -destination mock_resource_manager.go github.com/libp2p/go-libp2p/core/network ResourceManager"
//go:generate sh -c "mockgen -package mocknetwork -destination mock_conn_management_scope.go github.com/libp2p/go-libp2p/core/network ConnManagementScope"
//go:generate sh -c "mockgen -package mocknetwork -destination mock_stream_management_scope.go github.com/libp2p/go-libp2p/core/network StreamManagementScope"
//go:generate sh -c "mockgen -package mocknetwork -destination mock_peer_scope.go github.com/libp2p/go-libp2p/core/network PeerScope"
//go:generate sh -c "mockgen -package mocknetwork -destination mock_protocol_scope.go github.com/libp2p/go-libp2p/core/network ProtocolScope"
//go:generate sh -c "go run github.com/golang/mock/mockgen -package mocknetwork -destination mock_resource_manager.go github.com/libp2p/go-libp2p/core/network ResourceManager"
//go:generate sh -c "go run github.com/golang/mock/mockgen -package mocknetwork -destination mock_conn_management_scope.go github.com/libp2p/go-libp2p/core/network ConnManagementScope"
//go:generate sh -c "go run github.com/golang/mock/mockgen -package mocknetwork -destination mock_stream_management_scope.go github.com/libp2p/go-libp2p/core/network StreamManagementScope"
//go:generate sh -c "go run github.com/golang/mock/mockgen -package mocknetwork -destination mock_peer_scope.go github.com/libp2p/go-libp2p/core/network PeerScope"
//go:generate sh -c "go run github.com/golang/mock/mockgen -package mocknetwork -destination mock_protocol_scope.go github.com/libp2p/go-libp2p/core/network ProtocolScope"
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ require (
golang.org/x/crypto v0.3.0
golang.org/x/sync v0.1.0
golang.org/x/sys v0.3.0
golang.org/x/tools v0.3.0
google.golang.org/protobuf v1.28.1
)

Expand Down Expand Up @@ -111,7 +112,6 @@ require (
golang.org/x/mod v0.7.0 // indirect
golang.org/x/net v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
golang.org/x/tools v0.3.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/blake3 v1.1.7 // indirect
)
12 changes: 0 additions & 12 deletions p2p/host/pstoremanager/mock_peerstore_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion p2p/host/pstoremanager/pstoremanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/stretchr/testify/require"
)

//go:generate sh -c "mockgen -package pstoremanager_test -destination mock_peerstore_test.go github.com/libp2p/go-libp2p/core/peerstore Peerstore"
//go:generate sh -c "go run github.com/golang/mock/mockgen -package pstoremanager_test -destination mock_peerstore_test.go github.com/libp2p/go-libp2p/core/peerstore Peerstore"

func TestGracePeriod(t *testing.T) {
t.Parallel()
Expand Down
2 changes: 1 addition & 1 deletion p2p/transport/quic/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/stretchr/testify/require"
)

//go:generate sh -c "mockgen -package libp2pquic -destination mock_connection_gater_test.go github.com/libp2p/go-libp2p/core/connmgr ConnectionGater && goimports -w mock_connection_gater_test.go"
//go:generate sh -c "go run github.com/golang/mock/mockgen -package libp2pquic -destination mock_connection_gater_test.go github.com/libp2p/go-libp2p/core/connmgr ConnectionGater && go run golang.org/x/tools/cmd/goimports -w mock_connection_gater_test.go"

type connTestCase struct {
Name string
Expand Down
2 changes: 1 addition & 1 deletion p2p/transport/webtransport/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ func TestResourceManagerListening(t *testing.T) {
}

// TODO: unify somehow. We do the same in libp2pquic.
//go:generate sh -c "mockgen -package libp2pwebtransport_test -destination mock_connection_gater_test.go github.com/libp2p/go-libp2p/core/connmgr ConnectionGater && goimports -w mock_connection_gater_test.go"
//go:generate sh -c "go run github.com/golang/mock/mockgen -package libp2pwebtransport_test -destination mock_connection_gater_test.go github.com/libp2p/go-libp2p/core/connmgr ConnectionGater && go run golang.org/x/tools/cmd/goimports -w mock_connection_gater_test.go"

func TestConnectionGaterDialing(t *testing.T) {
ctrl := gomock.NewController(t)
Expand Down
10 changes: 10 additions & 0 deletions tools.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//go:build tools
// +build tools

package libp2p

import (
_ "github.com/golang/mock/mockgen"
_ "golang.org/x/tools/cmd/goimports"
_ "google.golang.org/protobuf/cmd/protoc-gen-go"
)

0 comments on commit 30b84fa

Please sign in to comment.