@@ -3,6 +3,7 @@ package cmd
3
3
import (
4
4
"bufio"
5
5
"context"
6
+ "fmt"
6
7
"os"
7
8
"path/filepath"
8
9
"regexp"
@@ -19,6 +20,7 @@ import (
19
20
20
21
"github.com/nektos/act/pkg/artifacts"
21
22
"github.com/nektos/act/pkg/common"
23
+ "github.com/nektos/act/pkg/container"
22
24
"github.com/nektos/act/pkg/model"
23
25
"github.com/nektos/act/pkg/runner"
24
26
)
@@ -39,6 +41,8 @@ func Execute(ctx context.Context, version string) {
39
41
rootCmd .Flags ().BoolP ("list" , "l" , false , "list workflows" )
40
42
rootCmd .Flags ().BoolP ("graph" , "g" , false , "draw workflows" )
41
43
rootCmd .Flags ().StringP ("job" , "j" , "" , "run job" )
44
+ rootCmd .Flags ().BoolP ("bug-report" , "" , false , "Display system information for bug report" )
45
+
42
46
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)" )
43
47
rootCmd .Flags ().StringArrayVarP (& input .envs , "env" , "" , []string {}, "env to make available to actions with optional value (e.g. --env myenv=foo or --env myenv)" )
44
48
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 {
105
109
106
110
args := make ([]string , 0 )
107
111
for _ , f := range actrc {
108
- args = append (args , readArgsFile (f )... )
112
+ args = append (args , readArgsFile (f , true )... )
109
113
}
110
114
111
115
args = append (args , os .Args [1 :]... )
112
116
return args
113
117
}
114
118
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 {
116
200
args := make ([]string , 0 )
117
201
f , err := os .Open (file )
118
202
if err != nil {
@@ -127,8 +211,10 @@ func readArgsFile(file string) []string {
127
211
scanner := bufio .NewScanner (f )
128
212
for scanner .Scan () {
129
213
arg := strings .TrimSpace (scanner .Text ())
130
- if strings .HasPrefix (arg , "-" ) {
214
+ if strings .HasPrefix (arg , "-" ) && split {
131
215
args = append (args , regexp .MustCompile (`\s` ).Split (arg , 2 )... )
216
+ } else if ! split {
217
+ args = append (args , arg )
132
218
}
133
219
}
134
220
return args
@@ -162,6 +248,10 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
162
248
log .SetFormatter (& log.JSONFormatter {})
163
249
}
164
250
251
+ if ok , _ := cmd .Flags ().GetBool ("bug-report" ); ok {
252
+ return bugReport (ctx , cmd .Version )
253
+ }
254
+
165
255
if runtime .GOOS == "darwin" && runtime .GOARCH == "arm64" && input .containerArchitecture == "" {
166
256
l := log .New ()
167
257
l .SetFormatter (& log.TextFormatter {
@@ -256,7 +346,7 @@ func newRunCommand(ctx context.Context, input *Input) func(*cobra.Command, []str
256
346
if err := defaultImageSurvey (cfgLocations [0 ]); err != nil {
257
347
log .Fatal (err )
258
348
}
259
- input .platforms = readArgsFile (cfgLocations [0 ])
349
+ input .platforms = readArgsFile (cfgLocations [0 ], true )
260
350
}
261
351
}
262
352
0 commit comments