You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: main.go
    path of file: ./repos/cockroach/pkg/cmd/bazci/bazel-github-helper
    
    the code of the file until where you have to start completion: // Copyright 2024 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache 
    
func dumpSummary(f *os.File, invocation *engflow.InvocationInfo) error {
	var title string
	if !invocation.Finished {
		title = "# Build did not succeed"
	} else if invocation.ExitCode == 0 {
		title = "# Build Succeeded"
	} else {
		title = fmt.Sprintf("# Build Failed (code: %s)", invocation.ExitCodeName)
	}
	_, err := f.WriteString(fmt.Sprintf("%s\n", title))
	if err != nil {
		return err
	}
	_, err = f.WriteString(fmt.Sprintf("### [EngFlow link](https://%s.cluster.engflow.com/invocations/default/%s)\n", *serverName, invocation.InvocationId))
	if err != nil {
		return err
	}

	var failedTests []failedTestResult
	for _, testResults := range invocation.TestResults {
		for _, testResult := range testResults {
			if testResult.Err != nil {
				// We already logged this error.
				continue
			}
			var testXml bazelutil.TestSuites
			if err := xml.Unmarshal([]byte(testResult.TestXml), &testXml); err != nil {
				fmt.Fprintf(os.Stderr, "Could not parse test.xml: got error %+v\n", err)
				continue
			}
			for _, suite := range testXml.Suites {
				for _, testCase := range suite.TestCases {
					outResult := failedTestResult{
						label:   testResult.Label,
						name:    testCase.Name,
						run:     testResult.Run,
						shard:   testResult.Shard,
						attempt: testResult.Attempt,
					}
					if testCase.Error != nil {
						outResult.status = "ERROR"
					} else if testCase.Failure != nil {
						outResult.status = "FAILURE"
					}
					if outResult.status != "" {
						failedTests = append(failedTests, outResult)
					}
				}
			}
		}
	}

	if len(failedTests) != 0 {
		_, err := f.WriteString(`| Label | TestName | Status | Link |
| --- | --- | --- | --- |
`)
		if err != nil {
			return err
		}
		for _, failedTest := range failedTests {
			base64Target := base64.StdEncoding.EncodeToString([]byte(failedTest.label))
			_, err := f.WriteString(fmt.Sprintf("| `%s` | `%s` | `%s` | [Link](https://%s.cluster.engflow.com/invocations/default/%s?testReportRun=%d&testReportShard=%d&testReportAttempt=%d#targets-%s) |\n", failedTest.label, failedTest.name, failedTest.status, *serverName, invocation.InvocationId, failedTest.run, failedTest.shard, failedTest.attempt, base64Target))
			if err != nil {
				return err
			}
		}
	}

	if len(invocation.FailedBuildActions) > 0 {
		for _, actions := range invocation.FailedBuildActions {
			for _, action := range actions {
				_, err := f.WriteString(fmt.Sprintf("### Build of `%s` failed (exit code %d)\n", action.Label, action.ExitCode))
				if err != nil {
					return err
				}
				if action.FailureDetail != "" {
					_, err := f.WriteString(fmt.Sprintf("```\n%s\n```\n", action.FailureDetail))
					if err != nil {
						return err
					}
				}
				for _, err := range action.Errs {
					fmt.Fprintf(os.Stderr, "could not download action log: got error %+v\n", err)
				}
				if action.Stdout != "" {
					_, err := f.WriteString(fmt.Sprintf("Stdout:\n```\n%s\n```\n", action.Stdout))
					if err != nil {
						return err
					}
				}
				if action.Stderr != "" {
					_, err := f.WriteString(fmt.Sprintf("Stdout:\n```\n%s\n```\n", action.Stderr))
					if err != nil {
						return err
					}
				}
			}
		}
	}

	return nil
}