@@ -4,7 +4,6 @@ const simpleGit = require('simple-git/promise');
44const request = require ( 'request' ) ;
55
66class GitHubJobClass {
7-
87 // pass in a job payload to setup class
98 constructor ( currentJob ) {
109 this . currentJob = currentJob ;
@@ -39,6 +38,7 @@ class GitHubJobClass {
3938 returnObject [ 'content' ] = response ;
4039 }
4140 resolve ( returnObject ) ;
41+ reject ( error ) ;
4242 } ) ;
4343 } ) ;
4444 }
@@ -56,6 +56,7 @@ class GitHubJobClass {
5656 return new Promise ( function ( resolve , reject ) {
5757 logger . save ( `${ '(rm)' . padEnd ( 15 ) } Finished cleaning repo` ) ;
5858 resolve ( true ) ;
59+ reject ( false ) ;
5960 } ) ;
6061 }
6162
@@ -65,11 +66,18 @@ class GitHubJobClass {
6566 logger . save ( `${ '(GIT)' . padEnd ( 15 ) } running fetch` ) ;
6667 try {
6768 if ( ! currentJob . payload . branchName ) {
68- logger . save ( `${ '(CLONE)' . padEnd ( 15 ) } failed due to insufficient definition` ) ;
69+ logger . save (
70+ `${ '(CLONE)' . padEnd ( 15 ) } failed due to insufficient definition`
71+ ) ;
6972 throw new Error ( 'branch name not indicated' ) ;
7073 }
7174 const basePath = this . getBasePath ( ) ;
72- const repoPath = basePath + '/' + currentJob . payload . repoOwner + '/' + currentJob . payload . repoName ;
75+ const repoPath =
76+ basePath +
77+ '/' +
78+ currentJob . payload . repoOwner +
79+ '/' +
80+ currentJob . payload . repoName ;
7381 await simpleGit ( 'repos' )
7482 . silent ( false )
7583 . clone ( repoPath , `${ this . getRepoDirName ( currentJob ) } ` )
@@ -91,6 +99,7 @@ class GitHubJobClass {
9199 return new Promise ( function ( resolve , reject ) {
92100 logger . save ( `${ '(GIT)' . padEnd ( 15 ) } Finished git clone` ) ;
93101 resolve ( true ) ;
102+ reject ( false ) ;
94103 } ) ;
95104 }
96105
@@ -106,13 +115,10 @@ class GitHubJobClass {
106115
107116 try {
108117 const exec = workerUtils . getExecPromise ( ) ;
109- const basePath = this . getBasePath ( ) ;
110- const repoPath = basePath + '/' + currentJob . payload . repoOwner + '/' + currentJob . payload . repoName ;
111-
112118 const pullRepoCommands = [
113119 `cd repos/${ this . getRepoDirName ( currentJob ) } ` ,
114120 `git checkout ${ currentJob . payload . branchName } ` ,
115- `git pull origin ${ currentJob . payload . branchName } ` ,
121+ `git pull origin ${ currentJob . payload . branchName } `
116122 ] ;
117123
118124 await exec ( pullRepoCommands . join ( ' && ' ) ) ;
@@ -122,28 +128,37 @@ class GitHubJobClass {
122128 `. /venv/bin/activate` ,
123129 `cd repos/${ this . getRepoDirName ( currentJob ) } ` ,
124130 `rm -f makefile` ,
125- `make html` ,
131+ `make html`
126132 ] ;
127133
128134 const deployCommands = [
129135 `. /venv/bin/activate` ,
130136 `cd repos/${ this . getRepoDirName ( currentJob ) } ` ,
131- `make stage` ,
137+ `make stage`
132138 ] ;
133139
134140 // the way we now build is to search for a specific function string in worker.sh
135141 // which then maps to a specific target that we run
136- const workerContents = fs . readFileSync ( `repos/${ this . getRepoDirName ( currentJob ) } /worker.sh` , { encoding : 'utf8' } ) ;
142+ const workerContents = fs . readFileSync (
143+ `repos/${ this . getRepoDirName ( currentJob ) } /worker.sh` ,
144+ { encoding : 'utf8' }
145+ ) ;
137146 const workerLines = workerContents . split ( / \r ? \n / ) ;
138147
139148 // overwrite repo makefile with the one our team maintains
140149 const makefileContents = await this . downloadMakefile ( ) ;
141150 if ( makefileContents && makefileContents . status === 'success' ) {
142- await fs . writeFileSync ( `repos/${ this . getRepoDirName ( currentJob ) } /Makefile` , makefileContents . content , { encoding : 'utf8' , flag : 'w' } ) ;
151+ await fs . writeFileSync (
152+ `repos/${ this . getRepoDirName ( currentJob ) } /Makefile` ,
153+ makefileContents . content ,
154+ { encoding : 'utf8' , flag : 'w' }
155+ ) ;
143156 } else {
144- console . log ( 'ERROR: makefile does not exist in /makefiles directory on meta branch.' ) ;
157+ console . log (
158+ 'ERROR: makefile does not exist in /makefiles directory on meta branch.'
159+ ) ;
145160 }
146-
161+
147162 // check if need to build next-gen instead
148163 for ( let i = 0 ; i < workerLines . length ; i ++ ) {
149164 if ( workerLines [ i ] === '"build-and-stage-next-gen"' ) {
@@ -162,11 +177,19 @@ class GitHubJobClass {
162177
163178 return new Promise ( function ( resolve , reject ) {
164179 logger . save ( `${ '(BUILD)' . padEnd ( 15 ) } Finished Build` ) ;
165- logger . save ( `${ '(BUILD)' . padEnd ( 15 ) } worker.sh run details:\n\n${ stdout } \n---\n${ stderr } ` ) ;
180+ logger . save (
181+ `${ '(BUILD)' . padEnd (
182+ 15
183+ ) } worker.sh run details:\n\n${ stdout } \n---\n${ stderr } `
184+ ) ;
166185 resolve ( {
167- 'status' : 'success' ,
168- 'stdout' : stdout ,
169- 'stderr' : stderr ,
186+ status : 'success' ,
187+ stdout : stdout ,
188+ stderr : stderr
189+ } ) ;
190+ reject ( {
191+ status : 'success' ,
192+ stderr : stderr
170193 } ) ;
171194 } ) ;
172195 } catch ( errResult ) {
@@ -175,15 +198,16 @@ class GitHubJobClass {
175198 errResult . hasOwnProperty ( 'signal' ) ||
176199 errResult . hasOwnProperty ( 'killed' )
177200 ) {
178- logger . save ( `${ '(BUILD)' . padEnd ( 15 ) } failed with code: ${ errResult . code } ` ) ;
201+ logger . save (
202+ `${ '(BUILD)' . padEnd ( 15 ) } failed with code: ${ errResult . code } `
203+ ) ;
179204 logger . save ( `${ '(BUILD)' . padEnd ( 15 ) } stdErr: ${ errResult . stderr } ` ) ;
180205 throw errResult ;
181206 }
182207 }
183208 }
184-
185209}
186210
187211module . exports = {
188212 GitHubJobClass : GitHubJobClass
189- } ;
213+ } ;
0 commit comments