@@ -35,9 +35,10 @@ export class DockerImageReconciler {
3535
3636 constructor ( gitHubClient : Octokit , repoVersionInfo : RepoVersionInfo ) {
3737 this . gitHubClient = gitHubClient ;
38- this . repoVersionFull = `${ repoVersionInfo . major } .${ repoVersionInfo . minor } .${ repoVersionInfo . patch } ` ;
39- this . repoVersionMinor = `${ repoVersionInfo . major } .${ repoVersionInfo . minor } ` ;
40- this . repoVersionMajor = String ( repoVersionInfo . major ) ;
38+ const { major, minor, patch } = repoVersionInfo ;
39+ this . repoVersionFull = `${ major } .${ minor } .${ patch } ` ;
40+ this . repoVersionMinor = `${ major } .${ minor } ` ;
41+ this . repoVersionMajor = String ( major ) ;
4142 }
4243
4344 private async isDockerImageMissing ( repository : string , tag : string ) : Promise < boolean > {
@@ -58,24 +59,44 @@ export class DockerImageReconciler {
5859 if ( versions . length === 0 ) return ;
5960 const versionsToCheck = versions . slice ( 0 , RECENT_VERSIONS_TO_CHECK ) ;
6061 for ( const version of versionsToCheck ) {
61- if ( this . imagesChecked >= MAX_IMAGES_PER_CYCLE ) break ;
62+ if ( this . imagesChecked >= MAX_IMAGES_PER_CYCLE ) {
63+ break ;
64+ }
6265 await this . checkVersionImages ( version ) ;
6366 }
6467 await this . reportResults ( ) ;
6568 }
6669
6770 private async checkVersionImages ( version : EditorVersionInfo ) : Promise < void > {
6871 const { version : editorVersion , changeSet : changeset } = version ;
69- for ( const { repo, tag, os } of [
70- { repo : 'base' , tag : `ubuntu-${ this . repoVersionFull } ` , os : 'ubuntu' } ,
71- { repo : 'base' , tag : `windows-${ this . repoVersionFull } ` , os : 'windows' } ,
72- { repo : 'hub' , tag : `ubuntu-${ this . repoVersionFull } ` , os : 'ubuntu' } ,
73- { repo : 'hub' , tag : `windows-${ this . repoVersionFull } ` , os : 'windows' } ,
74- ] ) {
75- const image : DockerImage = { repository : `unityci/${ repo } ` , tag, baseOs : os , imageType : repo as any } ;
72+
73+ const baseImages = [
74+ { repo : 'base' as const , tag : `ubuntu-${ this . repoVersionFull } ` , os : 'ubuntu' as const } ,
75+ { repo : 'base' as const , tag : `windows-${ this . repoVersionFull } ` , os : 'windows' as const } ,
76+ { repo : 'hub' as const , tag : `ubuntu-${ this . repoVersionFull } ` , os : 'ubuntu' as const } ,
77+ { repo : 'hub' as const , tag : `windows-${ this . repoVersionFull } ` , os : 'windows' as const } ,
78+ ] ;
79+
80+ for ( const { repo, tag, os } of baseImages ) {
81+ const image : DockerImage = {
82+ repository : `unityci/${ repo } ` ,
83+ tag,
84+ baseOs : os ,
85+ imageType : repo ,
86+ } ;
7687 await this . checkImage ( image ) ;
7788 }
78- for ( const platform of [ 'base' , 'linux-il2cpp' , 'windows-mono' , 'mac-mono' , 'ios' , 'android' , 'webgl' ] ) {
89+
90+ const ubuntuPlatforms = [
91+ 'base' ,
92+ 'linux-il2cpp' ,
93+ 'windows-mono' ,
94+ 'mac-mono' ,
95+ 'ios' ,
96+ 'android' ,
97+ 'webgl' ,
98+ ] as const ;
99+ for ( const platform of ubuntuPlatforms ) {
79100 if ( this . imagesChecked >= MAX_IMAGES_PER_CYCLE ) break ;
80101 await this . checkImage ( {
81102 repository : 'unityci/editor' ,
@@ -87,7 +108,15 @@ export class DockerImageReconciler {
87108 changeset,
88109 } ) ;
89110 }
90- for ( const platform of [ 'base' , 'windows-il2cpp' , 'universal-windows-platform' , 'appletv' , 'android' ] ) {
111+
112+ const windowsPlatforms = [
113+ 'base' ,
114+ 'windows-il2cpp' ,
115+ 'universal-windows-platform' ,
116+ 'appletv' ,
117+ 'android' ,
118+ ] as const ;
119+ for ( const platform of windowsPlatforms ) {
91120 if ( this . imagesChecked >= MAX_IMAGES_PER_CYCLE ) break ;
92121 await this . checkImage ( {
93122 repository : 'unityci/editor' ,
@@ -113,14 +142,18 @@ export class DockerImageReconciler {
113142 const dispatchedRetry = await this . dispatchRetry ( image ) ;
114143 this . missingImages . push ( { image, dispatchedRetry } ) ;
115144 } catch ( error ) {
116- this . missingImages . push ( { image, dispatchedRetry : false , error : String ( error ) } ) ;
145+ this . missingImages . push ( {
146+ image,
147+ dispatchedRetry : false ,
148+ error : String ( error ) ,
149+ } ) ;
117150 }
118151 }
119152
120153 private async dispatchRetry ( image : DockerImage ) : Promise < boolean > {
121154 try {
122155 const eventType = this . getEventType ( image ) ;
123- const payload : any = {
156+ const payload : Record < string , any > = {
124157 jobId : `reconciliation-${ Date . now ( ) } -${ image . imageType } -${ image . tag } ` ,
125158 repoVersionFull : this . repoVersionFull ,
126159 repoVersionMinor : this . repoVersionMinor ,
@@ -140,7 +173,7 @@ export class DockerImageReconciler {
140173
141174 return response . status >= 200 && response . status < 300 ;
142175 } catch ( error ) {
143- logger . error ( ` Error dispatching` , error ) ;
176+ logger . error ( ' Error dispatching' , error ) ;
144177 return false ;
145178 }
146179 }
@@ -163,10 +196,16 @@ export class DockerImageReconciler {
163196
164197 private async reportResults ( ) : Promise < void > {
165198 if ( this . missingImages . length === 0 ) {
166- await Discord . sendDebug ( `Checked ${ this . imagesChecked } images - OK` ) ;
199+ await Discord . sendDebug ( `[DockerImageReconciler] Checked ${ this . imagesChecked } images OK` ) ;
167200 return ;
168201 }
202+
169203 const successful = this . missingImages . filter ( ( m ) => m . dispatchedRetry ) . length ;
170- await Discord . sendAlert ( `DockerHub Reconciliation: Found ${ this . missingImages . length } missing, retried ${ successful } ` ) ;
204+ const failedCount = this . missingImages . length - successful ;
205+
206+ await Discord . sendAlert (
207+ `DockerHub Reconciliation: Found ${ this . missingImages . length } missing, ` +
208+ `retried ${ successful } , failed ${ failedCount } ` ,
209+ ) ;
171210 }
172- }
211+ }
0 commit comments