Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
3251ead
Add basic framework for baby steps runner
ethanchewy Jul 13, 2020
06adbae
Basic logic for adding steps / invoking composite action steps
ethanchewy Jul 14, 2020
9fc6f80
Composite Steps Runner MVP
ethanchewy Jul 14, 2020
50d4f9d
Fix null object reference error
ethanchewy Jul 14, 2020
bb84921
intialize composiute
ethanchewy Jul 14, 2020
eb0e456
Comment out code that is handled by stepsrunner
ethanchewy Jul 14, 2020
c63709d
Add composite clean up step
ethanchewy Jul 14, 2020
2067778
Remove previous 'workarounds' from StepsRunner. Clean Up PR
ethanchewy Jul 15, 2020
96ac86f
Remove todo
ethanchewy Jul 15, 2020
f322697
Remove todo
ethanchewy Jul 15, 2020
2c157b4
Fix using unitialized object yikes
ethanchewy Jul 15, 2020
256e455
Remove time delay
ethanchewy Jul 15, 2020
e42a7c3
Format handler
ethanchewy Jul 15, 2020
49ba1c8
Move output handler into action handler
ethanchewy Jul 15, 2020
45639a2
Add try to evaluate display name
ethanchewy Jul 15, 2020
87d3030
Remove while loop yikes
ethanchewy Jul 15, 2020
e0561ad
Abstract away the windows encoding check during step running
ethanchewy Jul 15, 2020
25bd4b1
Github context set to {ScopeName}.{ContextName} or {ContextName} if S…
ethanchewy Jul 15, 2020
f5680aa
Remove setting result to sucess since result defaults to sucess
ethanchewy Jul 15, 2020
74ba0eb
Fix windows error
ethanchewy Jul 15, 2020
8bf57f7
Fix windows
ethanchewy Jul 16, 2020
b0d92bb
revert:
ethanchewy Jul 16, 2020
309e09b
Windows fix
ethanchewy Jul 16, 2020
7be28ab
Fix Windows Error in Abstraction
ethanchewy Jul 16, 2020
7d95fa6
Remove Composite Steps Runner => consolidate into Composite Steps Runner
ethanchewy Jul 16, 2020
16df485
Remove unn. attribute in ExecutionContext
ethanchewy Jul 16, 2020
79e572f
Change protection levels, plus change function name to more clear mea…
ethanchewy Jul 16, 2020
ce52070
Remove location param
ethanchewy Jul 16, 2020
dc36e2e
location pt.2 fix
ethanchewy Jul 16, 2020
3d4f7bd
Remove outputs step
ethanchewy Jul 16, 2020
bc613a0
Remove temp directory
ethanchewy Jul 16, 2020
a0af7d6
new line
ethanchewy Jul 16, 2020
81bdee6
Add arguitl not null
ethanchewy Jul 16, 2020
44ed247
better comment
ethanchewy Jul 16, 2020
3c2d8f1
Change encoding name
ethanchewy Jul 16, 2020
868a42a
Check count > 0 for composite steps, import System.Threading
ethanchewy Jul 16, 2020
61a0049
Change function header encodingutil
ethanchewy Jul 16, 2020
df4e4c1
Add TODO
ethanchewy Jul 16, 2020
1cafbf0
Add await
ethanchewy Jul 16, 2020
470708d
Handle Failed Step
ethanchewy Jul 16, 2020
3915791
Move over SetAllCompositeOutputs to the handler
ethanchewy Jul 16, 2020
a40c07b
Remove timeout-minutes setting in steps-level
ethanchewy Jul 16, 2020
7d96e5d
Use only ExecutionContext
ethanchewy Jul 17, 2020
8714315
Move using to the top
ethanchewy Jul 17, 2020
ca79af5
Remove redundant check
ethanchewy Jul 17, 2020
b6c3091
Change function name
ethanchewy Jul 17, 2020
22c4cb9
Remove testing code
ethanchewy Jul 17, 2020
89002ce
Consolidate error code
ethanchewy Jul 17, 2020
0ad860e
Consolidate code
ethanchewy Jul 17, 2020
28db0aa
Change HandleOutput => ProcessCompositeActionOutputs
ethanchewy Jul 17, 2020
dd476b8
Remove set the timeout comment
ethanchewy Jul 17, 2020
d9e5109
Add Cancelling functionality + Remove unn. parameter
ethanchewy Jul 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions src/Runner.Common/Util/EncodingUtil.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using GitHub.Runner.Sdk;
using GitHub.Runner.Common;

namespace GitHub.Runner.Common.Util
{
public static class EncodingUtil
{
public static async Task SetEncoding(IHostContext hostContext, Tracing trace, CancellationToken cancellationToken)
{
#if OS_WINDOWS
try
{
if (Console.InputEncoding.CodePage != 65001)
{
using (var p = hostContext.CreateService<IProcessInvoker>())
{
// Use UTF8 code page
int exitCode = await p.ExecuteAsync(workingDirectory: hostContext.GetDirectory(WellKnownDirectory.Work),
fileName: WhichUtil.Which("chcp", true, trace),
arguments: "65001",
environment: null,
requireExitCodeZero: false,
outputEncoding: null,
killProcessOnCancel: false,
redirectStandardIn: null,
inheritConsoleHandler: true,
cancellationToken: cancellationToken);
if (exitCode == 0)
{
trace.Info("Successfully returned to code page 65001 (UTF8)");
}
else
{
trace.Warning($"'chcp 65001' failed with exit code {exitCode}");
}
}
}
}
catch (Exception ex)
{
trace.Warning($"'chcp 65001' failed with exception {ex.Message}");
}
#endif
// Dummy variable to prevent compiler error CS1998: "This async method lacks 'await' operators and will run synchronously..."
await Task.CompletedTask;
}
}
}
30 changes: 0 additions & 30 deletions src/Runner.Worker/ActionManifestManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public interface IActionManifestManager : IRunnerService
Dictionary<string, string> EvaluateContainerEnvironment(IExecutionContext executionContext, MappingToken token, IDictionary<string, PipelineContextData> extraExpressionValues);

string EvaluateDefaultInput(IExecutionContext executionContext, string inputName, TemplateToken token);

void SetAllCompositeOutputs(IExecutionContext parentExecutionContext, DictionaryContextData actionOutputs);
}

public sealed class ActionManifestManager : RunnerService, IActionManifestManager
Expand Down Expand Up @@ -170,34 +168,6 @@ public ActionDefinitionData Load(IExecutionContext executionContext, string mani
return actionDefinition;
}

public void SetAllCompositeOutputs(
IExecutionContext parentExecutionContext,
DictionaryContextData actionOutputs)
{
// Each pair is structured like this
// We ignore "description" for now
// {
// "the-output-name": {
// "description": "",
// "value": "the value"
// },
// ...
// }
foreach (var pair in actionOutputs)
{
var outputsName = pair.Key;
var outputsAttributes = pair.Value as DictionaryContextData;
outputsAttributes.TryGetValue("value", out var val);
var outputsValue = val as StringContextData;

// Set output in the whole composite scope.
if (!String.IsNullOrEmpty(outputsName) && !String.IsNullOrEmpty(outputsValue))
{
parentExecutionContext.SetOutput(outputsName, outputsValue, out _);
}
}
}

public DictionaryContextData EvaluateCompositeOutputs(
IExecutionContext executionContext,
TemplateToken token,
Expand Down
20 changes: 3 additions & 17 deletions src/Runner.Worker/ExecutionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ public interface IExecutionContext : IRunnerService

bool EchoOnActionCommand { get; set; }

IExecutionContext FinalizeContext { get; set; }

// Initialize
void InitializeJob(Pipelines.AgentJobRequestMessage message, CancellationToken token);
void CancelToken();
Expand Down Expand Up @@ -107,7 +105,7 @@ public interface IExecutionContext : IRunnerService
// others
void ForceTaskComplete();
void RegisterPostJobStep(IStep step);
IStep RegisterNestedStep(IActionRunner step, DictionaryContextData inputsData, int location, Dictionary<string, string> envData, bool cleanUp = false);
IStep CreateCompositeStep(IActionRunner step, DictionaryContextData inputsData, Dictionary<string, string> envData);
}

public sealed class ExecutionContext : RunnerService, IExecutionContext
Expand Down Expand Up @@ -174,8 +172,6 @@ public sealed class ExecutionContext : RunnerService, IExecutionContext

public bool EchoOnActionCommand { get; set; }

public IExecutionContext FinalizeContext { get; set; }

public TaskResult? Result
{
get
Expand Down Expand Up @@ -276,12 +272,10 @@ public void RegisterPostJobStep(IStep step)
/// Helper function used in CompositeActionHandler::RunAsync to
/// add a child node, aka a step, to the current job to the Root.JobSteps based on the location.
/// </summary>
public IStep RegisterNestedStep(
public IStep CreateCompositeStep(
IActionRunner step,
DictionaryContextData inputsData,
int location,
Dictionary<string, string> envData,
bool cleanUp = false)
Dictionary<string, string> envData)
{
// If the context name is empty and the scope name is empty, we would generate a unique scope name for this child in the following format:
// "__<GUID>"
Expand All @@ -297,12 +291,6 @@ public IStep RegisterNestedStep(

step.ExecutionContext.ExpressionValues["inputs"] = inputsData;

// Set Parent Attribute for Clean Up Step
if (cleanUp)
{
step.ExecutionContext.FinalizeContext = this;
}

// Add the composite action environment variables to each step.
#if OS_WINDOWS
var envContext = new DictionaryContextData();
Expand All @@ -315,8 +303,6 @@ public IStep RegisterNestedStep(
}
step.ExecutionContext.ExpressionValues["env"] = envContext;

Root.JobSteps.Insert(location, step);

return step;
}

Expand Down
Loading