Skip to content

Update proc to 0.9.0 #68

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ jobs:
git tag --list

# Install .NET version as mandated by global.json
- uses: actions/setup-dotnet@v3
- uses: actions/setup-dotnet@v4.1.0
with:
global-json-file: global.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

- run: ./build.sh build -s true
- run: ./build.sh test
name: Build
- run: ./build.sh generatepackages -s true
name: Generate local nuget packages
Expand Down
6 changes: 4 additions & 2 deletions build/scripts/CommandLine.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ open Microsoft.FSharp.Reflection
type Arguments =
| [<CliPrefix(CliPrefix.None);SubCommand>] Clean
| [<CliPrefix(CliPrefix.None);SubCommand>] Build

| [<CliPrefix(CliPrefix.None);SubCommand>] Test

| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] PristineCheck
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] GeneratePackages
| [<CliPrefix(CliPrefix.None);Hidden;SubCommand>] ValidatePackages
Expand All @@ -28,7 +29,8 @@ with
member this.Usage =
match this with
| Clean -> "clean known output locations"
| Build -> "Run build and tests"
| Build -> "Run build"
| Test -> "Run build and tests"
| Release -> "runs build, and create an validates the packages shy of publishing them"
| Publish -> "Runs the full release"

Expand Down
11 changes: 7 additions & 4 deletions build/scripts/Targets.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ open ProcNet


let exec binary args =
let r = Proc.Exec (binary, args |> List.map (fun a -> sprintf "\"%s\"" a) |> List.toArray)
match r.HasValue with | true -> r.Value | false -> failwithf "invocation of `%s` timed out" binary

Proc.Exec (binary, args |> List.toArray)

let private restoreTools = lazy(exec "dotnet" ["tool"; "restore"])
let private currentVersion =
lazy(
Expand All @@ -38,6 +37,9 @@ let private clean (arguments:ParseResults<Arguments>) =

let private build (arguments:ParseResults<Arguments>) = exec "dotnet" ["build"; "-c"; "Release"] |> ignore

//let private test (arguments:ParseResults<Arguments>) = exec "dotnet" ["test"; "-c"; "Release"; "-f"; "net6.0"] |> ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this commented line go?

let private test (arguments:ParseResults<Arguments>) = ignore()

let private pristineCheck (arguments:ParseResults<Arguments>) =
match Information.isCleanWorkingCopy "." with
| true -> printfn "The checkout folder does not have pending changes, proceeding"
Expand Down Expand Up @@ -142,7 +144,8 @@ let Setup (parsed:ParseResults<Arguments>) (subCommand:Arguments) =

step Clean.Name clean
cmd Build.Name None (Some [Clean.Name]) <| fun _ -> build parsed

cmd Test.Name None (Some [Build.Name]) <| fun _ -> test parsed

step PristineCheck.Name pristineCheck
step GeneratePackages.Name generatePackages
step ValidatePackages.Name validatePackages
Expand Down
2 changes: 1 addition & 1 deletion build/scripts/scripts.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ItemGroup>
<PackageReference Include="Argu" Version="6.0.0" />
<PackageReference Include="Bullseye" Version="3.3.0" />
<PackageReference Include="Proc" Version="0.6.2" />
<PackageReference Include="Proc" Version="0.9.1" />
<PackageReference Include="Fake.Tools.Git" Version="5.15.0" />
</ItemGroup>

Expand Down
2 changes: 1 addition & 1 deletion examples/ScratchPad/ScratchPad.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<IsPackable>False</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Proc" Version="0.6.1" />
<PackageReference Include="Proc" Version="0.9.1" />
<!--<ProjectReference Include="..\..\..\..\..\proc\src\Proc\Proc.csproj" />-->
<PackageReference Include="NEST" Version="6.0.1" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net462</TargetFrameworks>
<Description>Provides an EphemeralCluster implementation that can download/bootstrap/run a throwaway customizable Elasticsearch cluster</Description>
<PackageTags>elastic,elasticsearch,cluster,ephemeral</PackageTags>
</PropertyGroup>
Expand Down
5 changes: 3 additions & 2 deletions src/Elastic.Elasticsearch.Ephemeral/EphemeralFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ public EphemeralFileSystem(ElasticVersion version, string clusterName) : base(ve

protected static string EphemeralHome(ElasticVersion version, string clusterName)
{
var temp = Path.Combine(Path.GetTempPath(), SubFolder,
version.Artifact(Product.Elasticsearch).LocalFolderName, clusterName);
var artifact = version.Artifact(Product.Elasticsearch);
var localFolder = artifact.LocalFolderName;
var temp = Path.Combine(Path.GetTempPath(), SubFolder, localFolder, clusterName);
return Path.Combine(temp, "home");
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to improved readability here!

}
}
Expand Down
18 changes: 8 additions & 10 deletions src/Elastic.Elasticsearch.Ephemeral/Tasks/IClusterComposeTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,10 @@ protected static void WriteFileIfNotExist(string fileLocation, string contents)

protected static void ExecuteBinary(EphemeralClusterConfiguration config, IConsoleLineHandler writer,
string binary, string description, params string[] arguments) =>
ExecuteBinaryInternal(config, writer, binary, description, null, arguments);

protected static void ExecuteBinary(EphemeralClusterConfiguration config, IConsoleLineHandler writer,
string binary, string description, StartedHandler startedHandler, params string[] arguments) =>
ExecuteBinaryInternal(config, writer, binary, description, startedHandler, arguments);
ExecuteBinaryInternal(config, writer, binary, description, arguments);

private static void ExecuteBinaryInternal(EphemeralClusterConfiguration config, IConsoleLineHandler writer,
string binary, string description, StartedHandler startedHandler, params string[] arguments)
string binary, string description, params string[] arguments)
{
var command = $"{{{binary}}} {{{string.Join(" ", arguments)}}}";
writer?.WriteDiagnostic($"{{{nameof(ExecuteBinary)}}} starting process [{description}] {command}");
Expand All @@ -167,12 +163,14 @@ private static void ExecuteBinaryInternal(EphemeralClusterConfiguration config,
{
{config.FileSystem.ConfigEnvironmentVariableName, config.FileSystem.ConfigPath},
{"ES_HOME", config.FileSystem.ElasticsearchHome}
}
},
Timeout = timeout,
ConsoleOutWriter = new ConsoleOutColorWriter(),
};

var result = startedHandler != null
? Proc.Start(processStartArguments, timeout, new ConsoleOutColorWriter(), startedHandler)
: Proc.Start(processStartArguments, timeout, new ConsoleOutColorWriter());
writer.WriteDiagnostic($"{binary} {string.Join(" ", arguments)}");

var result = Proc.Start(processStartArguments);

if (!result.Completed)
throw new Exception($"Timeout while executing {description} exceeded {timeout}");
Expand Down
10 changes: 4 additions & 6 deletions src/Elastic.Elasticsearch.Managed/Configuration/NodeSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ namespace Elastic.Elasticsearch.Managed.Configuration
{
public class NodeSettings : List<NodeSetting>
{
private static readonly ElasticVersion
LastVersionWithoutPrefixForSettings = ElasticVersion.From("5.0.0-alpha2");

public NodeSettings()
{
}
Expand All @@ -37,8 +34,7 @@ public void Add(string key, string value, string versionRange) =>

public string[] ToCommandLineArguments(ElasticVersion version)
{
var settingsPrefix = version > LastVersionWithoutPrefixForSettings ? "" : "es.";
var settingArgument = version.Major >= 5 ? "-E " : "-D";
var settingArgument = "-E";
return this
//if a node setting is only applicable for a certain version make sure its filtered out
.Where(s => string.IsNullOrEmpty(s.VersionRange) || version.InRange(s.VersionRange))
Expand All @@ -47,7 +43,9 @@ public string[] ToCommandLineArguments(ElasticVersion version)
//on the command with the latter taking precedence
.GroupBy(setting => setting.Key)
.Select(g => g.Last())
.Select(s => s.Key.StartsWith(settingArgument) ? s.ToString() : $"{settingArgument}{settingsPrefix}{s}")
.SelectMany<NodeSetting, string>(
s => [settingArgument, $"{s}"]
)
.ToArray();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net462</TargetFrameworks>
<Description>
Provides an observable ElasticsearchNode abstraction that can be used to wrap an elasticsearch process.
Also ships with an cluster abstraction that can start one or more ElasticsearchNode's
</Description>
<PackageTags>elastic,elasticsearch,cluster,observable,rx</PackageTags>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Proc" Version="0.6.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Elastic.Stack.ArtifactsApi\Elastic.Stack.ArtifactsApi.csproj" />
<PackageReference Include="Proc" Version="0.9.1" />
</ItemGroup>
</Project>
12 changes: 9 additions & 3 deletions src/Elastic.Elasticsearch.Managed/ElasticsearchNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using Elastic.Elasticsearch.Managed.Configuration;
using Elastic.Elasticsearch.Managed.ConsoleWriters;
Expand Down Expand Up @@ -116,12 +117,17 @@ public IDisposable SubscribeLines(IConsoleLineHandler writer, Action<LineOut> on
var node = NodeConfiguration.DesiredNodeName;
writer?.WriteDiagnostic($"Elasticsearch location: [{Binary}]", node);
writer?.WriteDiagnostic($"Settings: {{{string.Join(" ", NodeConfiguration.CommandLineArguments)}}}", node);
writer?.WriteDiagnostic($"Environment: {{{string.Join(" ", StartArguments.Environment)}}}", node);
var envArgs = string.Join(" ", StartArguments.Environment.Select(kv => $"{kv.Key}={kv.Value}"));
writer?.WriteDiagnostic($"Full CMD: env {envArgs} {Binary} {string.Join(" ", NodeConfiguration.CommandLineArguments)} ", node);

var envVarName = NodeConfiguration.Version.InRange("<7.12.0") ? "JAVA_HOME" : "ES_JAVA_HOME";
var javaHome = Environment.GetEnvironmentVariable(envVarName);
writer?.WriteDiagnostic($"{envVarName}: {{{javaHome}}}", node);
Process.StartInfo.Environment[envVarName] = javaHome;

if (!string.IsNullOrWhiteSpace(javaHome))
{
writer?.WriteDiagnostic($"{envVarName}: {{{javaHome}}}", node);
Process.StartInfo.Environment[envVarName] = javaHome;
}
return SubscribeLines(
l =>
{
Expand Down
2 changes: 1 addition & 1 deletion src/Elastic.Stack.ArtifactsApi/ElasticVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public int CompareTo(string other)
public Artifact Artifact(Product product)
{
var cacheKey = product.ToString();
if (_resolved.TryGetValue(cacheKey, out var artifact))
if (_resolved.TryGetValue(cacheKey, out var artifact) && artifact != null)
return artifact;
switch (ArtifactBuildState)
{
Expand Down
Loading