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