https://github.com/hookyns/tyml
Library which is able to take YAML file in given format and process its instructions. It is like Your private local pipeline.
https://github.com/hookyns/tyml
csharp dotnet pipeline task task-runner yaml
Last synced: about 2 months ago
JSON representation
Library which is able to take YAML file in given format and process its instructions. It is like Your private local pipeline.
- Host: GitHub
- URL: https://github.com/hookyns/tyml
- Owner: Hookyns
- License: mit
- Created: 2021-03-16T03:53:11.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-08-29T21:49:54.000Z (almost 3 years ago)
- Last Synced: 2025-01-15T05:38:25.907Z (over 1 year ago)
- Topics: csharp, dotnet, pipeline, task, task-runner, yaml
- Language: C#
- Homepage:
- Size: 91.8 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tyml
YAML Task Runner
TYML is library able to take YAML file in given format and process its instructions. It is like Your private local pipeline.
## Example
### Configuration
```c#
TymlContext tymlContext = new TymlContextBuilder()
.AddTasks(typeof(CmdTask))
.UseWorkingDirectory(path)
.WithBaseVariables(new Dictionary()
{
{"foo", 5},
{"bar", "baz"}
})
.Build();
TymlExecutor tymlExecutor = provider.GetRequiredService();
using (ConsoleSink sink = new ConsoleSink(new ConsoleSinkOptions(ColorTheme.DarkConsole)))
{
await foreach (TaskExecution execution in tymlExecutor.Execute(tymlContext, CONTENT_OF_YAML_FILE))
{
await execution.OutputReader.Pipe(sink);
}
await foreach (TaskExecution execution in tymlExecutor.Execute(tymlContext, CONTENT_OF_SOME_OTHER_YAML_FILE))
{
await execution.OutputReader.Pipe(sink);
}
}
```
### YAML Format
```yaml
description: "Some description of this YAML" # optional description
variables: # optional variable section; overwriting environment variables and TymlContext variables.
ProjectDescription: |-
This is testing multiline project description.
This is second line of it.
with: colon
steps:
- task: Cmd # Name of task
displayName: "Run something" # Optional display name
inputs: # Input arguments parsed into IDictionary passed to ITask.Execute or parsed into generic type of TaskBase if you inherit from that
Script: "something.exe"
Args:
SomeEnvVariable: $(ProductionEnvironment) # $(..) replaced by variable value before execution if defined
ProjectDescription: '$(ProjectDescription)'
FooVariable: $(foo)! # Required variable; Exception thrown if not defined
```
## Predefined Tasks
You can install package `RJDev.Tyml.Tasks.Base` which implements basic tasks such as Cmd (run script on cmd/bash) and ExtractFiles.
## Custom Tasks
If You want to create custom Task You must implement `ITask` interface or use generic abstract class `TaskBase`.
If You want to publish your packages to NuGet, it would be nice to keep some naming convention, at least keep `Tyml.Tasks.{WhatKindOfTasks}`; or create PR to Tasks.Basic.
```c#
[TymlTask("Cmd", "Optional task description")]
public class CmdTask : TaskBase
{
protected override Task Execute(TaskContext context, CmdInputs inputs, CancellationToken cancellationToken)
{
context.Out.WriteLine($"Script: {inputs.Script} with args: {string.Join("; ", inputs.Args.Select(entry => entry.Key + ":" + entry.Value))}");
return this.OkSync();
}
}
```