Skip to content

Commit d938bdf

Browse files
committed
Add debugger and logging to self update
1 parent c353760 commit d938bdf

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Runner.Listener/SelfUpdater.cs

+8-3
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,21 @@ private async Task DownloadLatestRunner(CancellationToken token)
180180
var packageHashValue = _targetPackage.HashValue;
181181
_updateTrace.Add($"DownloadUrl: {packageDownloadUrl}");
182182

183+
#if DEBUG
183184
try
184185
{
185186
// Much of the update process (targetVersion, archive) is server-side, this is a way to control it from here for testing specific update scenarios
186187
// Add files like 'runner_v2.281.2.tar.gz' or 'runner_v2.283.0.zip' depending on your platform in your runner root folder
187188
// Note that runners still need to be behind the server's runner version in order to receive an 'AgentRefreshMessage' and trigger this update
188189
// This should not be in the release build to prevent tampering with updates
189190
var isMockUpdate = StringUtil.ConvertToBoolean(Environment.GetEnvironmentVariable("GITHUB_ACTIONS_RUNNER_IS_MOCK_UPDATE"));
190-
191-
_terminal.WriteLine(isMockUpdate.ToString());
192191
if (isMockUpdate)
193-
{
192+
{ int waitInSeconds = 20;
193+
while (!Debugger.IsAttached && waitInSeconds-- > 0)
194+
{
195+
await Task.Delay(1000);
196+
}
197+
Debugger.Break();
194198
// 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'
195199
var mockVersions = Environment.GetEnvironmentVariable("GITHUB_ACTIONS_RUNNER_MOCK_VERSION_LIST").Split(',');
196200

@@ -216,6 +220,7 @@ private async Task DownloadLatestRunner(CancellationToken token)
216220
_terminal.WriteLine($"Mocking update with file: {archiveFile}, nothing is downloaded");
217221
}
218222
}
223+
#endif
219224
// archiveFile is not null only if we mocked it above
220225
if (archiveFile == null)
221226
{

0 commit comments

Comments
 (0)