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

Template evaluation in action.yml #56

Merged
merged 3 commits into from
Jul 24, 2019
Merged

Conversation

TingluoHuang
Copy link
Member

@TingluoHuang TingluoHuang commented Jul 23, 2019

Leverage schema driven yaml parser to read the action.yml file, so we can parse out all the ${{expression}} expressions inside the yaml file and run through template evaluation with them.

ex:

name: 'Hello World'
description: 'Greet the world and record the time'
inputs: 
  greeting: # id of input
    description: 'The greeting we choose - will print ""{greeting}, World!"" on stdout'
    required: true
    default: 'Hello'
  entryPoint: # id of input
    description: 'optional docker entrypoint overwrite.'
    required: false
runs:
  using: 'docker'
  image: 'docker://ubuntu:18.04'
  args:
  - '${{ inputs.greeting }}'
  entrypoint: 'main.sh'
  env:
    Token: foo
    Test: ${{ inputs.entryPoint }}

[ServiceLocator(Default = typeof(ActionManifestManager))]
public interface IActionManifestManager : IRunnerService
{
ActionDefinitionData LoadManifestFile(IExecutionContext executionContext, string manifestFile);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shoudl this just be LoadManifest (i.e. is "File" redundant?)

Copy link
Member

Choose a reason for hiding this comment

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

Manifest is also redundant since it's the manifestmanager. Just load?

Copy link
Member Author

Choose a reason for hiding this comment

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

sure.


List<string> EvaluateContainerArguments(IExecutionContext executionContext, SequenceToken token, IDictionary<String, PipelineContextData> contextData);

Dictionary<String, String> EvaluateContainerEnvironments(IExecutionContext executionContext, MappingToken token, IDictionary<String, PipelineContextData> contextData);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Environment (singular)?

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

base.Initialize(hostContext);

var assembly = Assembly.GetExecutingAssembly();
var json = default(String);
Copy link
Collaborator

Choose a reason for hiding this comment

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

string

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

return actionDefinition;
}

public List<string> EvaluateContainerArguments(
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice

};
}
}
else if (string.Equals(usingToken.Value, "node", StringComparison.OrdinalIgnoreCase) ||
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we reduce this to just node12?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Choose a reason for hiding this comment

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

All the actions currently use node12 so we should be good.

Copy link
Member Author

Choose a reason for hiding this comment

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

cool, will remove "node"

/// <summary>
/// Converts a YAML file into a TemplateToken
/// </summary>
internal sealed class YamlObjectReader : IObjectReader
Copy link
Collaborator

Choose a reason for hiding this comment

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

after the fork, lets move everything into webapi and kill pipelines.yml. This should come from the SDK

@@ -11,6 +11,11 @@
using Pipelines = GitHub.DistributedTask.Pipelines;
using GitHub.Runner.Common;
using GitHub.Runner.Sdk;
using GitHub.DistributedTask.ObjectTemplating.Schema;
Copy link
Collaborator

Choose a reason for hiding this comment

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

sort

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@@ -89,6 +113,18 @@ public async Task RunAsync()
container.ContainerEntryPointArgs = Inputs.GetValueOrDefault("args");
}

if (Data.Environment != null)
Copy link
Collaborator

Choose a reason for hiding this comment

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

will this unintentionally clobber action-author-defined env?

Copy link
Collaborator

Choose a reason for hiding this comment

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

what's the guidance? namespace to avoid collision?

"mapping": {
"properties": {
"description": "string",
"required": "boolean",
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we validate required? otherwise should we remove these (should validation fail if we hit keys here we dont understand?)

@bryanmacfarlane
Copy link
Member

Can you update the description of the PR to give everyone context?

@TingluoHuang TingluoHuang merged commit 9d09123 into master Jul 24, 2019
@TingluoHuang TingluoHuang deleted the users/tihuang/actionschema branch July 24, 2019 17:12
fhammerl added a commit that referenced this pull request Jun 16, 2022
Hooks allowed to work even when context isn't returned
volker-raschek pushed a commit to dedalus-cis4u/github-runner-role that referenced this pull request Jul 25, 2022
jsoref pushed a commit to jsoref/actions-runner that referenced this pull request Oct 7, 2022
Creating or uploading artifacts needs a valid accesstoken, downloading without it is still allowed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants