Compare commits

..

3 Commits

Author SHA1 Message Date
TingluoHuang
edfad1a198 c 2020-05-11 14:28:43 -04:00
TingluoHuang
10bce3549c windows 2020-05-11 14:23:15 -04:00
TingluoHuang
68b180a229 run codeql on all platforms. 2020-05-11 14:09:58 -04:00
20 changed files with 53 additions and 123 deletions

View File

@@ -9,11 +9,11 @@ jobs:
CodeQL-Build: CodeQL-Build:
strategy: strategy:
fail-fast: false matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
# CodeQL runs on ubuntu-latest, windows-latest, and macos-latest # CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
runs-on: ubuntu-latest runs-on: ${{ matrix.os }}
steps: steps:
- name: Checkout repository - name: Checkout repository
@@ -22,13 +22,17 @@ jobs:
# Initializes the CodeQL tools for scanning. # Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v1 uses: github/codeql-action/init@v1
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java
- name: Manual build - name: Manual build (Windows)
if: runner.os == 'windows'
run : | run : |
./dev.sh layout Release linux-x64 dev.cmd layout Release
working-directory: src
- name: Manual build (Non-Windows)
if: runner.os != 'windows'
run : |
./dev.sh layout Release
working-directory: src working-directory: src
- name: Perform CodeQL Analysis - name: Perform CodeQL Analysis

View File

@@ -1,20 +1,11 @@
## Features ## Features
- Sample scripts to automate scalable runners (#427) - Runner support for GHES Alpha (#381 #386 #390 #393 $401)
- Raise warning when action input does not match action.yml. (#429) - Allow secrets context in Container.env (#388)
- Add secret masker for trimming double quotes. (#440)
- Use the API_URL and munge action URLs for GHES (#437 #469)
- Help trace worker crash in Kusto. (#450)
- update checkout@v1 for GHES (#470)
## Bugs ## Bugs
- Print node version in debug instead of output. (#433) - Raise warning when volume mount root. (#413)
- Better error when runner removed from service. (#441) - Fix typo (#394)
- Add help info for '--labels' config option (#472)
- Sps/token migration fix, job.status/steps.outcome/steps.conclusion case match with GitHub check suites conclusion. (#462)
- Docker build using -f instead of implied default (#471)
## Misc ## Misc
- Make release notes code blocks copy-paste-able (#430) - N/A
- Fix spelling of RHEL and CentOS. (#436)
- Add CodeQL Analysis workflow (#459)
## Windows x64 ## Windows x64
We recommend configuring the runner in a root folder of the Windows drive (e.g. "C:\actions-runner"). This will help avoid issues related to service identity folder permissions and long file path restrictions on Windows. We recommend configuring the runner in a root folder of the Windows drive (e.g. "C:\actions-runner"). This will help avoid issues related to service identity folder permissions and long file path restrictions on Windows.

View File

@@ -1 +1 @@
<Update to ./src/runnerversion when creating release> 2.168.0

View File

@@ -81,7 +81,7 @@ fi
export RUNNER_TOKEN=$(curl -s -X POST ${base_api_url}/${orgs_or_repos}/${runner_scope}/actions/runners/registration-token -H "accept: application/vnd.github.everest-preview+json" -H "authorization: token ${RUNNER_CFG_PAT}" | jq -r '.token') export RUNNER_TOKEN=$(curl -s -X POST ${base_api_url}/${orgs_or_repos}/${runner_scope}/actions/runners/registration-token -H "accept: application/vnd.github.everest-preview+json" -H "authorization: token ${RUNNER_CFG_PAT}" | jq -r '.token')
if [ "null" == "$RUNNER_TOKEN" -o -z "$RUNNER_TOKEN" ]; then fatal "Failed to get a token"; fi if [ -z "$RUNNER_TOKEN" ]; then fatal "Failed to get a token"; fi
#--------------------------------------- #---------------------------------------
# Download latest released and extract # Download latest released and extract

View File

@@ -1,7 +1,6 @@
#!/bin/bash #!/bin/bash
SVC_NAME="{{SvcNameVar}}" SVC_NAME="{{SvcNameVar}}"
SVC_NAME=${SVC_NAME// /_}
SVC_DESCRIPTION="{{SvcDescription}}" SVC_DESCRIPTION="{{SvcDescription}}"
user_id=`id -u` user_id=`id -u`

View File

@@ -1,7 +1,6 @@
#!/bin/bash #!/bin/bash
SVC_NAME="{{SvcNameVar}}" SVC_NAME="{{SvcNameVar}}"
SVC_NAME=${SVC_NAME// /_}
SVC_DESCRIPTION="{{SvcDescription}}" SVC_DESCRIPTION="{{SvcDescription}}"
SVC_CMD=$1 SVC_CMD=$1

View File

@@ -92,11 +92,9 @@ namespace GitHub.Runner.Listener.Configuration
_term.WriteSection("Authentication"); _term.WriteSection("Authentication");
while (true) while (true)
{ {
// When testing against a dev deployment of Actions Service, set this environment variable // Get the URL
var useDevActionsServiceUrl = Environment.GetEnvironmentVariable("USE_DEV_ACTIONS_SERVICE_URL");
var inputUrl = command.GetUrl(); var inputUrl = command.GetUrl();
if (inputUrl.Contains("codedev.ms", StringComparison.OrdinalIgnoreCase) if (inputUrl.Contains("codedev.ms", StringComparison.OrdinalIgnoreCase))
|| useDevActionsServiceUrl != null)
{ {
runnerSettings.ServerUrl = inputUrl; runnerSettings.ServerUrl = inputUrl;
// Get the credentials // Get the credentials

View File

@@ -82,7 +82,7 @@ namespace GitHub.Runner.Plugins.Repository.v1_0
executionContext.Output($"Syncing repository: {repoFullName}"); executionContext.Output($"Syncing repository: {repoFullName}");
// Repository URL // Repository URL
var githubUrl = executionContext.GetGitHubContext("server_url"); var githubUrl = executionContext.GetGitHubContext("url");
var githubUri = new Uri(!string.IsNullOrEmpty(githubUrl) ? githubUrl : "https://github.com"); var githubUri = new Uri(!string.IsNullOrEmpty(githubUrl) ? githubUrl : "https://github.com");
var portInfo = githubUri.IsDefaultPort ? string.Empty : $":{githubUri.Port}"; var portInfo = githubUri.IsDefaultPort ? string.Empty : $":{githubUri.Port}";
Uri repositoryUrl = new Uri($"{githubUri.Scheme}://{githubUri.Host}{portInfo}/{repoFullName}"); Uri repositoryUrl = new Uri($"{githubUri.Scheme}://{githubUri.Host}{portInfo}/{repoFullName}");

View File

@@ -150,8 +150,7 @@ namespace GitHub.Runner.Worker
containerSetupSteps.Add(new JobExtensionRunner(runAsync: this.PullActionContainerAsync, containerSetupSteps.Add(new JobExtensionRunner(runAsync: this.PullActionContainerAsync,
condition: $"{PipelineTemplateConstants.Success}()", condition: $"{PipelineTemplateConstants.Success}()",
displayName: $"Pull {imageToPull.Key}", displayName: $"Pull {imageToPull.Key}",
data: new ContainerSetupInfo(imageToPull.Value, imageToPull.Key), data: new ContainerSetupInfo(imageToPull.Value, imageToPull.Key)));
repositoryRef: null));
} }
} }
@@ -164,8 +163,7 @@ namespace GitHub.Runner.Worker
containerSetupSteps.Add(new JobExtensionRunner(runAsync: this.BuildActionContainerAsync, containerSetupSteps.Add(new JobExtensionRunner(runAsync: this.BuildActionContainerAsync,
condition: $"{PipelineTemplateConstants.Success}()", condition: $"{PipelineTemplateConstants.Success}()",
displayName: $"Build {setupInfo.ActionRepository}", displayName: $"Build {setupInfo.ActionRepository}",
data: new ContainerSetupInfo(imageToBuild.Value, setupInfo.Dockerfile, setupInfo.WorkingDirectory), data: new ContainerSetupInfo(imageToBuild.Value, setupInfo.Dockerfile, setupInfo.WorkingDirectory)));
repositoryRef: setupInfo.RepositoryRef));
} }
} }
@@ -778,7 +776,6 @@ namespace GitHub.Runner.Worker
} }
var setupInfo = new ActionContainer(); var setupInfo = new ActionContainer();
setupInfo.RepositoryRef = repositoryReference;
string destDirectory = Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Actions), repositoryReference.Name.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar), repositoryReference.Ref); string destDirectory = Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Actions), repositoryReference.Name.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar), repositoryReference.Ref);
string actionEntryDirectory = destDirectory; string actionEntryDirectory = destDirectory;
string dockerFileRelativePath = repositoryReference.Name; string dockerFileRelativePath = repositoryReference.Name;
@@ -1025,6 +1022,5 @@ namespace GitHub.Runner.Worker
public string Dockerfile { get; set; } public string Dockerfile { get; set; }
public string WorkingDirectory { get; set; } public string WorkingDirectory { get; set; }
public string ActionRepository { get; set; } public string ActionRepository { get; set; }
public Pipelines.RepositoryPathReference RepositoryRef { get; set; }
} }
} }

View File

@@ -170,9 +170,6 @@ namespace GitHub.Runner.Worker
} }
} }
// Validate inputs only for actions with action.yml
if (Action.Reference.Type == Pipelines.ActionSourceType.Repository)
{
foreach (var input in userInputs) foreach (var input in userInputs)
{ {
if (!validInputs.Contains(input)) if (!validInputs.Contains(input))
@@ -180,7 +177,6 @@ namespace GitHub.Runner.Worker
ExecutionContext.Warning($"Unexpected input '{input}', valid inputs are ['{string.Join("', '", validInputs)}']"); ExecutionContext.Warning($"Unexpected input '{input}', valid inputs are ['{string.Join("', '", validInputs)}']");
} }
} }
}
// Load the action environment. // Load the action environment.
ExecutionContext.Debug("Loading env"); ExecutionContext.Debug("Loading env");

View File

@@ -46,8 +46,7 @@ namespace GitHub.Runner.Worker
var postJobStep = new JobExtensionRunner(runAsync: this.StopContainersAsync, var postJobStep = new JobExtensionRunner(runAsync: this.StopContainersAsync,
condition: $"{PipelineTemplateConstants.Always}()", condition: $"{PipelineTemplateConstants.Always}()",
displayName: "Stop containers", displayName: "Stop containers",
data: data, data: data);
repositoryRef: null);
executionContext.Debug($"Register post job cleanup for stopping/deleting containers."); executionContext.Debug($"Register post job cleanup for stopping/deleting containers.");
executionContext.RegisterPostJobStep(postJobStep); executionContext.RegisterPostJobStep(postJobStep);

View File

@@ -109,7 +109,6 @@ namespace GitHub.Runner.Worker
public sealed class ExecutionContext : RunnerService, IExecutionContext public sealed class ExecutionContext : RunnerService, IExecutionContext
{ {
private const int _maxIssueCount = 10; private const int _maxIssueCount = 10;
private const int _throttlingDelayReportThreshold = 10 * 1000; // Don't report throttling with less than 10 seconds delay
private readonly TimelineRecord _record = new TimelineRecord(); private readonly TimelineRecord _record = new TimelineRecord();
private readonly Dictionary<Guid, TimelineRecord> _detailRecords = new Dictionary<Guid, TimelineRecord>(); private readonly Dictionary<Guid, TimelineRecord> _detailRecords = new Dictionary<Guid, TimelineRecord>();
@@ -260,9 +259,7 @@ namespace GitHub.Runner.Worker
return; return;
} }
string refName = step.GetRefName(); step.ExecutionContext = Root.CreatePostChild(step.DisplayName, IntraActionState);
step.ExecutionContext = Root.CreatePostChild(step.DisplayName, refName, IntraActionState);
Root.PostJobSteps.Push(step); Root.PostJobSteps.Push(step);
} }
@@ -270,12 +267,6 @@ namespace GitHub.Runner.Worker
{ {
Trace.Entering(); Trace.Entering();
// TODO: Null out old, non-json refNames only if a FF is set.
if (refName != null && !refName.StartsWith("{"))
{
refName = null;
}
var child = new ExecutionContext(); var child = new ExecutionContext();
child.Initialize(HostContext); child.Initialize(HostContext);
child.ScopeName = scopeName; child.ScopeName = scopeName;
@@ -344,7 +335,7 @@ namespace GitHub.Runner.Worker
} }
// report total delay caused by server throttling. // report total delay caused by server throttling.
if (_totalThrottlingDelayInMilliseconds > _throttlingDelayReportThreshold) if (_totalThrottlingDelayInMilliseconds > 0)
{ {
this.Warning($"The job has experienced {TimeSpan.FromMilliseconds(_totalThrottlingDelayInMilliseconds).TotalSeconds} seconds total delay caused by server throttling."); this.Warning($"The job has experienced {TimeSpan.FromMilliseconds(_totalThrottlingDelayInMilliseconds).TotalSeconds} seconds total delay caused by server throttling.");
} }
@@ -860,8 +851,7 @@ namespace GitHub.Runner.Worker
{ {
Interlocked.Add(ref _totalThrottlingDelayInMilliseconds, Convert.ToInt64(data.Delay.TotalMilliseconds)); Interlocked.Add(ref _totalThrottlingDelayInMilliseconds, Convert.ToInt64(data.Delay.TotalMilliseconds));
if (!_throttlingReported && if (!_throttlingReported)
_totalThrottlingDelayInMilliseconds > _throttlingDelayReportThreshold)
{ {
this.Warning(string.Format("The job is currently being throttled by the server. You may experience delays in console line output, job status reporting, and action log uploads.")); this.Warning(string.Format("The job is currently being throttled by the server. You may experience delays in console line output, job status reporting, and action log uploads."));
@@ -869,7 +859,7 @@ namespace GitHub.Runner.Worker
} }
} }
private IExecutionContext CreatePostChild(string displayName, string refName, Dictionary<string, string> intraActionState) private IExecutionContext CreatePostChild(string displayName, Dictionary<string, string> intraActionState)
{ {
if (!_expandedForPostJob) if (!_expandedForPostJob)
{ {
@@ -879,9 +869,7 @@ namespace GitHub.Runner.Worker
} }
var newGuid = Guid.NewGuid(); var newGuid = Guid.NewGuid();
return CreateChild(newGuid, displayName, newGuid.ToString("N"), null, null, intraActionState, _childTimelineRecordOrder - Root.PostJobSteps.Count);
// TODO: Check feature flag here, conditionally set refName to newGuid.ToString("N").
return CreateChild(newGuid, displayName, refName, null, null, intraActionState, _childTimelineRecordOrder - Root.PostJobSteps.Count);
} }
} }

View File

@@ -22,8 +22,8 @@ namespace GitHub.Runner.Worker
"repository_owner", "repository_owner",
"run_id", "run_id",
"run_number", "run_number",
"server_url",
"sha", "sha",
"url",
"workflow", "workflow",
"workspace", "workspace",
}; };

View File

@@ -1,31 +0,0 @@
using Newtonsoft.Json;
namespace GitHub.Runner.Worker
{
public static class IStepExtensions
{
public static string GetRefName(this IStep step, string defaultRefName = null)
{
// TODO: Really check a feature flag.
if (s_featureFlagEnabled)
{
if (step is JobExtensionRunner extensionRunner && extensionRunner.RepositoryRef != null)
{
return JsonConvert.SerializeObject(extensionRunner.RepositoryRef);
}
if (step is IActionRunner actionRunner && actionRunner.Action?.Reference != null)
{
return JsonConvert.SerializeObject(actionRunner.Action.Reference);
}
// RefName should always be valid json or null.
return null;
}
return defaultRefName;
}
private static bool s_featureFlagEnabled = true;
}
}

View File

@@ -131,13 +131,12 @@ namespace GitHub.Runner.Worker
// Temporary hack for GHES alpha // Temporary hack for GHES alpha
var configurationStore = HostContext.GetService<IConfigurationStore>(); var configurationStore = HostContext.GetService<IConfigurationStore>();
var runnerSettings = configurationStore.GetSettings(); var runnerSettings = configurationStore.GetSettings();
if (string.IsNullOrEmpty(context.GetGitHubContext("server_url")) && !runnerSettings.IsHostedServer && !string.IsNullOrEmpty(runnerSettings.GitHubUrl)) if (string.IsNullOrEmpty(context.GetGitHubContext("url")) && !runnerSettings.IsHostedServer && !string.IsNullOrEmpty(runnerSettings.GitHubUrl))
{ {
var url = new Uri(runnerSettings.GitHubUrl); var url = new Uri(runnerSettings.GitHubUrl);
var portInfo = url.IsDefaultPort ? string.Empty : $":{url.Port.ToString(CultureInfo.InvariantCulture)}"; var portInfo = url.IsDefaultPort ? string.Empty : $":{url.Port.ToString(CultureInfo.InvariantCulture)}";
context.SetGitHubContext("server_url", $"{url.Scheme}://{url.Host}{portInfo}"); context.SetGitHubContext("url", $"{url.Scheme}://{url.Host}{portInfo}");
context.SetGitHubContext("api_url", $"{url.Scheme}://{url.Host}{portInfo}/api/v3"); context.SetGitHubContext("api_url", $"{url.Scheme}://{url.Host}{portInfo}/api/v3");
context.SetGitHubContext("graphql_url", $"{url.Scheme}://{url.Host}{portInfo}/api/graphql");
} }
// Evaluate the job-level environment variables // Evaluate the job-level environment variables
@@ -215,8 +214,7 @@ namespace GitHub.Runner.Worker
preJobSteps.Add(new JobExtensionRunner(runAsync: containerProvider.StartContainersAsync, preJobSteps.Add(new JobExtensionRunner(runAsync: containerProvider.StartContainersAsync,
condition: $"{PipelineTemplateConstants.Success}()", condition: $"{PipelineTemplateConstants.Success}()",
displayName: "Initialize containers", displayName: "Initialize containers",
data: (object)containers, data: (object)containers));
repositoryRef: null));
} }
// Add action steps // Add action steps
@@ -261,19 +259,18 @@ namespace GitHub.Runner.Worker
// Create execution context for pre-job steps // Create execution context for pre-job steps
foreach (var step in preJobSteps) foreach (var step in preJobSteps)
{ {
if (step is JobExtensionRunner extensionStep) if (step is JobExtensionRunner)
{ {
ArgUtil.NotNull(extensionStep, step.DisplayName); JobExtensionRunner extensionStep = step as JobExtensionRunner;
ArgUtil.NotNull(extensionStep, extensionStep.DisplayName);
Guid stepId = Guid.NewGuid(); Guid stepId = Guid.NewGuid();
var refName = step.GetRefName(defaultRefName: null); extensionStep.ExecutionContext = jobContext.CreateChild(stepId, extensionStep.DisplayName, null, null, stepId.ToString("N"));
extensionStep.ExecutionContext = jobContext.CreateChild(stepId, extensionStep.DisplayName, refName, null, stepId.ToString("N"));
} }
else if (step is IActionRunner actionStep) else if (step is IActionRunner actionStep)
{ {
ArgUtil.NotNull(actionStep, step.DisplayName); ArgUtil.NotNull(actionStep, step.DisplayName);
Guid stepId = Guid.NewGuid(); Guid stepId = Guid.NewGuid();
var refName = step.GetRefName(defaultRefName: stepId.ToString("N")); actionStep.ExecutionContext = jobContext.CreateChild(stepId, actionStep.DisplayName, stepId.ToString("N"), null, null, intraActionStates[actionStep.Action.Id]);
actionStep.ExecutionContext = jobContext.CreateChild(stepId, actionStep.DisplayName, refName, null, null, intraActionStates[actionStep.Action.Id]);
} }
} }
@@ -284,8 +281,7 @@ namespace GitHub.Runner.Worker
{ {
ArgUtil.NotNull(actionStep, step.DisplayName); ArgUtil.NotNull(actionStep, step.DisplayName);
intraActionStates.TryGetValue(actionStep.Action.Id, out var intraActionState); intraActionStates.TryGetValue(actionStep.Action.Id, out var intraActionState);
var refName = step.GetRefName(defaultRefName: actionStep.Action.Name); actionStep.ExecutionContext = jobContext.CreateChild(actionStep.Action.Id, actionStep.DisplayName, actionStep.Action.Name, actionStep.Action.ScopeName, actionStep.Action.ContextName, intraActionState);
actionStep.ExecutionContext = jobContext.CreateChild(actionStep.Action.Id, actionStep.DisplayName, refName, actionStep.Action.ScopeName, actionStep.Action.ContextName, intraActionState);
} }
} }

View File

@@ -1,7 +1,7 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using GitHub.DistributedTask.Expressions2;
using GitHub.DistributedTask.ObjectTemplating.Tokens; using GitHub.DistributedTask.ObjectTemplating.Tokens;
using GitHub.DistributedTask.Pipelines;
namespace GitHub.Runner.Worker namespace GitHub.Runner.Worker
{ {
@@ -9,26 +9,22 @@ namespace GitHub.Runner.Worker
{ {
private readonly object _data; private readonly object _data;
private readonly Func<IExecutionContext, object, Task> _runAsync; private readonly Func<IExecutionContext, object, Task> _runAsync;
private readonly RepositoryPathReference _repositoryRef;
public JobExtensionRunner( public JobExtensionRunner(
Func<IExecutionContext, object, Task> runAsync, Func<IExecutionContext, object, Task> runAsync,
string condition, string condition,
string displayName, string displayName,
object data, object data)
RepositoryPathReference repositoryRef)
{ {
_runAsync = runAsync; _runAsync = runAsync;
Condition = condition; Condition = condition;
DisplayName = displayName; DisplayName = displayName;
_data = data; _data = data;
_repositoryRef = repositoryRef;
} }
public string Condition { get; set; } public string Condition { get; set; }
public TemplateToken ContinueOnError => new BooleanToken(null, null, null, false); public TemplateToken ContinueOnError => new BooleanToken(null, null, null, false);
public string DisplayName { get; set; } public string DisplayName { get; set; }
public RepositoryPathReference RepositoryRef => _repositoryRef;
public IExecutionContext ExecutionContext { get; set; } public IExecutionContext ExecutionContext { get; set; }
public TemplateToken Timeout => new NumberToken(null, null, null, 0); public TemplateToken Timeout => new NumberToken(null, null, null, 0);
public object Data => _data; public object Data => _data;

View File

@@ -295,10 +295,9 @@ namespace GitHub.Runner.Common.Tests.Worker
{ {
Name = "action", Name = "action",
Id = actionId, Id = actionId,
Reference = new Pipelines.RepositoryPathReference() Reference = new Pipelines.ContainerRegistryReference()
{ {
Name = "actions/runner", Image = "ubuntu:16.04"
Ref = "v1"
}, },
Inputs = actionInputs Inputs = actionInputs
}; };

View File

@@ -176,7 +176,7 @@ namespace GitHub.Runner.Common.Tests.Worker
jobExtension.Initialize(hc); jobExtension.Initialize(hc);
_actionManager.Setup(x => x.PrepareActionsAsync(It.IsAny<IExecutionContext>(), It.IsAny<IEnumerable<Pipelines.JobStep>>())) _actionManager.Setup(x => x.PrepareActionsAsync(It.IsAny<IExecutionContext>(), It.IsAny<IEnumerable<Pipelines.JobStep>>()))
.Returns(Task.FromResult(new PrepareResult(new List<JobExtensionRunner>() { new JobExtensionRunner(null, "", "prepare1", null, null), new JobExtensionRunner(null, "", "prepare2", null, null) }, new Dictionary<Guid, IActionRunner>()))); .Returns(Task.FromResult(new PrepareResult(new List<JobExtensionRunner>() { new JobExtensionRunner(null, "", "prepare1", null), new JobExtensionRunner(null, "", "prepare2", null) }, new Dictionary<Guid, IActionRunner>())));
List<IStep> result = await jobExtension.InitializeJob(_jobEc, _message); List<IStep> result = await jobExtension.InitializeJob(_jobEc, _message);

View File

@@ -1 +1 @@
2.262.0 2.169.0