Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: actions/runner
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: runs-on/runner
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 7 commits
  • 9 files changed
  • 1 contributor

Commits on Feb 8, 2025

  1. Copy the full SHA
    297fd36 View commit details
  2. Amend CI workflows

    crohr committed Feb 8, 2025
    Copy the full SHA
    1605ca8 View commit details
  3. Copy the full SHA
    4aa0126 View commit details
  4. Use root dir

    crohr committed Feb 8, 2025
    Copy the full SHA
    6e53ebd View commit details
  5. fix

    crohr committed Feb 8, 2025
    Copy the full SHA
    87e9faf View commit details
  6. fix

    crohr committed Feb 8, 2025
    Copy the full SHA
    d3a271c View commit details
  7. Merge pull request #2 from runs-on/feature/detect-and-warn-interruption

    Detect and warn interruption
    crohr authored Feb 8, 2025
    Copy the full SHA
    6a8be3e View commit details
22 changes: 3 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ jobs:
build:
strategy:
matrix:
runtime: [ linux-x64, linux-arm64, linux-arm, win-x64, win-arm64, osx-x64, osx-arm64 ]
runtime: [ linux-x64, linux-arm64, win-x64 ]
include:
- runtime: linux-x64
os: ubuntu-latest
@@ -28,26 +28,10 @@ jobs:
os: ubuntu-latest
devScript: ./dev.sh

- runtime: linux-arm
os: ubuntu-latest
devScript: ./dev.sh

- runtime: osx-x64
os: macOS-latest
devScript: ./dev.sh

- runtime: osx-arm64
os: macOS-latest
devScript: ./dev.sh

- runtime: win-x64
os: windows-2019
devScript: ./dev

- runtime: win-arm64
os: windows-latest
devScript: ./dev

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
@@ -67,14 +51,14 @@ jobs:

# Create runner package tar.gz/zip
- name: Package Release
if: github.event_name != 'pull_request'
# if: github.event_name != 'pull_request'
run: |
${{ matrix.devScript }} package Release ${{ matrix.runtime }}
working-directory: src

# Upload runner package tar.gz/zip as artifact
- name: Publish Artifact
if: github.event_name != 'pull_request'
# if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v4
with:
name: runner-package-${{ matrix.runtime }}
2 changes: 0 additions & 2 deletions .github/workflows/close-bugs-bot.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Close Bugs Bot
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # every day at midnight
jobs:
stale:
runs-on: ubuntu-latest
2 changes: 0 additions & 2 deletions .github/workflows/close-features-bot.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Close Features Bot
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # every day at midnight
jobs:
stale:
runs-on: ubuntu-latest
3 changes: 0 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -7,9 +7,6 @@ on:
push:
branches:
- main
pull_request:
schedule:
- cron: '0 0 * * 0'

jobs:
CodeQL-Build:
2 changes: 0 additions & 2 deletions .github/workflows/dotnet-upgrade.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: "DotNet SDK Upgrade"

on:
schedule:
- cron: '0 0 * * 1'
workflow_dispatch:

jobs:
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ jobs:
osx-arm64-sha: ${{ steps.sha.outputs.osx-arm64-sha256 }}
strategy:
matrix:
runtime: [ linux-x64, linux-arm64, linux-arm, win-x64, osx-x64, osx-arm64, win-arm64 ]
runtime: [ linux-x64, linux-arm64, win-x64 ]
include:
- runtime: linux-x64
os: ubuntu-latest
2 changes: 0 additions & 2 deletions .github/workflows/stale-bot.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
name: Stale Bot
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 1' # every monday at midnight
jobs:
stale:
runs-on: ubuntu-latest
1 change: 1 addition & 0 deletions src/Runner.Common/HostContext.cs
Original file line number Diff line number Diff line change
@@ -711,5 +711,6 @@ public enum ShutdownReason
{
UserCancelled = 0,
OperatingSystemShutdown = 1,
InfrastructureInterrupted = 2,
}
}
38 changes: 38 additions & 0 deletions src/Runner.Worker/JobRunner.cs
Original file line number Diff line number Diff line change
@@ -31,6 +31,8 @@ public sealed class JobRunner : RunnerService, IJobRunner
private IJobServerQueue _jobServerQueue;
private RunnerSettings _runnerSettings;
private ITempDirectoryManager _tempDirectoryManager;
private readonly CancellationTokenSource _interruptedHookTokenSource = new();
private Task _interruptedHookTask;

public async Task<TaskResult> RunAsync(AgentJobRequestMessage message, CancellationToken jobRequestCancellationToken)
{
@@ -131,6 +133,9 @@ public async Task<TaskResult> RunAsync(AgentJobRequestMessage message, Cancellat
case ShutdownReason.OperatingSystemShutdown:
errorMessage = $"Operating system is shutting down for computer '{Environment.MachineName}'";
break;
case ShutdownReason.InfrastructureInterrupted:
errorMessage = "This job was interrupted by the runner infrastructure. Results may be incomplete.";
break;
default:
throw new ArgumentException(HostContext.RunnerShutdownReason.ToString(), nameof(HostContext.RunnerShutdownReason));
}
@@ -216,6 +221,33 @@ public async Task<TaskResult> RunAsync(AgentJobRequestMessage message, Cancellat
await Task.WhenAny(_jobServerQueue.JobRecordUpdated.Task, Task.Delay(1000));
}

// Start monitoring for interrupted hook file
_interruptedHookTask = Task.Run(async () =>
{
string interruptedHookPath = Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Root), "runs-on-interrupted");
while (!_interruptedHookTokenSource.Token.IsCancellationRequested)
{
try
{
if (File.Exists(interruptedHookPath))
{
HostContext.ShutdownRunner(ShutdownReason.InfrastructureInterrupted);
break;
}

await Task.Delay(TimeSpan.FromSeconds(1), _interruptedHookTokenSource.Token);
}
catch (OperationCanceledException) when (_interruptedHookTokenSource.Token.IsCancellationRequested)
{
break;
}
catch (Exception ex)
{
Trace.Error($"Error checking interrupted hook file: {ex}");
}
}
}, _interruptedHookTokenSource.Token);

// Run all job steps
Trace.Info("Run all job steps.");
var stepsRunner = HostContext.GetService<IStepsRunner>();
@@ -256,6 +288,12 @@ public async Task<TaskResult> RunAsync(AgentJobRequestMessage message, Cancellat
runnerShutdownRegistration = null;
}

if (_interruptedHookTask != null)
{
_interruptedHookTokenSource.Cancel();
await _interruptedHookTask;
}

await ShutdownQueue(throwOnFailure: false);
}
}