@@ -3,6 +3,7 @@ package cmd
33import (
44 "bufio"
55 "context"
6+ "fmt"
67 "os"
78 "path/filepath"
89 "regexp"
@@ -19,6 +20,7 @@ import (
1920
2021 "github.com/nektos/act/pkg/artifacts"
2122 "github.com/nektos/act/pkg/common"
23+ "github.com/nektos/act/pkg/container"
2224 "github.com/nektos/act/pkg/model"
2325 "github.com/nektos/act/pkg/runner"
2426)
@@ -39,6 +41,8 @@ func Execute(ctx context.Context, version string) {
3941 rootCmd .Flags ().BoolP ("list" , "l" , false , "list workflows" )
4042 rootCmd .Flags ().BoolP ("graph" , "g" , false , "draw workflows" )
4143 rootCmd .Flags ().StringP ("job" , "j" , "" , "run job" )
44+ rootCmd .Flags ().BoolP ("bug-report" , "" , false , "Display system information for bug report" )
45+
4246 rootCmd .Flags ().StringArrayVarP (& input .secrets , "secret" , "s" , []string {}, "secret to make available to actions with optional value (e.g. -s mysecret=foo or -s mysecret)" )
4347 rootCmd .Flags ().StringArrayVarP (& input .envs , "env" , "" , []string {}, "env to make available to actions with optional value (e.g. --env myenv=foo or --env myenv)" )
4448 rootCmd .Flags ().StringArrayVarP (& input .platforms , "platform" , "P" , []string {}, "custom image to use per platform (e.g. -P ubuntu-18.04=nektos/act-environments-ubuntu:18.04)" )
@@ -105,14 +109,94 @@ func args() []string {
105109
106110 args := make ([]string , 0 )
107111 for _ , f := range actrc {
108- args = append (args , readArgsFile (f )... )
112+ args = append (args , readArgsFile (f , true )... )
109113 }
110114
111115 args = append (args , os .Args [1 :]... )
112116 return args
113117}
114118
115- func readArgsFile (file string ) []string {
119+ func bugReport (ctx context.Context , version string ) error {
120+ var commonSocketPaths = []string {
121+ "/var/run/docker.sock" ,
122+ "/var/run/podman/podman.sock" ,
123+ "$HOME/.colima/docker.sock" ,
124+ "$XDG_RUNTIME_DIR/docker.sock" ,
125+ `\\.\pipe\docker_engine` ,
126+ }
127+
128+ sprintf := func (key , val string ) string {
129+ return fmt .Sprintf ("%-24s%s\n " , key , val )
130+ }
131+
132+ report := sprintf ("act version:" , version )
133+ report += sprintf ("GOOS:" , runtime .GOOS )
134+ report += sprintf ("GOARCH:" , runtime .GOARCH )
135+ report += sprintf ("NumCPU:" , fmt .Sprint (runtime .NumCPU ()))
136+
137+ var dockerHost string
138+ if dockerHost = os .Getenv ("DOCKER_HOST" ); dockerHost == "" {
139+ dockerHost = "DOCKER_HOST environment variable is unset/empty."
140+ }
141+
142+ report += sprintf ("Docker host:" , dockerHost )
143+ report += fmt .Sprintln ("Sockets found:" )
144+ for _ , p := range commonSocketPaths {
145+ if strings .HasPrefix (p , `$` ) {
146+ v := strings .Split (p , `/` )[0 ]
147+ p = strings .Replace (p , v , os .Getenv (strings .TrimPrefix (v , `$` )), 1 )
148+ }
149+ if _ , err := os .Stat (p ); err != nil {
150+ continue
151+ } else {
152+ report += fmt .Sprintf ("\t %s\n " , p )
153+ }
154+ }
155+
156+ info , err := container .GetHostInfo (ctx )
157+ if err != nil {
158+ fmt .Println (report )
159+ return err
160+ }
161+
162+ report += sprintf ("Config files:" , "" )
163+ for _ , c := range configLocations () {
164+ args := readArgsFile (c , false )
165+ if len (args ) > 0 {
166+ report += fmt .Sprintf ("\t %s:\n " , c )
167+ for _ , l := range args {
168+ report += fmt .Sprintf ("\t \t %s\n " , l )
169+ }
170+ }
171+ }
172+
173+ report += fmt .Sprintln ("Docker Engine:" )
174+
175+ report += sprintf ("\t Engine version:" , info .ServerVersion )
176+ report += sprintf ("\t Engine runtime:" , info .DefaultRuntime )
177+ report += sprintf ("\t Cgroup version:" , info .CgroupVersion )
178+ report += sprintf ("\t Cgroup driver:" , info .CgroupDriver )
179+ report += sprintf ("\t Storage driver:" , info .Driver )
180+ report += sprintf ("\t Registry URI:" , info .IndexServerAddress )
181+
182+ report += sprintf ("\t OS:" , info .OperatingSystem )
183+ report += sprintf ("\t OS type:" , info .OSType )
184+ report += sprintf ("\t OS version:" , info .OSVersion )
185+ report += sprintf ("\t OS arch:" , info .Architecture )
186+ report += sprintf ("\t OS kernel:" , info .KernelVersion )
187+ report += sprintf ("\t OS CPU:" , fmt .Sprint (info .NCPU ))
188+ report += sprintf ("\t OS memory:" , fmt .Sprintf ("%d MB" , info .MemTotal / 1024 / 1024 ))
189+
190+ report += fmt .Sprintln ("\t Security options:" )
191+ for _ , secopt := range info .SecurityOptions {
192+ report += fmt .Sprintf ("\t \t %s\n " , secopt )
193+ }
194+
195+ fmt .Println (report )
196+ return nil
197+ }
198+
199+ func readArgsFile (file string , split bool ) []string {
116200 args := make ([]string , 0 )
117201 f , err := os .Open (file )
118202 if err != nil {
@@ -127,8 +211,10 @@ func readArgsFile(file string) []string {
127211 scanner := bufio .NewScanner (f )
128212 for scanner .Scan () {
129213 arg := strings .TrimSpace (scanner .Text ())
130- if strings .HasPrefix (arg , "-" ) {
214+ if strings .HasPrefix (arg , "-" ) && split {
131215 args = append (args , regexp .MustCompile (`\s` ).Split (arg , 2 )... )
216+ } else if ! split {
217+ args = append (args , arg )
132218 }
133219 }
134220 return args
@@ -162,6 +248,10 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
162248 log .SetFormatter (& log.JSONFormatter {})
163249 }
164250
251+ if ok , _ := cmd .Flags ().GetBool ("bug-report" ); ok {
252+ return bugReport (ctx , cmd .Version )
253+ }
254+
165255 if runtime .GOOS == "darwin" && runtime .GOARCH == "arm64" && input .containerArchitecture == "" {
166256 l := log .New ()
167257 l .SetFormatter (& log.TextFormatter {
@@ -256,7 +346,7 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
256346 if err := defaultImageSurvey (cfgLocations [0 ]); err != nil {
257347 log .Fatal (err )
258348 }
259- input .platforms = readArgsFile (cfgLocations [0 ])
349+ input .platforms = readArgsFile (cfgLocations [0 ], true )
260350 }
261351 }
262352
0 commit comments