Skip to content

Commit

Permalink
Added Semver check for package version.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre Bourget committed May 17, 2022
1 parent 568e2d4 commit 5112914
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
8 changes: 4 additions & 4 deletions cmd/substreams/pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,21 @@ func runPack(cmd *cobra.Command, args []string) error {
return fmt.Errorf("writing %q: %w", defaultFilename, err)
}

fmt.Printf(`To generate bindings for your Rust code:
fmt.Printf(`To generate bindings for your code:
1. create a file 'buf.gen.yaml' with this content:
version: v1
plugins:
- name: prost
- name: prost # Generate for Rust, used by your modules, or Rust client code.
out: gen/src
opt:
- bytes=.
- compile_well_known_types
2. run 'buf generate %s#format=bin'
2. run 'buf generate %s#format=bin'
3. See https://crates.io/crates/protoc-gen-prost for more details
`, defaultFilename)
fmt.Println("")
fmt.Printf("----------------------------------------\n")
fmt.Printf("Successfully wrote %q.\n", defaultFilename)

Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ require (
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/crypto v0.0.0-20220214200702-86341886e292 // indirect
golang.org/x/mod v0.5.1 // indirect
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,8 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38=
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down
6 changes: 5 additions & 1 deletion manifest/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"

pbsubstreams "github.com/streamingfast/substreams/pb/sf/substreams/v1"
"golang.org/x/mod/semver"
"google.golang.org/protobuf/proto"
)

Expand Down Expand Up @@ -191,7 +192,10 @@ func validatePackage(pkg *pbsubstreams.Package) error {

for _, spkg := range pkg.PackageMeta {
if !moduleNameRegexp.MatchString(spkg.Name) {
return fmt.Errorf("invalid package name %q: must match %s", spkg.Name, moduleNameRegexp.String())
return fmt.Errorf("package %q: invalid name: must match %s", spkg.Name, moduleNameRegexp.String())
}
if !semver.IsValid(spkg.Version) {
return fmt.Errorf("package %q: version %q should match Semver", spkg.Name, spkg.Version)
}
}

Expand Down

0 comments on commit 5112914

Please sign in to comment.