Skip to content

Commit 809b1de

Browse files
committed
feat(test): thread --artifact to formatters for diff annotations
Signed-off-by: caesarsage <destinyerhabor6@gmail.com>
1 parent 2fc5e8d commit 809b1de

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

cmd/test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ func NewTestCommand(globalClientOpts *connectors.ClientOptions) *cobra.Command {
129129
operationsHeaders: operationsHeaders,
130130
oAuth2Context: oAuth2Context,
131131
outputFormat: outputFormat,
132+
artifactPath: artifact,
132133
}
133134

134135
if !dryRun {

cmd/testExecutor.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type testParams struct {
3737
operationsHeaders string
3838
oAuth2Context string
3939
outputFormat string
40+
artifactPath string
4041
}
4142

4243
// progressWriter returns where human progress/diagnostics should go. For
@@ -87,24 +88,25 @@ func runTestAndWait(mc connectors.MicrocksClient, params testParams) (bool, stri
8788
time.Sleep(2 * time.Second)
8889
}
8990

90-
if err := renderTestResult(mc, testResultID, params.outputFormat); err != nil {
91+
if err := renderTestResult(mc, testResultID, params.outputFormat, params.artifactPath); err != nil {
9192
return false, testResultID, err
9293
}
9394

9495
return success, testResultID, nil
9596
}
9697

9798
// renderTestResult fetches the full result and writes it to stdout in the
98-
// requested format.
99-
func renderTestResult(mc connectors.MicrocksClient, testResultID, format string) error {
99+
// requested format. artifactPath (when set) lets the github-actions formatter
100+
// map failures to file:line.
101+
func renderTestResult(mc connectors.MicrocksClient, testResultID, format, artifactPath string) error {
100102
if format == "" {
101103
format = string(output.FormatText)
102104
}
103105
full, err := mc.GetFullTestResult(testResultID)
104106
if err != nil {
105107
return fmt.Errorf("Got error when retrieving full test result: %s", err)
106108
}
107-
formatter, err := output.NewFormatter(output.OutputFormat(format))
109+
formatter, err := output.NewFormatter(output.OutputFormat(format), output.WithArtifactPath(artifactPath))
108110
if err != nil {
109111
return err
110112
}

0 commit comments

Comments
 (0)