MCPcopy Create free account
hub / github.com/cli/cli / runAll

Function runAll

script/ghmock/run.go:158–226  ·  view source on GitHub ↗

runAll runs each binary in turn and appends its requests to the log. It then saves the run and its report for ghmock export. A nil checker turns schema checks off.

(st *state, chk *checker, opts runOptions)

Source from the content-addressed store, hash-verified

156// then saves the run and its report for ghmock export. A nil checker turns
157// schema checks off.
158func runAll(st *state, chk *checker, opts runOptions) (runRecord, []runResult, error) {
159 start := time.Now().UTC()
160 rec := runRecord{ID: newRunID(start), Time: start.Truncate(time.Second), Command: opts.commandLine()}
161 configBaseline, err := st.snapshotConfig(rec.ID, opts.configDir)
162 if err != nil {
163 return runRecord{}, nil, err
164 }
165 rec.ConfigBaseline = configBaseline
166 baseline, err := st.snapshotGit(rec.ID, opts.in)
167 if err != nil {
168 return runRecord{}, nil, err
169 }
170 rec.GitBaseline = baseline
171 var ca *certAuthority
172 if !opts.localhost {
173 var err error
174 if ca, err = newCertAuthority(); err != nil {
175 return runRecord{}, nil, fmt.Errorf("making a certificate authority: %w", err)
176 }
177 }
178 results := make([]runResult, 0, len(opts.binaries))
179 for i, binary := range opts.binaries {
180 var configDir string
181 if configBaseline != "" {
182 configDir = filepath.ToSlash(filepath.Join("config", "runs", rec.ID, fmt.Sprint(i+1)))
183 if err := copyConfigTree(filepath.Join(st.dir, filepath.FromSlash(configBaseline)), filepath.Join(st.dir, filepath.FromSlash(configDir))); err != nil {
184 return runRecord{}, nil, fmt.Errorf("copying configuration for build %d: %w", i+1, err)
185 }
186 }
187 var gitDir string
188 if baseline != "" {
189 gitDir = gitBuildDirectory(rec.ID, i)
190 if err := copyGitTree(filepath.Join(st.dir, filepath.FromSlash(baseline)), filepath.Join(st.dir, filepath.FromSlash(gitDir))); err != nil {
191 return runRecord{}, nil, fmt.Errorf("copying Git state for build %d: %w", i+1, err)
192 }
193 }
194 res, err := runBinary(st, chk, binary, opts, ca, gitDir, configDir)
195 if err != nil {
196 return runRecord{}, nil, fmt.Errorf("%s: %w", binary, err)
197 }
198 for i := range res.requests {
199 res.requests[i].Run = rec.ID
200 res.requests[i].Binary = binary
201 }
202 if err := st.appendLog(res.requests); err != nil {
203 return runRecord{}, nil, err
204 }
205 results = append(results, res)
206 rec.Results = append(rec.Results, runOutcome{
207 Binary: binary, Path: res.path, Version: res.version, ExitCode: res.exitCode,
208 TimedOut: res.timedOut, Stdout: res.stdout, Stderr: res.stderr,
209 Terminal: res.terminal, TerminalOutput: res.terminalOutput, Steps: res.steps, UnusedKeys: res.unusedKeys,
210 Git: res.git, Config: res.config,
211 })
212 }
213
214 var notes []string
215 if chk != nil {

Callers 2

cmdRunFunction · 0.85
TestRunAllFunction · 0.85

Calls 15

newRunIDFunction · 0.85
newCertAuthorityFunction · 0.85
copyConfigTreeFunction · 0.85
gitBuildDirectoryFunction · 0.85
copyGitTreeFunction · 0.85
runBinaryFunction · 0.85
printReportFunction · 0.85
commandLineMethod · 0.80
snapshotConfigMethod · 0.80
snapshotGitMethod · 0.80
JoinMethod · 0.80
appendLogMethod · 0.80

Tested by 1

TestRunAllFunction · 0.68