Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
09f3178
Run a dependency with the value it was declared with
Mpdreamz Nov 12, 2026
c226611
Document that a dependency runs with the value it names
Mpdreamz Nov 12, 2026
e0902b6
Draw the plan with --graph, and list the run order in target help
Mpdreamz Nov 12, 2026
b85d642
Run a command's parallel stages side by side
Mpdreamz Nov 12, 2026
3dcae3d
Add conditions, ordering, cleanup and preconditions to every target s…
Mpdreamz Nov 12, 2026
8e2e6fb
Run several targets from one command line, and leave targets out with…
Mpdreamz Nov 12, 2026
44c3467
List the run switches in the generated wrappers
Mpdreamz Nov 12, 2026
75bf1c3
Teach the package skills the new target features
Mpdreamz Nov 12, 2026
cf94635
Stop and prefix F# sh commands in parallel stages
Mpdreamz Nov 12, 2026
77fed67
Merge remote-tracking branch 'origin/main' into make/dependency-values
Mpdreamz Nov 12, 2026
3933be8
Merge branch 'make/run-graph' into make/parallel
Mpdreamz Nov 12, 2026
8ab8ef0
Merge branch 'make/parallel' into make/modifiers
Mpdreamz Nov 12, 2026
0f224f4
Merge branch 'make/modifiers' into make/cli
Mpdreamz Nov 12, 2026
a9681b3
Merge branch 'make/dependency-values' into make/run-graph
Mpdreamz Nov 12, 2026
a1b6875
Merge branch 'make/cli' into make/gaps
Mpdreamz Nov 12, 2026
3f7a2a3
Format with curb 0.14.1
Mpdreamz Nov 12, 2026
ff05d77
Format with curb 0.14.1
Mpdreamz Nov 12, 2026
09465a0
Merge branch 'make/parallel' into make/modifiers
Mpdreamz Nov 12, 2026
0e3a8d6
Merge branch 'make/modifiers' into make/cli
Mpdreamz Nov 12, 2026
77a85a8
Merge branch 'make/cli' into make/gaps
Mpdreamz Nov 12, 2026
c233636
Merge remote-tracking branch 'origin/main' into make/run-graph
Mpdreamz Nov 12, 2026
151a6de
Merge branch 'make/run-graph' into make/parallel
Mpdreamz Nov 12, 2026
8d03e41
Merge branch 'make/parallel' into make/modifiers
Mpdreamz Nov 12, 2026
271f998
Merge branch 'make/modifiers' into make/cli
Mpdreamz Nov 12, 2026
2f4516c
Merge branch 'make/cli' into make/gaps
Mpdreamz Nov 12, 2026
9125590
Merge remote-tracking branch 'origin/main' into make/parallel
Mpdreamz Nov 12, 2026
de80887
Merge branch 'make/parallel' into make/modifiers
Mpdreamz Nov 12, 2026
ef2670b
Merge branch 'make/modifiers' into make/cli
Mpdreamz Nov 12, 2026
dd673b8
Merge branch 'make/cli' into make/gaps
Mpdreamz Nov 12, 2026
533f290
Merge remote-tracking branch 'origin/main' into make/modifiers
Mpdreamz Nov 12, 2026
7a5dbf9
Merge branch 'make/modifiers' into make/cli
Mpdreamz Nov 12, 2026
f650e8e
Merge branch 'make/cli' into make/gaps
Mpdreamz Nov 12, 2026
f01bf9b
Merge remote-tracking branch 'origin/main' into make/cli
Mpdreamz Nov 12, 2026
dcd5ea0
Merge branch 'make/cli' into make/gaps
Mpdreamz Nov 12, 2026
97c608a
Merge remote-tracking branch 'origin/main' into make/gaps
Mpdreamz Nov 12, 2026
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
4 changes: 2 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<PackageVersion Include="MinVer" Version="8.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.9.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="5.9.0" />
<PackageVersion Include="Proc" Version="0.21.0" />
<PackageVersion Include="Proc.Fs" Version="0.21.0" />
<PackageVersion Include="Proc" Version="0.22.0" />
<PackageVersion Include="Proc.Fs" Version="0.22.0" />
<PackageVersion Include="FSharp.Core" Version="11.0.101" />
<!-- netstandard2.0 only -->
<PackageVersion Include="System.Memory" Version="4.6.3" />
Expand Down
5 changes: 5 additions & 0 deletions docs/make/mise.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ run = "dotnet run build.cs -- pkg generate"
usage = '''
flag "--configuration <configuration>" help="string (default: Release)"
flag "-s --single-target" help="Skip prerequisite deps; run only the body / Composes"
flag "--graph" help="Draw what would run and run nothing: tree, mermaid or json"
flag "-j --jobs <jobs>" help="How many targets may run at once (default: one per processor)"
flag "-k --keep-going" help="After a failure, finish the targets that do not depend on it"
flag "--output <output>" help="Output of targets running side by side: prefixed or grouped"
flag "--skip <skip>" help="Leave a target out of the plan, with what only it needed"
'''
```

Expand Down
9 changes: 3 additions & 6 deletions docs/make/parallel.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

F#, in a `command { }` block, where the operation is `concurrently` because F# reserves `parallel`:

```fsharp

Check warning on line 26 in docs/make/parallel.md

View workflow job for this annotation

GitHub Actions / docs

Unknown language: fsharp
| Release -> command {
requires [Test { Filter = None }]
concurrently [Pkg Generate; Docs Build; Docker Image]
Expand Down Expand Up @@ -55,7 +55,7 @@

A target body stops when it is cancelled only if it watches for it:

- `Shell.Exec` watches for it, and stops the process it started.
- `Shell.Exec` in C#, and `sh` in an F# `target { }` block, watch for it and stop the process they started.
- An async body can take the token: `app.Target(async ct => await Task.Delay(1000, ct))`, or read
`MakeContext.Current.CancellationToken`.

Expand Down Expand Up @@ -85,11 +85,8 @@
terminal, so a tool that colours only for a terminal prints without colour. A run with one job, or without a parallel
stage, leaves every command on the console as before.

:::{note}
In F#, `sh` commands inside a `target { }` block run on the console, not through the target's lines, and a failure
elsewhere does not stop them. `printfn` and other `Console` output is prefixed. A parallel F# target finishes the
command it is running when the run stops, and then starts no more.
:::
In F#, the `sh` commands of a `target { }` block running side by side do the same: their lines carry the target's
name, and a failure elsewhere stops them. The `shell { }` inside a command's `executes (...)` runs on the console.

## Build options with the same name

Expand Down
11 changes: 10 additions & 1 deletion src/Nullean.Make.Fs/Builders.fs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,16 @@ type TargetBuilder<'TCase>(dependsOn: 'TCase list, hidden: bool) =
member _.TryWith(body: ShellStep<'T>, handler: exn -> ShellStep<'T>) = shell.TryWith(body, handler)
member _.TryFinally(body: ShellStep<'T>, compensation: unit -> unit) = shell.TryFinally(body, compensation)
member _.Using(resource: 'R :> IDisposable, body: 'R -> ShellStep<'T>) = shell.Using(resource, body)
member _.Run(step: ShellStep<unit>) : Definition<'TCase> = FsTarget("", dependsOn, (fun _ -> shell.Run step), hidden)
member _.Run(step: ShellStep<unit>) : Definition<'TCase> =
FsTarget("", dependsOn, (fun _ -> shell.Run(step, TargetBuilder<'TCase>.Token())), hidden)

/// While targets run side by side, the run's token: a failure elsewhere stops the block, and its commands print
/// through Console.Out, where each line gets the target's name. Otherwise none, so commands keep the console.
static member internal Token() =
match Nullean.Make.MakeContext.Current with
| null -> Threading.CancellationToken.None
| ctx when isNull ctx.Sink -> Threading.CancellationToken.None
| ctx -> ctx.CancellationToken

/// What a <c>command { }</c> block collects: its requires, its composed stages in order and an optional body.
[<NoComparison; NoEquality>]
Expand Down
3 changes: 2 additions & 1 deletion src/Nullean.Make.Fs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ they are written:
```

`-j` / `--jobs` caps how many targets run at once, and `-k` / `--keep-going` lets the targets that do not depend on a
failure finish. `printfn` output of targets running side by side carries their names; `sh` commands keep the console.
failure finish. Output of targets running side by side, `sh` commands included, carries their names, and a failure
stops the `sh` commands still running.
See [Running targets side by side](https://argh.nullean.net/make/parallel).

`executes (...)` adds a body that runs after every composed target. Like a target block, it is deferred. Use `shell { }` inside it to run commands:
Expand Down
4 changes: 2 additions & 2 deletions src/Nullean.Make.Fs/skills/nullean-make-fs/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ let main argv =
- A dependency can name a payload, `Test { Filter = Some "Unit" }`: the target runs with it. Equal payloads run once,
different payloads once each. Only the named target binds the command line.
- `concurrently [A; B]` in a `command { }` block is a stage that runs side by side (F# reserves `parallel`); stages
run in the order written. `-j N` caps targets at once and `-k` keeps going after a failure. `printfn` output is
prefixed with the target's name; `sh` output keeps the console and is not cancelled.
run in the order written. `-j N` caps targets at once and `-k` keeps going after a failure. Output, `sh` included, is
prefixed with the target's name, and a failure elsewhere stops a running `sh`.
- Pipe a definition through `onlyWhen (fun () -> ...)`, `after [Lint]`, `cleanup [StopDb]`, `needsEnv ["KEY"]`,
`needsTool ["docker"]` and `describe "..."`.
- `build release --graph` (or `--graph mermaid|json`) draws the plan, skipped targets included, and runs nothing.
Expand Down
13 changes: 12 additions & 1 deletion src/Nullean.Make/Wrappers/WrapperModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,18 @@ public static WrapperModel From(BuildGraph graph, string run, string? prefix)
.Select(t => new WrapperTarget(t.Route, OneLine(t.Description), t.DtoType is null ? Array.Empty<DtoOption>() : DtoOptions.Describe(t.DtoType)))
.ToList();

var options = new List<WrapperOption> { new("--single-target", "-s", "Skip prerequisite deps; run only the body / Composes", true, "bool"), };
// The switches every Make script reads. A build option with the same short name keeps it, as on the command line.
string? Short(string name) => graph.GlobalOptions.Any(o => o.Short?.TrimStart('-') == name.TrimStart('-')) ? null : name;

var options = new List<WrapperOption>
{
new("--single-target", "-s", "Skip prerequisite deps; run only the body / Composes", true, "bool"),
new("--graph", null, "Draw what would run and run nothing: tree, mermaid or json", true, "bool"),
new("--jobs", Short("-j"), "How many targets may run at once (default: one per processor)", false, "int"),
new("--keep-going", Short("-k"), "After a failure, finish the targets that do not depend on it", true, "bool"),
new("--output", null, "Output of targets running side by side: prefixed or grouped", false, "string"),
new("--skip", null, "Leave a target out of the plan, with what only it needed", false, "string"),
};
foreach (var o in graph.GlobalOptions)
{
var valueType = o.Property?.PropertyType ?? o.ValueType;
Expand Down
54 changes: 54 additions & 0 deletions tests/Nullean.Make.Fs.Tests/ParallelTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ open System.Threading
open System.Collections.Concurrent
open TUnit.Core
open Nullean.Make.Fs
open Proc.Fs

type Side =
| Left
Expand Down Expand Up @@ -59,3 +60,56 @@ type ParallelTests() =
member _.``Graph draws the parallel stage``() =
let _, _, stdout = run ["both"; "--graph"]
Assert.Contains("parallel", stdout)

type Shelled =
| Version
| Sleeper
| Breaker
| Quiet
| Pair
| Doomed

/// A command that runs for half a minute, on every OS the tests run on.
let private longCommand () =
if OperatingSystem.IsWindows() then "ping", [ "-n"; "30"; "127.0.0.1" ] else "sleep", [ "30" ]

let private runShelled (args: string list) =
let log = ConcurrentQueue<string>()
let app = MakeApp<Shelled>("build", None)
let binary, longArgs = longCommand ()
app.Bind <| function
| Version -> target [] { sh $"dotnet --version" }
| Sleeper -> target [] {
sh $"{binary} {longArgs}"
log.Enqueue "sleeper:done" }
| Breaker -> target [] { failBuild "broken on purpose" }
| Quiet -> target [] { printfn "quiet" }
| Pair -> command { concurrently [Version; Quiet] }
| Doomed -> command { concurrently [Sleeper; Breaker] }
let stdout = new StringWriter()
let oldOut, oldErr = Console.Out, Console.Error
Console.SetOut stdout
Console.SetError(new StringWriter())
let watch = Diagnostics.Stopwatch.StartNew()
try
let exit = app.RunAsync(List.toArray args).GetAwaiter().GetResult()
exit, List.ofSeq log, string stdout, watch.Elapsed
finally
Console.SetOut oldOut
Console.SetError oldErr

[<NotInParallel>]
type ParallelShellTests() =

[<Test>]
member _.``sh output of a target running side by side carries its name``() =
let _, _, stdout, _ = runShelled ["pair"; "-j"; "2"]
let lines = stdout.Split('\n') |> Array.map (fun l -> l.Trim())
Assert.Equal(true, lines |> Array.exists (fun l -> l.StartsWith "[version] " && Char.IsDigit l.["[version] ".Length]))

[<Test>]
member _.``a failure elsewhere stops a running sh command``() =
let exit, log, _, elapsed = runShelled ["doomed"; "-j"; "2"]
Assert.Equal(1, exit)
Assert.Equal<string list>([], log)
Assert.Equal(true, elapsed < TimeSpan.FromSeconds 20.)
34 changes: 34 additions & 0 deletions tests/Nullean.Make.Tests/WrapperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ public class Schema : Namespace
}

/// <summary><c>schema-update</c> and <c>schema update</c> are distinct targets but the same just recipe name.</summary>
public class KeepBuild : MakeBuild
{
[Flag("--keep", "-k", Description = "Keep the output")]
public bool Keep { get; init; }

public Target Clean =>
_ => _.Executes(() =>
{ });
}

public class ClashingWrapperBuild : MakeBuild
{
public Target SchemaUpdate =>
Expand Down Expand Up @@ -93,6 +103,15 @@ public void Dispose()

""";

[Test]
public async Task A_build_option_with_the_same_short_name_keeps_it_in_the_mise_include()
{
var (exit, _, stderr) = await RunAsync<KeepBuild>("sync", "--run", "dotnet run build.cs --", "--only", "mise");
exit.Should().Be(0, stderr);
var text = FileText("mise-tasks.toml");
text.Should().Contain("flag \"--keep-going\" help=").And.Contain("flag \"-k --keep\"");
}

[Test]
public async Task Sync_writes_the_mise_include()
{
Expand All @@ -111,6 +130,11 @@ public async Task Sync_writes_the_mise_include()
run = "dotnet run build.cs -- clean"
usage = '''
flag "-s --single-target" help="Skip prerequisite deps; run only the body / Composes"
flag "--graph" help="Draw what would run and run nothing: tree, mermaid or json"
flag "-j --jobs <jobs>" help="How many targets may run at once (default: one per processor)"
flag "-k --keep-going" help="After a failure, finish the targets that do not depend on it"
flag "--output <output>" help="Output of targets running side by side: prefixed or grouped"
flag "--skip <skip>" help="Leave a target out of the plan, with what only it needed"
flag "-c --clean-checkout" help="Skip the clean-checkout guard"
'''

Expand All @@ -123,6 +147,11 @@ public async Task Sync_writes_the_mise_include()
flag "--no-restore" help="bool (default: False)"
arg "[project]" help="string (default: null)"
flag "-s --single-target" help="Skip prerequisite deps; run only the body / Composes"
flag "--graph" help="Draw what would run and run nothing: tree, mermaid or json"
flag "-j --jobs <jobs>" help="How many targets may run at once (default: one per processor)"
flag "-k --keep-going" help="After a failure, finish the targets that do not depend on it"
flag "--output <output>" help="Output of targets running side by side: prefixed or grouped"
flag "--skip <skip>" help="Leave a target out of the plan, with what only it needed"
flag "-c --clean-checkout" help="Skip the clean-checkout guard"
'''

Expand All @@ -132,6 +161,11 @@ public async Task Sync_writes_the_mise_include()
run = "dotnet run build.cs -- schema update"
usage = '''
flag "-s --single-target" help="Skip prerequisite deps; run only the body / Composes"
flag "--graph" help="Draw what would run and run nothing: tree, mermaid or json"
flag "-j --jobs <jobs>" help="How many targets may run at once (default: one per processor)"
flag "-k --keep-going" help="After a failure, finish the targets that do not depend on it"
flag "--output <output>" help="Output of targets running side by side: prefixed or grouped"
flag "--skip <skip>" help="Leave a target out of the plan, with what only it needed"
flag "-c --clean-checkout" help="Skip the clean-checkout guard"
'''

Expand Down
Loading