1- import { error , getInput , info , setOutput , warning } from '@actions/core'
2- import { appendFileSync , existsSync , readFileSync } from 'fs'
1+ import { error , getInput , info , setOutput } from '@actions/core'
2+ import { existsSync , readFileSync } from 'fs'
33import {
44 downloadArtifact ,
55 postCommentIfInPr ,
66 resolveExistingCommentIfFound ,
77 uploadArtifact ,
88} from './actions'
9- import {
10- callLaceworkCli ,
11- debug ,
12- generateUILink ,
13- getActionRef ,
14- getMsSinceStart ,
15- getOptionalEnvVariable ,
16- getRequiredEnvVariable ,
17- getRunUrl ,
18- telemetryCollector ,
19- } from './util'
9+ import { callLaceworkCli , debug , generateUILink , getOptionalEnvVariable } from './util'
2010
2111import path from 'path'
2212
@@ -41,17 +31,7 @@ async function runAnalysis() {
4131 const toUpload : string [ ] = [ ]
4232
4333 // command to print both sarif and lwjson formats
44- var args = [
45- 'sca' ,
46- 'scan' ,
47- '.' ,
48- '--formats' ,
49- 'sarif' ,
50- '--output' ,
51- sarifReportPath ,
52- '--deployment' ,
53- 'ci' ,
54- ]
34+ var args = [ 'scan' , '.' , '--formats' , 'sarif' , '--output' , sarifReportPath , '--deployment' , 'ci' ]
5535 if ( target === 'push' ) {
5636 args . push ( '--save-results' )
5737 }
@@ -64,14 +44,11 @@ async function runAnalysis() {
6444 const uploadStart = Date . now ( )
6545
6646 await uploadArtifact ( getArtifactName ( target ) , ...toUpload )
67-
68- telemetryCollector . addField ( 'duration.upload-artifacts' , ( Date . now ( ) - uploadStart ) . toString ( ) )
6947 setOutput ( `${ target } -completed` , true )
7048}
7149
7250export async function compareResults ( oldReport : string , newReport : string ) : Promise < string > {
7351 const args = [
74- 'sca' ,
7552 'compare' ,
7653 '--old' ,
7754 oldReport ,
@@ -101,10 +78,6 @@ async function displayResults() {
10178 const downloadStart = Date . now ( )
10279 const artifactOld = await downloadArtifact ( getArtifactName ( 'old' ) )
10380 const artifactNew = await downloadArtifact ( getArtifactName ( 'new' ) )
104- telemetryCollector . addField (
105- 'duration.download-artifacts' ,
106- ( Date . now ( ) - downloadStart ) . toString ( )
107- )
10881 const sarifFileOld = path . join ( artifactOld , sarifReportPath )
10982 const sarifFileNew = path . join ( artifactNew , sarifReportPath )
11083
@@ -129,7 +102,6 @@ async function displayResults() {
129102 } else {
130103 await resolveExistingCommentIfFound ( )
131104 }
132- telemetryCollector . addField ( 'duration.comment' , ( Date . now ( ) - commentStart ) . toString ( ) )
133105 setOutput ( `display-completed` , true )
134106}
135107
@@ -142,29 +114,15 @@ function getArtifactName(target: string): string {
142114}
143115
144116async function main ( ) {
145- telemetryCollector . addField ( 'duration.install' , getMsSinceStart ( ) )
146- telemetryCollector . addField ( 'version' , getActionRef ( ) )
147- telemetryCollector . addField ( 'url' , getRunUrl ( ) )
148- telemetryCollector . addField ( 'repository' , getRequiredEnvVariable ( 'GITHUB_REPOSITORY' ) )
149117 if ( getInput ( 'target' ) !== '' ) {
150- telemetryCollector . addField ( 'run-type' , 'analysis' )
151118 await runAnalysis ( )
152119 } else {
153- telemetryCollector . addField ( 'run-type' , 'display' )
154120 await displayResults ( )
155121 }
156122}
157123
158124main ( )
159125 . catch ( ( e ) => {
160- telemetryCollector . addError ( 'error' , e )
161126 error ( e . message ) // TODO: Use setFailed once we want failures to be fatal
162127 } )
163- . finally ( async ( ) => {
164- telemetryCollector . addField ( 'metadata.integration' , 'github' )
165- telemetryCollector . addField ( 'duration.total' , getMsSinceStart ( ) )
166- await telemetryCollector . report ( ) . catch ( ( err ) => {
167- warning ( 'Failed to report telemetry: ' + err . message )
168- } )
169- appendFileSync ( getRequiredEnvVariable ( 'GITHUB_ENV' ) , 'LACEWORK_WROTE_TELEMETRY=true\n' )
170- } )
128+ . finally ( async ( ) => { } )
0 commit comments