@@ -182,14 +182,36 @@ private async Task DownloadLatestRunner(CancellationToken token)
182
182
183
183
try
184
184
{
185
- archiveFile = await DownLoadRunner ( latestRunnerDirectory , packageDownloadUrl , packageHashValue , token ) ;
186
-
187
- if ( string . IsNullOrEmpty ( archiveFile ) )
185
+ #if DEBUG
186
+ // Much of the update process (targetVersion, archive) is server-side, this is a way to control it from here for testing specific update scenarios
187
+ // Add files like 'runner_v2.281.2.tar.gz' or 'runner_v2.283.0.zip' depending on your platform in your runner root folder
188
+ var isMockUpdate = StringUtil . ConvertToBoolean ( Environment . GetEnvironmentVariable ( "GITHUB_ACTIONS_RUNNER_IS_MOCK_UPDATE" ) ) ;
189
+ if ( isMockUpdate )
188
190
{
189
- throw new TaskCanceledException ( $ "Runner package '{ packageDownloadUrl } ' failed after { Constants . RunnerDownloadRetryMaxAttempts } download attempts") ;
191
+ // the env var should be of format 'v2.281.2,v2.283.0,v2.283.1,v2.284.0'
192
+ var mockVersions = Environment . GetEnvironmentVariable ( "GITHUB_ACTIONS_RUNNER_MOCK_VERSION_LIST" ) . Split ( ',' ) ;
193
+ if ( mockVersions . Any ( ) )
194
+ {
195
+ var targetVersion = mockVersions . First ( ) ;
196
+ archiveFile = "runner_" + targetVersion ;
197
+ var newMockVersions = string . Join ( "," , mockVersions . Skip ( 1 ) ) ;
198
+ Environment . SetEnvironmentVariable ( "GITHUB_ACTIONS_RUNNER_MOCK_VERSION_LIST" , newMockVersions ) ;
199
+ _updateTrace . Add ( $ "Mocking update with file: { archiveFile } , nothing is downloaded") ;
200
+ }
190
201
}
202
+ #else
203
+ // archiveFile is not null only if we mocked it above
204
+ if ( archiveFile == null )
205
+ {
206
+ archiveFile = await DownLoadRunner ( latestRunnerDirectory , packageDownloadUrl , packageHashValue , token ) ;
191
207
192
- await ValidateRunnerHash ( archiveFile , packageHashValue ) ;
208
+ if ( string . IsNullOrEmpty ( archiveFile ) )
209
+ {
210
+ throw new TaskCanceledException ( $ "Runner package '{ packageDownloadUrl } ' failed after { Constants . RunnerDownloadRetryMaxAttempts } download attempts") ;
211
+ }
212
+ await ValidateRunnerHash ( archiveFile , packageHashValue ) ;
213
+ }
214
+ #endif
193
215
194
216
await ExtractRunnerPackage ( archiveFile , latestRunnerDirectory , token ) ;
195
217
}
0 commit comments