Code Monkey home page Code Monkey logo

Comments (10)

premun avatar premun commented on May 27, 2024 1

Nice! These make sense:

  • Id validation can happen for strings too
  • Strong-typed logic operators are also nice!

I updated the description.

I am not sure about whether mixing fluent with declaration wouldn't be beneficial (Trigger().Batched()). Maybe not for those ones but I can imagine for example:

{
    Variable("Configuration", "Release").Readonly(),
    Variable("DOTNET_SKIP_FIRST_TIME_EXPERIENCE", true),
}

from sharpliner.

mandel-macaque avatar mandel-macaque commented on May 27, 2024 1

I'd go for less typing, also, we can let people define several pipelines if needed and reference them as resources (yes, is a thing and very useful).

from sharpliner.

mandel-macaque avatar mandel-macaque commented on May 27, 2024

Comments about the above:

Triggers

I would go the declarative way form

Trigger = Trigger.ForBranch("main", "production").Batch().Exclude("tools/*"),

to

Trigger = {
    new {
        Branch = {"main", "production"}
        IsBatch = true,
       Exclude = { "tools/*" }
   },
}

Also, should be a collection, we can have more than one trigger AFAIK

PRs

Same comment as with triggers.

Variables

I LOVE this syntax:

If("eq(variables['Build.Reason'], 'PullRequest')")
                .Variable("TargetBranch", "$(System.PullRequest.SourceBranch)"),

But I think we should do the following, add the basic conditions in the yaml, there are not than many AND we can be able o validate them:

If.Eq(Variable("Name"), "MyValue")
    .Variable("TargetBranch", "$(System.PullRequest.SourceBranch)")

Job

I don't get the idea of the Id, is it really needed if we do static validations?

The rest looks good to me.

from sharpliner.

mandel-macaque avatar mandel-macaque commented on May 27, 2024

Yes! We need to find the right balance between the two approaches. I think that adjectives should be all fluent, while properties should all be declarative even if optional. Then use declarative for all conditions. The question is what reads better:

If().Equals("varname", "value")
    .Variable("conditionalVar","value");

Or

If(Equals("varname", "value"))
    .Variable("condition","value");

I'm going for the second one, because with complex expressions it looks shorter/nicer:

If(And(Equals("var", "value"),Equals("var","value")))
    .Variable("var","value");

We should look at Nunit and xUnit for ideas since they have a lot of assertions and more experience. I think with some smart use of genetics this will me very doable.

PS: I think will be shorter because the concatenation of several ands would be very verbose

from sharpliner.

mandel-macaque avatar mandel-macaque commented on May 27, 2024

Also, thinking about serialization, 2 is closer to the one used by yaml

from sharpliner.

premun avatar premun commented on May 27, 2024

👍 Makes sense with adjectives
👍 Second one looks almost like YAML so yeah, let's do that one

from sharpliner.

premun avatar premun commented on May 27, 2024

@mandel-macaque another idea:

We could move the top level properties of the Pipeline POCO to the PipelineDefinition class itself and the user would override those. Rather than having:

    protected override Pipeline Pipeline => new()
    {
        Name = "$(Date:yyyMMdd).$(Rev:rr)",

        Variables = new[]
        {
            Variable("Configuration", "Release"),
        },
    }

you would do

    protected override string Name => "$(Date:yyyMMdd).$(Rev:rr)";

    protected override IEnumerable<Variable> Variables => new[]
    {
        Variable("Configuration", "Release"),
    };

But I guess that will be more confusing? I guess it's more typing..

from sharpliner.

premun avatar premun commented on May 27, 2024

I have the API for variable definition ready but I will be moving rooms this weekend so I might be offline.

If you want to have a look or work on top of that it's in the api branch in my fork:
https://github.com/premun/sharpliner/blob/prvysoky/api/tests/Sharpliner.Serialization.Tests/MockPipeline.cs

The whole API now works for VariableDefinition but it can be made generic and applied to steps/jobs too

from sharpliner.

premun avatar premun commented on May 27, 2024

I have this for nested ifs:

image

from sharpliner.

premun avatar premun commented on May 27, 2024

Closing as it was implemented already in #14 and #15

from sharpliner.

Related Issues (20)

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.