@@ -30,16 +30,17 @@ const (
3030)
3131
3232func executeRunTestsV2Step (ctx context.Context , engine * engine.Engine , r * api.StartStepRequest , out io.Writer , tiConfig * tiCfg.Cfg ) (
33- * runtime.State , map [string ]string , []byte , []* api.OutputV2 , string , error ) {
33+ * runtime.State , map [string ]string , []byte , []* api.OutputV2 , string , * types. TelemetryData , error ) {
3434 start := time .Now ()
35+ telemetry := & types.TelemetryData {}
3536 log := logrus .New ()
3637 log .Out = out
3738 step := toStep (r )
3839 optimizationState := types .DISABLED
3940 step .Entrypoint = r .RunTestsV2 .Entrypoint
40- preCmd , err := leRuntime .SetupRunTestV2 (ctx , & r .RunTestsV2 , step .Name , r .WorkingDir , log , r .Envs , tiConfig )
41+ preCmd , err := leRuntime .SetupRunTestV2 (ctx , & r .RunTestsV2 , step .Name , r .WorkingDir , log , r .Envs , tiConfig , & telemetry . TestIntelligenceMetaData )
4142 if err != nil {
42- return nil , nil , nil , nil , string (optimizationState ), err
43+ return nil , nil , nil , nil , string (optimizationState ), telemetry , err
4344 }
4445 command := r .RunTestsV2 .Command [0 ]
4546 if preCmd != "" {
@@ -48,7 +49,7 @@ func executeRunTestsV2Step(ctx context.Context, engine *engine.Engine, r *api.St
4849 step .Command = []string {command }
4950
5051 if (len (r .OutputVars ) > 0 || len (r .Outputs ) > 0 ) && (len (step .Entrypoint ) == 0 || len (step .Command ) == 0 ) {
51- return nil , nil , nil , nil , string (optimizationState ), fmt .Errorf ("output variable should not be set for unset entrypoint or command" )
52+ return nil , nil , nil , nil , string (optimizationState ), telemetry , fmt .Errorf ("output variable should not be set for unset entrypoint or command" )
5253 }
5354
5455 enablePluginOutputSecrets := IsFeatureFlagEnabled (ciEnablePluginOutputSecrets , engine , step )
@@ -87,17 +88,18 @@ func executeRunTestsV2Step(ctx context.Context, engine *engine.Engine, r *api.St
8788 // If there are no paths specified, set Paths[0] to include all XML files and all TRX files
8889 r .TestReport .Junit .Paths = []string {"**/*.xml" , "**/*.trx" }
8990 }
90- if rerr := report .ParseAndUploadTests (ctx , r .TestReport , r .WorkingDir , step .Name , log , time .Now (), tiConfig , r .Envs ); rerr != nil {
91+ if _ , rerr := report .ParseAndUploadTests (ctx , r .TestReport , r .WorkingDir , step .Name , log , time .Now (), tiConfig , & telemetry . TestIntelligenceMetaData , r .Envs ); rerr != nil {
9192 log .WithError (rerr ).Errorln ("failed to upload report" )
9293 }
9394
94- if uerr := callgraph .Upload (ctx , step .Name , time .Since (start ).Milliseconds (), log , time .Now (), tiConfig , outDir ); uerr != nil {
95+ //Passing default false for failed test for now
96+ if uerr := callgraph .Upload (ctx , step .Name , time .Since (start ).Milliseconds (), log , time .Now (), tiConfig , outDir , false ); uerr != nil {
9597 log .WithError (uerr ).Errorln ("unable to collect callgraph" )
9698 }
9799
98100 // Parse and upload savings to TI
99101 if tiConfig .GetParseSavings () {
100- optimizationState = savings .ParseAndUploadSavings (ctx , r .WorkingDir , log , step .Name , checkStepSuccess (exited , err ), timeTakenMs , tiConfig , r .Envs )
102+ optimizationState = savings .ParseAndUploadSavings (ctx , r .WorkingDir , log , step .Name , checkStepSuccess (exited , err ), timeTakenMs , tiConfig , r .Envs , telemetry )
101103 }
102104
103105 artifact , _ := fetchArtifactDataFromArtifactFile (artifactFile , out )
@@ -170,12 +172,12 @@ func executeRunTestsV2Step(ctx context.Context, engine *engine.Engine, r *api.St
170172 outputsV2 = append (outputsV2 , summaryOutputsV2 ... )
171173 }
172174
173- return exited , outputs , artifact , outputsV2 , string (optimizationState ), finalErr
175+ return exited , outputs , artifact , outputsV2 , string (optimizationState ), telemetry , finalErr
174176
175177 } else {
176178 outputs , err := fetchOutputVariables (outputFile , out , false ) // nolint:govet
177179 if err != nil {
178- return exited , nil , nil , nil , string (optimizationState ), err
180+ return nil , nil , nil , nil , string (optimizationState ), telemetry , err
179181 }
180182 // Delete output variable file
181183 if ferr := os .Remove (outputFile ); ferr != nil {
@@ -195,22 +197,22 @@ func executeRunTestsV2Step(ctx context.Context, engine *engine.Engine, r *api.St
195197 if report .TestSummaryAsOutputEnabled (r .Envs ) {
196198 outputsV2 = append (outputsV2 , summaryOutputsV2 ... )
197199 }
198- return exited , outputs , artifact , outputsV2 , string (optimizationState ), err
200+ return exited , outputs , artifact , outputsV2 , string (optimizationState ), telemetry , err
199201 } else if len (r .OutputVars ) > 0 {
200202 // only return err when output vars are expected
201203 if report .TestSummaryAsOutputEnabled (r .Envs ) {
202- return exited , summaryOutputs , artifact , summaryOutputsV2 , string (optimizationState ), err
204+ return exited , summaryOutputs , artifact , summaryOutputsV2 , string (optimizationState ), telemetry , err
203205 }
204- return exited , outputs , artifact , nil , string (optimizationState ), err
206+ return exited , outputs , artifact , nil , string (optimizationState ), telemetry , err
205207 }
206208 if len (summaryOutputsV2 ) != 0 && report .TestSummaryAsOutputEnabled (r .Envs ) {
207- return exited , outputs , artifact , summaryOutputsV2 , string (optimizationState ), nil
209+ return exited , outputs , artifact , summaryOutputsV2 , string (optimizationState ), telemetry , nil
208210 }
209- return exited , outputs , artifact , nil , string (optimizationState ), nil
211+ return exited , outputs , artifact , nil , string (optimizationState ), telemetry , nil
210212 }
211213 }
212214 if len (summaryOutputsV2 ) != 0 && report .TestSummaryAsOutputEnabled (r .Envs ) {
213- return exited , summaryOutputs , artifact , summaryOutputsV2 , string (optimizationState ), err
215+ return exited , summaryOutputs , artifact , summaryOutputsV2 , string (optimizationState ), telemetry , err
214216 }
215- return exited , nil , artifact , nil , string (optimizationState ), err
217+ return exited , nil , artifact , nil , string (optimizationState ), telemetry , err
216218}
0 commit comments