@@ -3,217 +3,15 @@ const { API_URL } = require('./constants');
3
3
const utils = require ( '../helpers/utils' ) ;
4
4
const fs = require ( 'fs' ) ;
5
5
const path = require ( 'path' ) ;
6
- const http = require ( 'http' ) ;
7
- const https = require ( 'https' ) ;
8
6
const request = require ( 'request' ) ;
9
- var gitLastCommit = require ( 'git-last-commit' ) ;
10
- const { v4 : uuidv4 } = require ( 'uuid' ) ;
11
7
const os = require ( 'os' ) ;
12
- const { promisify } = require ( 'util' ) ;
13
- const getRepoInfo = require ( 'git-repo-info' ) ;
14
- const gitconfig = require ( 'gitconfiglocal' ) ;
15
- const { spawn, execSync } = require ( 'child_process' ) ;
16
8
const glob = require ( 'glob' ) ;
17
-
18
- exports . getFileSeparatorData = ( ) => {
19
- return / ^ w i n / . test ( process . platform ) ? "\\" : "/" ;
20
- }
21
-
22
- exports . findGitConfig = ( filePath ) => {
23
- const fileSeparator = exports . getFileSeparatorData ( ) ;
24
- if ( filePath == null || filePath == '' || filePath == fileSeparator ) {
25
- return null ;
26
- }
27
- try {
28
- fs . statSync ( filePath + fileSeparator + '.git' + fileSeparator + 'config' ) ;
29
- return filePath ;
30
- } catch ( e ) {
31
- let parentFilePath = filePath . split ( fileSeparator ) ;
32
- parentFilePath . pop ( ) ;
33
- return exports . findGitConfig ( parentFilePath . join ( fileSeparator ) ) ;
34
- }
35
- }
36
-
37
- const getGitMetaData = ( ) => {
38
- return new Promise ( async ( resolve , reject ) => {
39
- try {
40
- var info = getRepoInfo ( ) ;
41
- if ( ! info . commonGitDir ) {
42
- logger . debug ( `Unable to find a Git directory` ) ;
43
- resolve ( { } ) ;
44
- }
45
- if ( ! info . author && exports . findGitConfig ( process . cwd ( ) ) ) {
46
- /* commit objects are packed */
47
- gitLastCommit . getLastCommit ( async ( err , commit ) => {
48
- if ( err ) {
49
- logger . debug ( `Exception in populating Git Metadata with error : ${ err } ` , true , err ) ;
50
- return resolve ( { } ) ;
51
- }
52
- try {
53
- info [ "author" ] = info [ "author" ] || `${ commit [ "author" ] [ "name" ] . replace ( / [ “ ] + / g, '' ) } <${ commit [ "author" ] [ "email" ] . replace ( / [ “ ] + / g, '' ) } >` ;
54
- info [ "authorDate" ] = info [ "authorDate" ] || commit [ "authoredOn" ] ;
55
- info [ "committer" ] = info [ "committer" ] || `${ commit [ "committer" ] [ "name" ] . replace ( / [ “ ] + / g, '' ) } <${ commit [ "committer" ] [ "email" ] . replace ( / [ “ ] + / g, '' ) } >` ;
56
- info [ "committerDate" ] = info [ "committerDate" ] || commit [ "committedOn" ] ;
57
- info [ "commitMessage" ] = info [ "commitMessage" ] || commit [ "subject" ] ;
58
-
59
- const { remote } = await pGitconfig ( info . commonGitDir ) ;
60
- const remotes = Object . keys ( remote ) . map ( remoteName => ( { name : remoteName , url : remote [ remoteName ] [ 'url' ] } ) ) ;
61
- resolve ( {
62
- "name" : "git" ,
63
- "sha" : info [ "sha" ] ,
64
- "short_sha" : info [ "abbreviatedSha" ] ,
65
- "branch" : info [ "branch" ] ,
66
- "tag" : info [ "tag" ] ,
67
- "committer" : info [ "committer" ] ,
68
- "committer_date" : info [ "committerDate" ] ,
69
- "author" : info [ "author" ] ,
70
- "author_date" : info [ "authorDate" ] ,
71
- "commit_message" : info [ "commitMessage" ] ,
72
- "root" : info [ "root" ] ,
73
- "common_git_dir" : info [ "commonGitDir" ] ,
74
- "worktree_git_dir" : info [ "worktreeGitDir" ] ,
75
- "last_tag" : info [ "lastTag" ] ,
76
- "commits_since_last_tag" : info [ "commitsSinceLastTag" ] ,
77
- "remotes" : remotes
78
- } ) ;
79
- } catch ( e ) {
80
- logger . debug ( `Exception in populating Git Metadata with error : ${ e } ` , true , e ) ;
81
- return resolve ( { } ) ;
82
- }
83
- } , { dst : exports . findGitConfig ( process . cwd ( ) ) } ) ;
84
- } else {
85
- const { remote } = await pGitconfig ( info . commonGitDir ) ;
86
- const remotes = Object . keys ( remote ) . map ( remoteName => ( { name : remoteName , url : remote [ remoteName ] [ 'url' ] } ) ) ;
87
- resolve ( {
88
- "name" : "git" ,
89
- "sha" : info [ "sha" ] ,
90
- "short_sha" : info [ "abbreviatedSha" ] ,
91
- "branch" : info [ "branch" ] ,
92
- "tag" : info [ "tag" ] ,
93
- "committer" : info [ "committer" ] ,
94
- "committer_date" : info [ "committerDate" ] ,
95
- "author" : info [ "author" ] ,
96
- "author_date" : info [ "authorDate" ] ,
97
- "commit_message" : info [ "commitMessage" ] ,
98
- "root" : info [ "root" ] ,
99
- "common_git_dir" : info [ "commonGitDir" ] ,
100
- "worktree_git_dir" : info [ "worktreeGitDir" ] ,
101
- "last_tag" : info [ "lastTag" ] ,
102
- "commits_since_last_tag" : info [ "commitsSinceLastTag" ] ,
103
- "remotes" : remotes
104
- } ) ;
105
- }
106
- } catch ( err ) {
107
- logger . debug ( `Exception in populating Git metadata with error : ${ err } ` , true , err ) ;
108
- resolve ( { } ) ;
109
- }
110
- } )
111
- }
112
-
113
- const getCiInfo = ( ) => {
114
- var env = process . env ;
115
- // Jenkins
116
- if ( ( typeof env . JENKINS_URL === "string" && env . JENKINS_URL . length > 0 ) || ( typeof env . JENKINS_HOME === "string" && env . JENKINS_HOME . length > 0 ) ) {
117
- return {
118
- name : "Jenkins" ,
119
- build_url : env . BUILD_URL ,
120
- job_name : env . JOB_NAME ,
121
- build_number : env . BUILD_NUMBER
122
- }
123
- }
124
- // CircleCI
125
- if ( env . CI === "true" && env . CIRCLECI === "true" ) {
126
- return {
127
- name : "CircleCI" ,
128
- build_url : env . CIRCLE_BUILD_URL ,
129
- job_name : env . CIRCLE_JOB ,
130
- build_number : env . CIRCLE_BUILD_NUM
131
- }
132
- }
133
- // Travis CI
134
- if ( env . CI === "true" && env . TRAVIS === "true" ) {
135
- return {
136
- name : "Travis CI" ,
137
- build_url : env . TRAVIS_BUILD_WEB_URL ,
138
- job_name : env . TRAVIS_JOB_NAME ,
139
- build_number : env . TRAVIS_BUILD_NUMBER
140
- }
141
- }
142
- // Codeship
143
- if ( env . CI === "true" && env . CI_NAME === "codeship" ) {
144
- return {
145
- name : "Codeship" ,
146
- build_url : null ,
147
- job_name : null ,
148
- build_number : null
149
- }
150
- }
151
- // Bitbucket
152
- if ( env . BITBUCKET_BRANCH && env . BITBUCKET_COMMIT ) {
153
- return {
154
- name : "Bitbucket" ,
155
- build_url : env . BITBUCKET_GIT_HTTP_ORIGIN ,
156
- job_name : null ,
157
- build_number : env . BITBUCKET_BUILD_NUMBER
158
- }
159
- }
160
- // Drone
161
- if ( env . CI === "true" && env . DRONE === "true" ) {
162
- return {
163
- name : "Drone" ,
164
- build_url : env . DRONE_BUILD_LINK ,
165
- job_name : null ,
166
- build_number : env . DRONE_BUILD_NUMBER
167
- }
168
- }
169
- // Semaphore
170
- if ( env . CI === "true" && env . SEMAPHORE === "true" ) {
171
- return {
172
- name : "Semaphore" ,
173
- build_url : env . SEMAPHORE_ORGANIZATION_URL ,
174
- job_name : env . SEMAPHORE_JOB_NAME ,
175
- build_number : env . SEMAPHORE_JOB_ID
176
- }
177
- }
178
- // GitLab
179
- if ( env . CI === "true" && env . GITLAB_CI === "true" ) {
180
- return {
181
- name : "GitLab" ,
182
- build_url : env . CI_JOB_URL ,
183
- job_name : env . CI_JOB_NAME ,
184
- build_number : env . CI_JOB_ID
185
- }
186
- }
187
- // Buildkite
188
- if ( env . CI === "true" && env . BUILDKITE === "true" ) {
189
- return {
190
- name : "Buildkite" ,
191
- build_url : env . BUILDKITE_BUILD_URL ,
192
- job_name : env . BUILDKITE_LABEL || env . BUILDKITE_PIPELINE_NAME ,
193
- build_number : env . BUILDKITE_BUILD_NUMBER
194
- }
195
- }
196
- // Visual Studio Team Services
197
- if ( env . TF_BUILD === "True" ) {
198
- return {
199
- name : "Visual Studio Team Services" ,
200
- build_url : `${ env . SYSTEM_TEAMFOUNDATIONSERVERURI } ${ env . SYSTEM_TEAMPROJECTID } ` ,
201
- job_name : env . SYSTEM_DEFINITIONID ,
202
- build_number : env . BUILD_BUILDID
203
- }
204
- }
205
- // if no matches, return null
206
- return null ;
207
- }
9
+ const helper = require ( '../helpers/helper' ) ;
208
10
209
11
exports . checkAccessibilityPlatform = ( user_config ) => {
210
- logger . info ( "checkAccessibilityPlatform start" ) ;
211
12
let accessibility = false ;
212
- // console.log("user_config.browsers", user_config.browsers)
213
13
user_config . browsers . forEach ( browser => {
214
- console . log ( "browser" , browser )
215
14
if ( browser . accessibility ) {
216
- console . log ( "inside browser.accessibility" )
217
15
accessibility = true ;
218
16
return true ;
219
17
}
@@ -254,21 +52,21 @@ exports.createAccessibilityTestRun = async (user_config, framework) => {
254
52
'startTime' : ( new Date ( ) ) . toISOString ( ) ,
255
53
'description' : buildDescription ,
256
54
'source' : {
257
- frameworkName : "framework " ,
258
- frameworkVersion : "frameworkVersion" ,
259
- sdkVersion : "sdkVersion"
55
+ frameworkName : "Cypress " ,
56
+ frameworkVersion : helper . getPackageVersion ( 'cypress' , user_config ) ,
57
+ sdkVersion : helper . getAgentVersion ( )
260
58
} ,
261
59
'settings' : settings ,
262
- 'versionControl' : await getGitMetaData ( ) ,
263
- 'ciInfo' : getCiInfo ( ) ,
60
+ 'versionControl' : await helper . getGitMetaData ( ) ,
61
+ 'ciInfo' : helper . getCiInfo ( ) ,
264
62
'hostInfo' : {
265
63
hostname : os . hostname ( ) ,
266
64
platform : os . platform ( ) ,
267
65
type : os . type ( ) ,
268
66
version : os . version ( ) ,
269
67
arch : os . arch ( )
270
68
} ,
271
- 'browserstackAutomation' : true // fix!!
69
+ 'browserstackAutomation' : process . env . BROWSERSTACK_AUTOMATION
272
70
} ;
273
71
274
72
const config = {
@@ -285,7 +83,7 @@ exports.createAccessibilityTestRun = async (user_config, framework) => {
285
83
'POST' , 'test_runs' , data , config
286
84
) ;
287
85
logger . info ( "response in createAccessibilityTestRun" , response ) ;
288
-
86
+ process . env . BROWSERSTACK_TEST_ACCESSIBILITY = 'true' ;
289
87
process . env . BS_A11Y_JWT = response . data . data . accessibilityToken ;
290
88
process . env . BS_A11Y_TEST_RUN_ID = response . data . data . id ;
291
89
0 commit comments