Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ cover.out
examples/sfu-ws/cert.pem
examples/sfu-ws/key.pem
wasm_exec.js
.scp
17 changes: 17 additions & 0 deletions cmd/scp/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT

package main

import (
"os"

"github.com/pion/scp/internal/cli"
)

func main() {
if err := cli.Execute(os.Args[1:]); err != nil {
cli.PrintError(err)
os.Exit(1)
}
}
28 changes: 26 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
module github.com/pion/template
module github.com/pion/scp

go 1.21
go 1.24.0

Check failure on line 3 in go.mod

View workflow job for this annotation

GitHub Actions / lint / Metadata

Invalid Go version

Found 1.24.0. Expected 1.21

toolchain go1.24.4

require (
github.com/Masterminds/semver/v3 v3.4.0
github.com/pion/logging v0.2.3
github.com/pion/sctp v1.8.39
github.com/pion/transport v0.14.1
github.com/spf13/cobra v1.10.1
github.com/stretchr/testify v1.10.0
golang.org/x/mod v0.30.0
golang.org/x/sys v0.22.0
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/pion/randutil v0.1.0 // indirect
github.com/pion/transport/v3 v3.0.7 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/pflag v1.0.9 // indirect
)
73 changes: 73 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms=
github.com/pion/logging v0.2.3 h1:gHuf0zpoh1GW67Nr6Gj4cv5Z9ZscU7g/EaoC/Ke/igI=
github.com/pion/logging v0.2.3/go.mod h1:z8YfknkquMe1csOrxK5kc+5/ZPAzMxbKLX5aXpbpC90=
github.com/pion/randutil v0.1.0 h1:CFG1UdESneORglEsnimhUjf33Rwjubwj6xfiOXBa3mA=
github.com/pion/randutil v0.1.0/go.mod h1:XcJrSMMbbMRhASFVOlj/5hQial/Y8oH/HVo7TBZq+j8=
github.com/pion/sctp v1.8.39 h1:PJma40vRHa3UTO3C4MyeJDQ+KIobVYRZQZ0Nt7SjQnE=
github.com/pion/sctp v1.8.39/go.mod h1:cNiLdchXra8fHQwmIoqw0MbLLMs+f7uQ+dGMG2gWebE=
github.com/pion/transport v0.14.1 h1:XSM6olwW+o8J4SCmOBb/BpwZypkHeyM0PGFCxNQBr40=
github.com/pion/transport v0.14.1/go.mod h1:4tGmbk00NeYA3rUa9+n+dzCCoKkcy3YlYb99Jn2fNnI=
github.com/pion/transport/v3 v3.0.7 h1:iRbMH05BzSNwhILHoBoAPxoB9xQgOaJk+591KC9P1o0=
github.com/pion/transport/v3 v3.0.7/go.mod h1:YleKiTZ4vqNxVwh77Z0zytYi7rXHl7j6uPLGhhz9rwo=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s=
github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0=
github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY=
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk=
golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
50 changes: 50 additions & 0 deletions internal/cli/cli.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT

// Package cli wires up the cobra command tree for the scp generator.
package cli

import (
"context"
"fmt"
"os"

"github.com/spf13/cobra"
)

func Execute(args []string) error {
root := newRootCmd()
root.SetArgs(args)
ctx := context.Background()

if err := root.ExecuteContext(ctx); err != nil {
return err
}

return nil
}

func PrintError(err error) {
fmt.Fprintf(os.Stderr, "error: %v\n", err)
}

func newRootCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "scp",
Short: "scp is a generator for multi-revision Pion SCTP testing",
Long: `scp resolves references to github.com/pion/sctp, generates deterministic
harnesses, and runs cross-version compatibility tests.`,
SilenceUsage: true,
SilenceErrors: true,
}

cmd.PersistentFlags().BoolP("verbose", "v", false, "enable verbose logging")
cmd.PersistentFlags().Bool("dry-run", false, "show actions without writing results")

cmd.AddCommand(newResolveCmd())
cmd.AddCommand(newUpdateCmd())
cmd.AddCommand(newGenerateCmd())
cmd.AddCommand(newTestCmd())

return cmd
}
51 changes: 51 additions & 0 deletions internal/cli/generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT

package cli

import (
"github.com/pion/scp/internal/generate"
"github.com/spf13/cobra"
)

func newGenerateCmd() *cobra.Command {
opts := generate.DefaultOptions()
cmd := &cobra.Command{
Use: "generate",
Short: "Generate runners, wrappers, and harness code from a lock file",
RunE: func(cmd *cobra.Command, args []string) error {
return generate.Run(cmd.Context(), opts)
},
}

cmd.Flags().StringVar(&opts.LockPath, "lock", opts.LockPath, "path to lock.json")
cmd.Flags().StringVar(&opts.FeaturesPath, "features", opts.FeaturesPath, "path to features.yaml")
cmd.Flags().StringVar(&opts.OutputDir, "out", opts.OutputDir, "output directory for generated code")
cmd.Flags().StringVar(&opts.APIName, "package", opts.APIName, "name of generated API package")
cmd.Flags().StringVar(
&opts.RunnerProtocol,
"runner-proto",
opts.RunnerProtocol,
"runner transport protocol (stdio-json|rpc)",
)
cmd.Flags().StringVar(
&opts.ModuleMode,
"modmode",
opts.ModuleMode,
"module resolve mode (remote|local-cache)",
)
cmd.Flags().StringVar(
&opts.LicensePath,
"license",
opts.LicensePath,
"optional license header file path",
)
cmd.Flags().StringSliceVar(
&opts.OnlyNames,
"only",
nil,
"optional comma-separated list of lock entries to generate",
)

return cmd
}
71 changes: 71 additions & 0 deletions internal/cli/resolve.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT

package cli

import (
"errors"

"github.com/pion/scp/internal/resolve"
"github.com/pion/scp/internal/scp"
"github.com/spf13/cobra"
)

var errNoRefsProvided = errors.New("no refs specified: use --refs or provide positional selectors")

func newResolveCmd() *cobra.Command {
opts := resolve.Options{}.WithDefaults()
cmd := &cobra.Command{
Use: "resolve",
Short: "Resolve ref selectors into manifest and lock files",
RunE: func(cmd *cobra.Command, args []string) error {
if len(opts.Refs) == 0 && len(args) == 0 {
return errNoRefsProvided
}

if len(args) > 0 {
opts.Refs = append(opts.Refs, args...)
}

opts.Refs = scp.SplitAndTrim(opts.Refs)

ctx := cmd.Context()
if err := resolve.Run(ctx, opts); err != nil {
return err
}

return nil
},
}

cmd.Flags().StringSliceVar(&opts.Refs, "refs", nil, "comma-separated selector list (may repeat)")
cmd.Flags().StringVar(&opts.Repository, "repo", resolve.DefaultRepository, "repository URL to mirror")
cmd.Flags().StringVar(&opts.CacheDir, "cache", scp.DefaultCacheDir(), "cache directory for mirrors and checkouts")
cmd.Flags().BoolVar(
&opts.IncludePreRelease,
"include-pre",
false,
"include pre-release tags when resolving ranges",
)
cmd.Flags().StringVar(
&opts.ManifestPath,
"out-manifest",
scp.DefaultManifestPath(),
"output path for manifest JSON",
)
cmd.Flags().StringVar(
&opts.LockPath,
"out-lock",
scp.DefaultLockPath(),
"output path for lock JSON",
)
cmd.Flags().StringVar(&opts.FreezeAt, "freeze-at", "", "RFC3339 timestamp to pin moving refs")
cmd.Flags().BoolVar(
&opts.AllowDirtyLocal,
"local-allow-dirty",
false,
"permit path selectors with local modifications",
)

return cmd
}
58 changes: 58 additions & 0 deletions internal/cli/test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT

package cli

import (
"github.com/pion/scp/internal/testcmd"
"github.com/spf13/cobra"
)

func newTestCmd() *cobra.Command {
opts := testcmd.DefaultOptions()
cmd := &cobra.Command{
Use: "test",
Short: "Build runners and execute cross-revision scenarios",
RunE: func(cmd *cobra.Command, args []string) error {
return testcmd.Run(cmd.Context(), opts)
},
}

cmd.Flags().StringVar(&opts.LockPath, "lock", opts.LockPath, "path to lock.json")
cmd.Flags().StringVar(
&opts.PairMode,
"pairs",
opts.PairMode,
"pair selection mode (adjacent|latest-prev|matrix|explicit|self)",
)
cmd.Flags().StringSliceVar(
&opts.IncludeNames,
"include",
nil,
"include only these entries (comma-separated)",
)
cmd.Flags().StringSliceVar(
&opts.ExcludeNames,
"exclude",
nil,
"exclude these entries (comma-separated)",
)
cmd.Flags().StringSliceVar(
&opts.ExplicitPairs,
"explicit",
nil,
"explicit pairs when --pairs=explicit (comma-separated A:B)",
)
cmd.Flags().StringSliceVar(
&opts.Cases,
"cases",
nil,
"scenario IDs to run (comma-separated)",
)
cmd.Flags().StringVar(&opts.Timeout, "timeout", opts.Timeout, "overall timeout for each pair")
cmd.Flags().Int64Var(&opts.Seed, "seed", opts.Seed, "random seed (0=random)")
cmd.Flags().StringVar(&opts.JUnitPath, "out", opts.JUnitPath, "path to write JUnit XML results")
cmd.Flags().IntVar(&opts.Repeat, "repeat", opts.Repeat, "number of times to run each pair (>=1)")

return cmd
}
27 changes: 27 additions & 0 deletions internal/cli/update.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT

package cli

import (
"github.com/pion/scp/internal/update"
"github.com/spf13/cobra"
)

func newUpdateCmd() *cobra.Command {
opts := update.DefaultOptions()
cmd := &cobra.Command{
Use: "update",
Short: "Update lock files from manifest entries with floating refs",
RunE: func(cmd *cobra.Command, args []string) error {
return update.Run(cmd.Context(), opts)
},
}

cmd.Flags().StringVar(&opts.ManifestPath, "manifest", opts.ManifestPath, "path to manifest.json")
cmd.Flags().StringVar(&opts.LockPath, "lock", opts.LockPath, "path to lock.json to update")
cmd.Flags().StringSliceVar(&opts.OnlyNames, "only", nil, "comma-separated entry names to refresh")
cmd.Flags().StringVar(&opts.FreezeAt, "freeze-at", "", "RFC3339 timestamp to pin moving refs")

return cmd
}
Loading
Loading