@@ -9,6 +9,7 @@ const archiver = require("../helpers/archiver"),
9
9
utils = require ( "../helpers/utils" ) ,
10
10
fileHelpers = require ( "../helpers/fileHelpers" ) ,
11
11
syncRunner = require ( "../helpers/syncRunner" ) ,
12
+ checkUploaded = require ( "../helpers/checkUploaded" ) ,
12
13
reportGenerator = require ( '../helpers/reporterHTML' ) . reportGenerator ,
13
14
{ initTimeComponents, markBlockStart, markBlockEnd, getTimeComponents} = require ( '../helpers/timeComponents' ) ;
14
15
@@ -81,107 +82,115 @@ module.exports = function run(args) {
81
82
82
83
// warn if specFiles cross our limit
83
84
utils . warnSpecLimit ( bsConfig , args , specFiles ) ;
84
-
85
85
markBlockEnd ( 'preArchiveSteps' ) ;
86
- // Archive the spec files
87
- markBlockStart ( 'zip' ) ;
88
- markBlockStart ( 'zip.archive' ) ;
89
- return archiver . archive ( bsConfig . run_settings , config . fileName , args . exclude ) . then ( function ( data ) {
90
-
91
- markBlockEnd ( 'zip.archive' ) ;
92
- // Uploaded zip file
93
- markBlockStart ( 'zip.zipUpload' ) ;
94
- return zipUploader . zipUpload ( bsConfig , config . fileName ) . then ( async function ( zip ) {
95
-
96
- markBlockEnd ( 'zip.zipUpload' ) ;
97
- markBlockEnd ( 'zip' ) ;
98
- // Create build
99
-
100
- //setup Local Testing
101
- markBlockStart ( 'localSetup' ) ;
102
- let bs_local = await utils . setupLocalTesting ( bsConfig , args ) ;
103
- markBlockEnd ( 'localSetup' ) ;
104
- markBlockStart ( 'createBuild' ) ;
105
- return build . createBuild ( bsConfig , zip ) . then ( function ( data ) {
106
- markBlockEnd ( 'createBuild' ) ;
107
- markBlockEnd ( 'total' ) ;
108
- let message = `${ data . message } ! ${ Constants . userMessages . BUILD_CREATED } with build id: ${ data . build_id } ` ;
109
- let dashboardLink = `${ Constants . userMessages . VISIT_DASHBOARD } ${ data . dashboard_url } ` ;
110
- utils . exportResults ( data . build_id , `${ config . dashboardUrl } ${ data . build_id } ` ) ;
111
- if ( ( utils . isUndefined ( bsConfig . run_settings . parallels ) && utils . isUndefined ( args . parallels ) ) || ( ! utils . isUndefined ( bsConfig . run_settings . parallels ) && bsConfig . run_settings . parallels == Constants . cliMessages . RUN . DEFAULT_PARALLEL_MESSAGE ) ) {
112
- logger . warn ( Constants . userMessages . NO_PARALLELS ) ;
113
- }
86
+ markBlockStart ( 'checkAlreadyUploaded' ) ;
87
+ return checkUploaded . checkUploadedMd5 ( bsConfig , args ) . then ( function ( md5data ) {
88
+ markBlockEnd ( 'checkAlreadyUploaded' ) ;
89
+
90
+ // Archive the spec files
91
+ markBlockStart ( 'zip' ) ;
92
+ markBlockStart ( 'zip.archive' ) ;
93
+ return archiver . archive ( bsConfig . run_settings , config . fileName , args . exclude , md5data ) . then ( function ( data ) {
94
+ markBlockEnd ( 'zip.archive' ) ;
95
+
96
+ // Uploaded zip file
97
+ markBlockStart ( 'zip.zipUpload' ) ;
98
+ return zipUploader . zipUpload ( bsConfig , config . fileName , md5data ) . then ( async function ( zip ) {
99
+ markBlockEnd ( 'zip.zipUpload' ) ;
100
+ markBlockEnd ( 'zip' ) ;
101
+ // Create build
102
+
103
+ //setup Local Testing
104
+ markBlockStart ( 'localSetup' ) ;
105
+ let bs_local = await utils . setupLocalTesting ( bsConfig , args ) ;
106
+ markBlockEnd ( 'localSetup' ) ;
107
+ markBlockStart ( 'createBuild' ) ;
108
+ return build . createBuild ( bsConfig , zip ) . then ( function ( data ) {
109
+ markBlockEnd ( 'createBuild' ) ;
110
+ markBlockEnd ( 'total' ) ;
111
+ let message = `${ data . message } ! ${ Constants . userMessages . BUILD_CREATED } with build id: ${ data . build_id } ` ;
112
+ let dashboardLink = `${ Constants . userMessages . VISIT_DASHBOARD } ${ data . dashboard_url } ` ;
113
+ utils . exportResults ( data . build_id , `${ config . dashboardUrl } ${ data . build_id } ` ) ;
114
+ if ( ( utils . isUndefined ( bsConfig . run_settings . parallels ) && utils . isUndefined ( args . parallels ) ) || ( ! utils . isUndefined ( bsConfig . run_settings . parallels ) && bsConfig . run_settings . parallels == Constants . cliMessages . RUN . DEFAULT_PARALLEL_MESSAGE ) ) {
115
+ logger . warn ( Constants . userMessages . NO_PARALLELS ) ;
116
+ }
114
117
115
- if ( bsConfig . run_settings . cypress_version && bsConfig . run_settings . cypress_version !== data . cypress_version ) {
116
- let versionMessage = utils . versionChangedMessage ( bsConfig . run_settings . cypress_version , data . cypress_version )
117
- logger . warn ( versionMessage ) ;
118
- }
118
+ if ( bsConfig . run_settings . cypress_version && bsConfig . run_settings . cypress_version !== data . cypress_version ) {
119
+ let versionMessage = utils . versionChangedMessage ( bsConfig . run_settings . cypress_version , data . cypress_version )
120
+ logger . warn ( versionMessage ) ;
121
+ }
119
122
120
- if ( ! args . disableNpmWarning && bsConfig . run_settings . npm_dependencies && Object . keys ( bsConfig . run_settings . npm_dependencies ) . length <= 0 ) {
121
- logger . warn ( Constants . userMessages . NO_NPM_DEPENDENCIES ) ;
122
- logger . warn ( Constants . userMessages . NO_NPM_DEPENDENCIES_READ_MORE ) ;
123
- }
123
+ if ( ! args . disableNpmWarning && bsConfig . run_settings . npm_dependencies && Object . keys ( bsConfig . run_settings . npm_dependencies ) . length <= 0 ) {
124
+ logger . warn ( Constants . userMessages . NO_NPM_DEPENDENCIES ) ;
125
+ logger . warn ( Constants . userMessages . NO_NPM_DEPENDENCIES_READ_MORE ) ;
126
+ }
124
127
125
- if ( args . sync ) {
126
- syncRunner . pollBuildStatus ( bsConfig , data ) . then ( async ( exitCode ) => {
128
+ if ( args . sync ) {
129
+ syncRunner . pollBuildStatus ( bsConfig , data ) . then ( async ( exitCode ) => {
127
130
128
- // stop the Local instance
129
- await utils . stopLocalBinary ( bsConfig , bs_local , args ) ;
131
+ // stop the Local instance
132
+ await utils . stopLocalBinary ( bsConfig , bs_local , args ) ;
130
133
131
- // Generate custom report!
132
- reportGenerator ( bsConfig , data . build_id , args , function ( ) {
133
- utils . sendUsageReport ( bsConfig , args , `${ message } \n${ dashboardLink } ` , Constants . messageTypes . SUCCESS , null ) ;
134
- utils . handleSyncExit ( exitCode , data . dashboard_url ) ;
134
+ // Generate custom report!
135
+ reportGenerator ( bsConfig , data . build_id , args , function ( ) {
136
+ utils . sendUsageReport ( bsConfig , args , `${ message } \n${ dashboardLink } ` , Constants . messageTypes . SUCCESS , null ) ;
137
+ utils . handleSyncExit ( exitCode , data . dashboard_url ) ;
138
+ } ) ;
135
139
} ) ;
136
- } ) ;
137
- }
138
-
139
- logger . info ( message ) ;
140
- logger . info ( dashboardLink ) ;
141
- if ( ! args . sync ) logger . info ( Constants . userMessages . EXIT_SYNC_CLI_MESSAGE . replace ( "<build-id>" , data . build_id ) ) ;
142
- let dataToSend = {
143
- time_components : getTimeComponents ( ) ,
144
- build_id : data . build_id ,
145
- } ;
146
- if ( bsConfig && bsConfig . connection_settings ) {
147
- if ( bsConfig . connection_settings . local_mode ) {
148
- dataToSend . local_mode = bsConfig . connection_settings . local_mode ;
149
140
}
150
- if ( bsConfig . connection_settings . usedAutoLocal ) {
151
- dataToSend . used_auto_local = bsConfig . connection_settings . usedAutoLocal ;
141
+
142
+ logger . info ( message ) ;
143
+ logger . info ( dashboardLink ) ;
144
+ if ( ! args . sync ) logger . info ( Constants . userMessages . EXIT_SYNC_CLI_MESSAGE . replace ( "<build-id>" , data . build_id ) ) ;
145
+ let dataToSend = {
146
+ time_components : getTimeComponents ( ) ,
147
+ build_id : data . build_id ,
148
+ } ;
149
+ if ( bsConfig && bsConfig . connection_settings ) {
150
+ if ( bsConfig . connection_settings . local_mode ) {
151
+ dataToSend . local_mode = bsConfig . connection_settings . local_mode ;
152
+ }
153
+ if ( bsConfig . connection_settings . usedAutoLocal ) {
154
+ dataToSend . used_auto_local = bsConfig . connection_settings . usedAutoLocal ;
155
+ }
152
156
}
153
- }
154
- utils . sendUsageReport ( bsConfig , args , `${ message } \n${ dashboardLink } ` , Constants . messageTypes . SUCCESS , null , dataToSend ) ;
155
- return ;
156
- } ) . catch ( async function ( err ) {
157
- // Build creation failed
157
+ utils . sendUsageReport ( bsConfig , args , `${ message } \n${ dashboardLink } ` , Constants . messageTypes . SUCCESS , null , dataToSend ) ;
158
+ return ;
159
+ } ) . catch ( async function ( err ) {
160
+ // Build creation failed
161
+ logger . error ( err ) ;
162
+ // stop the Local instance
163
+ await utils . stopLocalBinary ( bsConfig , bs_local , args ) ;
164
+
165
+ utils . sendUsageReport ( bsConfig , args , err , Constants . messageTypes . ERROR , 'build_failed' ) ;
166
+ } ) ;
167
+ } ) . catch ( function ( err ) {
168
+ // Zip Upload failed | Local Start failed
158
169
logger . error ( err ) ;
159
- // stop the Local instance
160
- await utils . stopLocalBinary ( bsConfig , bs_local , args ) ;
161
-
162
- utils . sendUsageReport ( bsConfig , args , err , Constants . messageTypes . ERROR , 'build_failed' ) ;
170
+ if ( err === Constants . userMessages . LOCAL_START_FAILED ) {
171
+ utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . LOCAL_START_FAILED } ` , Constants . messageTypes . ERROR , 'local_start_failed' ) ;
172
+ } else {
173
+ logger . error ( Constants . userMessages . ZIP_UPLOAD_FAILED ) ;
174
+ fileHelpers . deleteZip ( ) ;
175
+ utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . ZIP_UPLOAD_FAILED } ` , Constants . messageTypes . ERROR , 'zip_upload_failed' ) ;
176
+ }
163
177
} ) ;
164
178
} ) . catch ( function ( err ) {
165
- // Zip Upload failed | Local Start failed
179
+ // Zipping failed
166
180
logger . error ( err ) ;
167
- if ( err === Constants . userMessages . LOCAL_START_FAILED ) {
168
- utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . LOCAL_START_FAILED } ` , Constants . messageTypes . ERROR , 'local_start_failed' ) ;
169
- } else {
170
- logger . error ( Constants . userMessages . ZIP_UPLOAD_FAILED ) ;
181
+ logger . error ( Constants . userMessages . FAILED_TO_ZIP ) ;
182
+ utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . FAILED_TO_ZIP } ` , Constants . messageTypes . ERROR , 'zip_creation_failed' ) ;
183
+ try {
171
184
fileHelpers . deleteZip ( ) ;
172
- utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . ZIP_UPLOAD_FAILED } ` , Constants . messageTypes . ERROR , 'zip_upload_failed' ) ;
185
+ } catch ( err ) {
186
+ utils . sendUsageReport ( bsConfig , args , Constants . userMessages . ZIP_DELETE_FAILED , Constants . messageTypes . ERROR , 'zip_deletion_failed' ) ;
173
187
}
174
188
} ) ;
175
189
} ) . catch ( function ( err ) {
176
- // Zipping failed
190
+ // md5 check failed
177
191
logger . error ( err ) ;
178
- logger . error ( Constants . userMessages . FAILED_TO_ZIP ) ;
179
- utils . sendUsageReport ( bsConfig , args , `${ err } \n${ Constants . userMessages . FAILED_TO_ZIP } ` , Constants . messageTypes . ERROR , 'zip_creation_failed' ) ;
180
- try {
181
- fileHelpers . deleteZip ( ) ;
182
- } catch ( err ) {
183
- utils . sendUsageReport ( bsConfig , args , Constants . userMessages . ZIP_DELETE_FAILED , Constants . messageTypes . ERROR , 'zip_deletion_failed' ) ;
184
- }
192
+ logger . error ( Constants . userMessages . FAILED_MD5_CHECK ) ;
193
+ utils . sendUsageReport ( bsConfig , args , Constants . userMessages . MD5_CHECK_FAILED , Constants . messageTypes . ERROR , 'zip_already_uploaded_failed' ) ;
185
194
} ) ;
186
195
} ) . catch ( function ( err ) {
187
196
// browerstack.json is not valid
0 commit comments