Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: added defaults shell and working-directory to composite #1803

Open
wants to merge 152 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 150 commits
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
f572663
added defaults shell and working-directory to composite
Apr 4, 2022
af1d9c0
removed extra spaces in action_yaml
Apr 4, 2022
9fadfdc
merged from main, CompositeDefaults don't override global, renamed ac…
nikola-jokic Apr 7, 2022
fc85544
Merge branch 'main' into nikola-jokic/enhancement/836
nikola-jokic Apr 11, 2022
372229d
Merge branch 'actions:main' into nikola-jokic/enhancement/836
nikola-jokic Apr 28, 2022
e87a311
added check if default is set or shell is set
nikola-jokic Apr 28, 2022
238565a
added missing check on shell only if action source type is script
nikola-jokic Apr 28, 2022
af94f51
Merge branch 'actions:main' into nikola-jokic/enhancement/836
nikola-jokic May 31, 2022
b8e91ed
Merge branch 'actions:main' into nikola-jokic/enhancement/836
nikola-jokic Aug 16, 2022
a795990
Improved error logs for missing 'using' configuration in metadata fil…
AvaStancu Aug 16, 2022
703a54f
Display full job name and nested workflow details in log (#2049)
Aug 23, 2022
5731c0e
Include step context name and start/finish time in step telemetry (#2…
TingluoHuang Aug 23, 2022
a2fb048
Escaping key and quoting it to avoid key based command injection (#2062)
nikola-jokic Aug 23, 2022
2363d32
Release notes for 2.296.0 (#2078)
AvaStancu Aug 23, 2022
a47f49c
Validate lines and columns for Annotations (#2082)
konradpabjan Aug 24, 2022
7c7cd7f
docker: escape key-value pair as -e KEY and VALUE being environment v…
nikola-jokic Aug 31, 2022
a815fa9
2.296.1 Release (#2092) (#2099)
fhammerl Sep 2, 2022
a419d6c
fix ACTIONS_RUNNER_CONTAINER_HOOKS name in ADR (#2098)
nikola-jokic Sep 6, 2022
43853e5
Port hotfix to main branch (#2108)
thboop Sep 9, 2022
69f84e9
fix for issue #2009 - composite summary file (#2077)
ruvceskistefan Sep 12, 2022
df0ac57
Bump @actions/core from 1.2.6 to 1.9.1 in /src/Misc/expressionFunc/ha…
rentziass Sep 15, 2022
3c93e8e
Remove unused imports (#2124)
JoannaaKL Sep 15, 2022
bf2caf4
Remove unused imports (#2126)
JoannaaKL Sep 15, 2022
ef8719e
Add Release branches to pull request spec (#2134)
thboop Sep 19, 2022
9176801
Add file commands for save-state and set-output (#2118)
rentziass Sep 26, 2022
36c5a27
POC: Windows arm64 runner build (#2022)
thboop Sep 26, 2022
e6b4b11
Add link to blog post to node 12 warn (#2156)
takost Sep 26, 2022
e239ec4
2.297.0 release notes (#2155)
thboop Sep 26, 2022
b30cba2
Adding a new vars context for non-secret variables (#2096)
tauhid621 Sep 30, 2022
69ac979
Avastancu/joannaakl/service container error log (#2110)
JoannaaKL Oct 3, 2022
23887ca
Add warning for users using deprecated commands (#2164)
rentziass Oct 4, 2022
fd08a1f
Prepare release notes for v2.298.0 (#2169)
rentziass Oct 4, 2022
5156aab
Fix incorrect template vars to show SHA for WIN-ARM64 (#2171)
fhammerl Oct 4, 2022
aa5f3d9
Backport 2.298.1 (#2175)
fhammerl Oct 4, 2022
4cecc9f
Revert "Avastancu/joannaakl/service container error log (#2110)" (#2179)
fhammerl Oct 5, 2022
d719a7b
Correct grammar in archive extraction error message (#2184)
rneatherway Oct 6, 2022
d977f4c
changes to support specific run service URL (#2158)
yaananth Oct 6, 2022
2f3f6cb
Backfill notes from release branch 2.298.2 (wrong branch name) (#2180)
fhammerl Oct 7, 2022
9ba99d7
Avastancu/joannaakl/service container error log (#2110) (#2182)
AvaStancu Oct 11, 2022
e5b069b
Allow '--disableupdate' in create-latest-svc.sh (#2201)
fhammerl Oct 13, 2022
c0e9d53
Fix markup for support link (#2114)
bensherman Oct 13, 2022
1b149c2
Add runner devcontainer (#2187)
fhammerl Oct 17, 2022
2efddc2
Fix IDE0090 (#2211)
cory-miller Oct 18, 2022
985c95b
Add linter workflow (#2213)
cory-miller Oct 18, 2022
d26dc55
Disable linter errors (#2216)
cory-miller Oct 20, 2022
351e962
Add generateServiceConfig option for configure command (#2226)
cory-miller Oct 26, 2022
b4f0c45
Setting debug using GitHub Action variables (#2234)
tauhid621 Oct 31, 2022
d019e5b
Allow the container.image to be empty (#2235)
JoannaaKL Nov 2, 2022
aae4dd8
run.sh installs SIGINT and SIGTERM traps to gracefully stop runner (#…
nikola-jokic Nov 2, 2022
fe189bd
Use Global.Variables instead of JobContext and include action path/re…
TingluoHuang Nov 2, 2022
fde6136
prepare release notes for 2.299.0 (#2239)
cory-miller Nov 2, 2022
813a252
Forward parameters into run() func in run.sh. (#2240)
TingluoHuang Nov 2, 2022
dd8bce0
Dockerfile and workflow change for runner image (#2250)
nikola-jokic Nov 10, 2022
dc9fe01
Add `RUNNER_ALLOW_RUNASROOT=1` to dockerfile (#2254)
TingluoHuang Nov 15, 2022
3351ea3
Small change to Node.js 12 deprecation message (#2262)
chrispat Nov 16, 2022
fdfbdfd
expose github.actor_id, github.workflow_ref & github.workflow_sha as …
amitrathi2040 Nov 17, 2022
eea1f6d
Updated info on process for requesting features and enhancements (#2259)
AvaStancu Nov 18, 2022
1afe238
Support runner upgrade messages (#2231)
takost Nov 21, 2022
bf616ec
added replace to allow create latest svc to apply --replace flag (#2273)
nikola-jokic Nov 22, 2022
f3cc2b4
(delete.sh) Loggin repaired and made runner_name optional defaulting …
nikola-jokic Nov 22, 2022
3bf19c7
added to lowercase on setting github.action_status (#1944)
nikola-jokic Nov 22, 2022
864030d
Backfill notes and version from 'Release 2.299.1 runner.' (#2277)
fhammerl Nov 22, 2022
1f88507
Return exit code when MANUALLY_TRAP_SIG is exported (#2285)
nikola-jokic Nov 28, 2022
30bbf6c
Listener stdout logging (#2291)
AvaStancu Dec 6, 2022
9de53d2
Made worker logs available to stdout (#2307)
AvaStancu Dec 8, 2022
5f507c9
Use results for uploading step summaries (#2301)
brittanyellich Dec 14, 2022
f2b463f
prepare release notes for 2.300.0 (#2312)
AvaStancu Dec 14, 2022
6e475d8
Update Dockerfile (#2315)
fhammerl Dec 15, 2022
f920de4
Updated contact links for feature requests (#2314)
AvaStancu Dec 15, 2022
137dfb2
Initialize container manager based on whether the ContainerHooksPath …
nikola-jokic Dec 16, 2022
8129966
set env in ProcessInvoker sanitized (#2280)
ruvceskistefan Dec 19, 2022
71a27d9
Re-add file size check prior to reading file (#2321) (#2330)
bethanyj28 Dec 19, 2022
dbf6605
Release notes for 2.300.1 (#2326)
fhammerl Dec 19, 2022
b30f14c
Bump runner version to 2.300.2 to match released version.
TingluoHuang Dec 19, 2022
a683911
Log GitHub RequestId for better traceability. (#2332)
TingluoHuang Dec 19, 2022
850e416
Make runner image print diag log to STDOUT. (#2331)
TingluoHuang Dec 19, 2022
6a907a0
split by regex (#2333)
ruvceskistefan Dec 20, 2022
b7e09ad
Treat jitconfig as secret. (#2335)
nikola-jokic Dec 21, 2022
6058531
Add Header/Footer to multi-line message in StdoutTraceListener. (#2336)
TingluoHuang Dec 22, 2022
8a1f32c
Always upload to avoid issues (#2334)
yacaovsnc Dec 28, 2022
90e0dff
Allow provide extra User-Agent for better correlation. (#2370)
TingluoHuang Jan 16, 2023
4c7e786
Show more information in the runner log (#2377)
yujincat Jan 18, 2023
9bb4504
update node to 16.16.0 (#2371)
johnsudol Jan 18, 2023
f6b0110
Add a disclaimer for which runner version is available to a given ten…
cory-miller Jan 18, 2023
9a80f6f
new option to remove local config files (#2367)
johnsudol Jan 18, 2023
54f998e
Update Node dependencies (#2381)
johnsudol Jan 18, 2023
f53e066
Prepare 2.301.0 runner release. (#2382)
TingluoHuang Jan 18, 2023
1b73815
Revert "split by regex (#2333)" (#2383)
TingluoHuang Jan 19, 2023
14b8882
Bump runner version to match the released runner. (#2385)
TingluoHuang Jan 19, 2023
b42d461
Bump dotnet sdk to latest version. (#2392)
TingluoHuang Jan 23, 2023
380d752
fix small bug (#2396)
yaananth Jan 30, 2023
3aabb2f
start calling run service for job completion (#2412)
yaananth Feb 1, 2023
7262b18
Add support for ghe.com domain (#2420)
easyt Feb 6, 2023
288e7f8
Defer evaluation of a step's DisplayName until its condition is evalu…
jww3 Feb 7, 2023
fc5c740
Run service: send more stuff as part of job completed (#2423)
yaananth Feb 7, 2023
550aa86
Add docker cli to the runner image. (#2425)
TingluoHuang Feb 8, 2023
6a9f352
Replace '(' and ')' with '[' and '] from OS.Description so it doesn't…
fhammerl Feb 8, 2023
c58f11b
Uploading step logs to Results as well (#2422)
yacaovsnc Feb 13, 2023
9eefe99
Prepare runner release 2.302.0 (#2433)
TingluoHuang Feb 14, 2023
a04bf63
Use v2 version based on https://github.blog/changelog/2023-01-18-code…
TingluoHuang Feb 14, 2023
1b711d5
Don't add Needs constant twice
JoannaaKL Feb 15, 2023
7c29bf5
Revert "Uploading step logs to Results as well (#2422)" (#2437)
yacaovsnc Feb 15, 2023
876b1b5
Wait for docker base on env RUNNER_WAIT_FOR_DOCKER_IN_SECONDS. (#2440)
TingluoHuang Feb 15, 2023
51e0aa4
Don't disable lint errors (#2436)
JoannaaKL Feb 16, 2023
8e3de94
Properly guard upload (#2439)
yacaovsnc Feb 17, 2023
348a30e
Add job log upload support (#2447)
yacaovsnc Feb 21, 2023
b143196
call run service renewjob (#2461)
yaananth Feb 27, 2023
7572af1
Runner service exit after consecutive re-try exits (#2426)
nikola-jokic Feb 28, 2023
5bca536
Change runner image to make user/folder align with ubuntu-latest host…
TingluoHuang Mar 2, 2023
042d452
Bypass all proxies for all hosts if `no_proxy='*'` is set (#2395)
fhammerl Mar 6, 2023
cf3e1a5
Exit on deprication error (#2299)
nikola-jokic Mar 7, 2023
ceebeef
Add update certificates to ./run.sh if RUNNER_UPDATE_CA_CERTS env is …
nikola-jokic Mar 8, 2023
2b94eaa
Support matrix context in output keys (#2477)
ajaykn Mar 10, 2023
ecdd895
Replace deprecated command with environment file (#2429)
jongwooo Mar 10, 2023
81b6ad1
Prepare runner release 2.303.0 (#2482)
TingluoHuang Mar 10, 2023
3d1be04
Update container hooks version to 0.3.0 (#2492)
Link- Mar 17, 2023
fddc1df
Bump container hooks version to 0.3.1 (#2496)
TingluoHuang Mar 20, 2023
4b27b49
Update runner to handle Dotcom/runner-admin based registration flow (…
takost Mar 21, 2023
5c66797
Fix JIT configurations on Windows (#2497)
MatisseHack Mar 21, 2023
f905dde
ADR: Runner Image Tags (#2494)
Link- Mar 23, 2023
5bb25e8
Listen directly to Broker for messages (#2500)
luketomlinson Mar 24, 2023
b486802
Register Runners against V2 servers (#2505)
luketomlinson Mar 28, 2023
fb6c379
Guard against NullReference while creating HostContext (#2343)
nikola-jokic Mar 30, 2023
56cb9c1
Update Runner to send step updates to Results (#2510)
yacaovsnc Apr 3, 2023
1767552
which handles broken symlink & unit test added (#2150) (#2196)
eli-entelis Apr 7, 2023
a710569
Also send in conclusion for steps (#2531)
yacaovsnc Apr 13, 2023
3cf0bda
If conclusion is not set, we cannot get default value (#2535)
yacaovsnc Apr 13, 2023
5b7d827
Handle non success raw http responses (#2541)
yaananth Apr 14, 2023
d3ca7cb
Adding curl retry for external tool downloads (#2552)
mspletz Apr 18, 2023
d28dd80
Limit the time we wait for waiting websocket to connect. (#2554)
TingluoHuang Apr 19, 2023
601990b
Adding curl --retry-all-errors for external tool downloads (#2557)
mspletz Apr 20, 2023
a3cc9e2
Add *.ghe.localhost domains to hosted server check (#2536)
easyt Apr 24, 2023
552bdff
Rename AcquireJobRequest::StreamID to AcquireJobRequest::JobMessageID…
jww3 Apr 26, 2023
9b8f244
Bypass job server when run service is enabled (#2516)
yacaovsnc Apr 26, 2023
c283204
Add orchestrationId to useragent for better correlation. (#2568)
TingluoHuang Apr 26, 2023
4c3438c
Prepare 2.304.0 runner release. (#2569)
TingluoHuang Apr 26, 2023
737927e
handle conflict errors from run service (#2570)
yaananth Apr 27, 2023
70d90a0
contribute.md: Fix link to style guidelines (#2560)
perlun Apr 27, 2023
0db9b07
Fix null guard bug (#2576)
yacaovsnc Apr 28, 2023
7b629c8
send annotations to run-service (#2574)
yaananth May 1, 2023
195f070
Remove Temporary Serialization Shim (#2549)
jww3 May 3, 2023
e32d771
Resolve Actions Directly From Launch for Run Service Jobs (#2529)
jherns May 3, 2023
a92deb2
Trace WebSocket exception into verbose level to reduce noise in diag …
TingluoHuang May 8, 2023
ff9684c
[1742] Ensure multiple composite annoations are correctly written. (#…
jww3 May 10, 2023
12252fa
Add --no-default-labels config option to self-hosted runners (#2443)
gabriel-samfira May 11, 2023
6e2f0b0
Adding Consistency to 'Failed To Resolve Action Download Info' Infras…
vmjoseph May 11, 2023
822237f
added defaults shell and working-directory to composite
Apr 4, 2022
ab0f3e1
Merge branch 'main' into nikola-jokic/enhancement/836
nikola-jokic May 12, 2023
274b805
auto update leftover removed
nikola-jokic May 12, 2023
19f867d
encode every changed file to utf8
nikola-jokic May 12, 2023
e4b8e89
Add null reference guard
nikola-jokic May 23, 2023
b997f1f
Merge branch 'main' into nikola-jokic/enhancement/836
nikola-jokic Sep 21, 2023
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
1 change: 1 addition & 0 deletions src/Runner.Worker/ActionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,7 @@ public sealed class CompositeActionExecutionData : ActionExecutionData
public List<Pipelines.ActionStep> Steps { get; set; }
public Stack<Pipelines.ActionStep> PostSteps { get; set; }
public MappingToken Outputs { get; set; }
public MappingToken CompositeDefaults { get; set; }
}

public abstract class ActionExecutionData
Expand Down
37 changes: 34 additions & 3 deletions src/Runner.Worker/ActionManifestManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ private ActionExecutionData ConvertRuns(
var postEntrypointToken = default(StringToken);
var postIfToken = default(StringToken);
var steps = default(List<Pipelines.Step>);
var defaultsToken = default(MappingToken);

foreach (var run in runsMapping)
{
Expand Down Expand Up @@ -419,6 +420,9 @@ private ActionExecutionData ConvertRuns(
steps = PipelineTemplateConverter.ConvertToSteps(templateContext, stepsToken);
templateContext.Errors.Check();
break;
case "defaults":
defaultsToken = run.Value.AssertMapping("defaults");
break;
default:
Trace.Info($"Ignore run property {runsKey}.");
break;
Expand Down Expand Up @@ -448,7 +452,7 @@ private ActionExecutionData ConvertRuns(
};
}
}
else if (string.Equals(usingToken.Value, "node12", StringComparison.OrdinalIgnoreCase)||
else if (string.Equals(usingToken.Value, "node12", StringComparison.OrdinalIgnoreCase) ||
string.Equals(usingToken.Value, "node16", StringComparison.OrdinalIgnoreCase))
{
if (string.IsNullOrEmpty(mainToken?.Value))
Expand Down Expand Up @@ -476,14 +480,41 @@ private ActionExecutionData ConvertRuns(
}
else
{
var compositeActionsExecutionDataSteps = steps.Cast<Pipelines.ActionStep>().ToList();
if (defaultsToken == null)
{
foreach (var step in compositeActionsExecutionDataSteps)
{
if (step.Reference.Type != Pipelines.ActionSourceType.Script)
{
continue;
}
var mapping = step.Inputs.AssertMapping("inputs");
var foundShell = false;
foreach (var pair in mapping)
{
// Expression key
if (pair.Key is StringToken && pair.Key.AssertString("inputs key").Value.Equals("shell"))
{
foundShell = true;
break;
}
}
if (!foundShell)
{
throw new TemplateValidationException("Composite action must set the default shell, or the shell parameter in each step is required.");
}
}
}
return new CompositeActionExecutionData()
{
Steps = steps.Cast<Pipelines.ActionStep>().ToList(),
Steps = compositeActionsExecutionDataSteps,
PreSteps = new List<Pipelines.ActionStep>(),
PostSteps = new Stack<Pipelines.ActionStep>(),
InitCondition = "always()",
CleanupCondition = "always()",
Outputs = outputs
Outputs = outputs,
CompositeDefaults = defaultsToken,
};
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Runner.Worker/GlobalContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public sealed class GlobalContext
public PlanFeatures Features { get; set; }
public IList<String> FileTable { get; set; }
public IDictionary<String, IDictionary<String, String>> JobDefaults { get; set; }
public IDictionary<String, IDictionary<String, String>> CompositeDefaults { get; set; }
public List<ActionsStepTelemetry> StepsTelemetry { get; set; }
public List<StepResult> StepsResult { get; set; }
public List<Annotation> JobAnnotations { get; set; }
Expand Down
31 changes: 31 additions & 0 deletions src/Runner.Worker/Handlers/CompositeActionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ public async Task RunAsync(ActionRunStage stage)
}
ExecutionContext.StepTelemetry.Type = "composite";

// save job defaults run to be restored after the composite run
IDictionary<string, string> jobDefaultsRun = new Dictionary<string, string>();
if (ExecutionContext.Global.JobDefaults.ContainsKey("run"))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets not overwrite job defaults, let's use a new key called CompositeDefaults, to minimize risk of these changes and make it clearer to read the code where these values are coming from.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it but I am not sure if this is what you have meant.

{
jobDefaultsRun = ExecutionContext.Global.JobDefaults["run"];
}

try
{
// Inputs of the composite step
Expand Down Expand Up @@ -162,6 +169,26 @@ public async Task RunAsync(ActionRunStage stage)
embeddedSteps.Add(step);
}

ExecutionContext.Global.CompositeDefaults = new Dictionary<string, IDictionary<string, string>>(StringComparer.OrdinalIgnoreCase)
{
["run"] = new Dictionary<string, string>(),
};

if (Data.CompositeDefaults != null && Data.CompositeDefaults.Any(x => string.Equals(x.Key.AssertString("defaults key").Value, "run", StringComparison.OrdinalIgnoreCase)))
{
var defaultsToken = Data.CompositeDefaults.First(x => string.Equals(x.Key.AssertString("defaults key").Value, "run", StringComparison.OrdinalIgnoreCase));
var templateEvaluator = ExecutionContext.ToPipelineTemplateEvaluator();
var jobDefaults = templateEvaluator.EvaluateJobDefaultsRun(defaultsToken.Value, ExecutionContext.ExpressionValues, ExecutionContext.ExpressionFunctions);

foreach (var pair in jobDefaults)
{
if (!string.IsNullOrEmpty(pair.Value))
{
ExecutionContext.Global.CompositeDefaults["run"][pair.Key] = pair.Value;
}
}
}

// Run embedded steps
await RunStepsAsync(embeddedSteps, stage);

Expand All @@ -177,6 +204,10 @@ public async Task RunAsync(ActionRunStage stage)
ExecutionContext.Error(ex);
ExecutionContext.Result = TaskResult.Failed;
}
finally
{
ExecutionContext.Global.CompositeDefaults = new Dictionary<string, IDictionary<string, string>>(StringComparer.OrdinalIgnoreCase);
}
}

private void ProcessOutputs()
Expand Down
42 changes: 35 additions & 7 deletions src/Runner.Worker/Handlers/ScriptHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.IO;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -68,15 +68,25 @@ protected override void PrintActionDetails(ActionRunStage stage)
bool validateShellOnHost = !(StepHost is ContainerStepHost);
string prependPath = string.Join(Path.PathSeparator.ToString(), ExecutionContext.Global.PrependPath.Reverse<string>());
string shell = null;

if (!Inputs.TryGetValue("shell", out shell) || string.IsNullOrEmpty(shell))
{
// TODO: figure out how defaults interact with template later
// for now, we won't check job.defaults if we are inside a template.
if (string.IsNullOrEmpty(ExecutionContext.ScopeName) && ExecutionContext.Global.JobDefaults.TryGetValue("run", out var runDefaults))
if (ExecutionContext.Global.CompositeDefaults.TryGetValue("run", out var runCompositeDefaults))
{
if (runCompositeDefaults.TryGetValue("shell", out shell))
{
ExecutionContext.Debug("Overwrite 'shell' base on composite defaults.");
}
}
else if (ExecutionContext.Global.JobDefaults.TryGetValue("run", out var runDefaults))
{
runDefaults.TryGetValue("shell", out shell);
if (runDefaults.TryGetValue("shell", out shell))
{
ExecutionContext.Debug("Overwrite 'shell' base on job defaults.");
}
}
}

if (string.IsNullOrEmpty(shell))
{
#if OS_WINDOWS
Expand Down Expand Up @@ -156,7 +166,14 @@ public async Task RunAsync(ActionRunStage stage)
if (!Inputs.TryGetValue("workingDirectory", out workingDirectory))
{
// Don't use job level working directories for hooks
if (IsActionStep && string.IsNullOrEmpty(ExecutionContext.ScopeName) && ExecutionContext.Global.JobDefaults.TryGetValue("run", out var runDefaults))
if (githubContext.ContainsKey("action_path") && ExecutionContext.Global.CompositeDefaults.TryGetValue("run", out var runCompositeDefaults))
{
if (runCompositeDefaults.TryGetValue("working-directory", out workingDirectory))
{
ExecutionContext.Debug("Overwrite 'working-directory' base on composite defaults.");
}
}
else if (IsActionStep && string.IsNullOrEmpty(ExecutionContext.ScopeName) && ExecutionContext.Global.JobDefaults.TryGetValue("run", out var runDefaults))
{
if (runDefaults.TryGetValue("working-directory", out workingDirectory))
{
Expand All @@ -165,12 +182,23 @@ public async Task RunAsync(ActionRunStage stage)
}
}
var workspaceDir = githubContext["workspace"] as StringContextData;
if (githubContext.ContainsKey("action_path"))
{
workspaceDir = githubContext["action_path"] as StringContextData;
}
workingDirectory = Path.Combine(workspaceDir, workingDirectory ?? string.Empty);

string shell = null;
if (!Inputs.TryGetValue("shell", out shell) || string.IsNullOrEmpty(shell))
{
if (string.IsNullOrEmpty(ExecutionContext.ScopeName) && ExecutionContext.Global.JobDefaults.TryGetValue("run", out var runDefaults))
if (githubContext.ContainsKey("action_path") && ExecutionContext.Global.CompositeDefaults.TryGetValue("run", out var runCompositeDefaults))
{
if (runCompositeDefaults.TryGetValue("shell", out shell))
{
ExecutionContext.Debug("Overwrite 'shell' base on composite defaults.");
}
}
else if (ExecutionContext.Global.JobDefaults.TryGetValue("run", out var runDefaults))
{
if (runDefaults.TryGetValue("shell", out shell))
{
Expand Down
39 changes: 36 additions & 3 deletions src/Runner.Worker/action_yaml.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"definitions": {
"action-root": {
"description": "Action file",
Expand Down Expand Up @@ -103,7 +103,11 @@
"mapping": {
"properties": {
"using": "non-empty-string",
"steps": "composite-steps"
"steps": "composite-steps",
"defaults": {
"type": "composite-defaults",
"required": false
}
}
}
},
Expand Down Expand Up @@ -133,7 +137,7 @@
"working-directory": "string-steps-context",
"shell": {
"type": "string-steps-context",
"required": true
"required": false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should still fail here if composite defaults aren't set and a shell isn't set for that step. Do we currently do that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in that case, the action would fail with this output:
image

}
}
}
Expand Down Expand Up @@ -268,6 +272,35 @@
"loose-key-type": "non-empty-string",
"loose-value-type": "string"
}
},
"composite-defaults": {
"mapping": {
"properties": {
"run": "composite-defaults-run"
}
}
},
"composite-defaults-run": {
"context": [
"inputs",
"github",
"strategy",
"matrix",
"needs",
"env"
],
"mapping": {
"properties": {
"shell": {
"type": "non-empty-string",
"required": false
},
"working-directory": {
"type": "non-empty-string",
"required": false
}
}
}
}
}
}