GithubHelp home page GithubHelp logo

bubdm / tyml Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hookyns/tyml

0.0 0.0 0.0 105 KB

Library which is able to take YAML file in given format and process its instructions. It is like Your private local pipeline.

License: MIT License

C# 99.34% Batchfile 0.66%

tyml's Introduction

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

TymlContext tymlContext = new TymlContextBuilder()
    .AddTasks(typeof(CmdTask))
    .UseWorkingDirectory(path)
    .WithBaseVariables(new Dictionary<string, object>()
    {
        {"foo", 5},
        {"bar", "baz"}
    })
    .Build();
    
TymlExecutor tymlExecutor = provider.GetRequiredService<TymlExecutor>();
	
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

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<TInputs> 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<TOfInputObject>. 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.

[TymlTask("Cmd", "Optional task description")]
public class CmdTask : TaskBase<CmdTaskConfig>
{
	protected override Task<TaskCompletionStatus> 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();
	}
}

tyml's People

Contributors

hookyns avatar kosorin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.