@@ -188,35 +188,47 @@ private async Task DownloadLatestRunner(CancellationToken token)
188
188
// This should not be in the release build to prevent tampering with updates
189
189
var isMockUpdate = StringUtil . ConvertToBoolean ( Environment . GetEnvironmentVariable ( "GITHUB_ACTIONS_RUNNER_IS_MOCK_UPDATE" ) ) ;
190
190
if ( isMockUpdate )
191
- { int waitInSeconds = 20 ;
191
+ {
192
+ int waitInSeconds = 20 ;
192
193
while ( ! Debugger . IsAttached && waitInSeconds -- > 0 )
193
194
{
194
195
await Task . Delay ( 1000 ) ;
195
196
}
196
197
Debugger . Break ( ) ;
197
- // the env var should be of format GITHUB_ACTIONS_RUNNER_MOCK_VERSION_LIST='v2.281.2,v2.283.0,v2.283.1,v2.284.0'
198
- var mockVersions = Environment . GetEnvironmentVariable ( "GITHUB_ACTIONS_RUNNER_MOCK_VERSION_LIST" ) . Split ( ',' ) ;
199
-
200
- _terminal . WriteLine ( string . Join ( "," , mockVersions ) ) ;
201
- if ( mockVersions . Any ( ) )
198
+ // the runner-mock-versions.txt file should be of format
199
+ // v2.281.2
200
+ // v2.283.0
201
+ // v2.283.1
202
+ // v2.284.0
203
+ var mockVersionsPath = Path . Combine ( HostContext . GetDirectory ( WellKnownDirectory . Root ) , "runner-mock-versions.txt" ) ;
204
+ if ( File . Exists ( mockVersionsPath ) )
202
205
{
203
- var targetVersion = mockVersions . First ( ) ;
206
+ var mockVersions = File . ReadAllLines ( Path . Combine ( HostContext . GetDirectory ( WellKnownDirectory . Root ) , "runner-mock-versions.txt" ) ) ;
204
207
205
- if ( _targetPackage . Platform . StartsWith ( "win" ) )
206
- {
207
- archiveFile = Path . Combine ( HostContext . GetDirectory ( WellKnownDirectory . Root ) , $ "runner{ targetVersion } .zip") ;
208
- }
209
- else
208
+ _terminal . WriteLine ( string . Join ( "," , mockVersions ) ) ;
209
+ if ( mockVersions . Any ( ) )
210
210
{
211
- archiveFile = Path . Combine ( HostContext . GetDirectory ( WellKnownDirectory . Root ) , $ "runner{ targetVersion } .tar.gz") ;
212
- }
211
+ var targetVersion = mockVersions . First ( ) ;
213
212
214
- _terminal . WriteLine ( $ "Mock target version is: { targetVersion } ") ;
213
+ if ( _targetPackage . Platform . StartsWith ( "win" ) )
214
+ {
215
+ archiveFile = Path . Combine ( HostContext . GetDirectory ( WellKnownDirectory . Root ) , $ "runner{ targetVersion } .zip") ;
216
+ }
217
+ else
218
+ {
219
+ archiveFile = Path . Combine ( HostContext . GetDirectory ( WellKnownDirectory . Root ) , $ "runner{ targetVersion } .tar.gz") ;
220
+ }
221
+
222
+ _terminal . WriteLine ( $ "Mock target version is: { targetVersion } ") ;
215
223
216
- var newMockVersions = string . Join ( "," , mockVersions . Skip ( 1 ) ) ;
217
- Environment . SetEnvironmentVariable ( "GITHUB_ACTIONS_RUNNER_MOCK_VERSION_LIST" , newMockVersions ) ;
218
- _updateTrace . Add ( $ "Mocking update with file: { archiveFile } , nothing is downloaded") ;
219
- _terminal . WriteLine ( $ "Mocking update with file: { archiveFile } , nothing is downloaded") ;
224
+ File . Delete ( mockVersionsPath ) ;
225
+ if ( mockVersions . Length > 1 )
226
+ {
227
+ File . WriteAllLines ( mockVersionsPath , mockVersions . Skip ( 1 ) ) ;
228
+ }
229
+ _updateTrace . Add ( $ "Mocking update with file: { archiveFile } , nothing is downloaded") ;
230
+ _terminal . WriteLine ( $ "Mocking update with file: { archiveFile } , nothing is downloaded") ;
231
+ }
220
232
}
221
233
}
222
234
// archiveFile is not null only if we mocked it above
0 commit comments