Skip to content

Commit eee172b

Browse files
authored
Refactor/build scripts (#3636) (#3639)
* Move to BullsEye (cherry picked from commit 90f82a3) * scripts now a netcoreapp project and seems to compile, used hacks to get typeproviders happy (cherry picked from commit bfbb6e2) * created combined tasks (cherry picked from commit 3022fef) * played around with optional targets (cherry picked from commit ec6dc72) * Versioning refactor and args are typed and not passed around with getBuildParam (cherry picked from commit a815714) * Remove FAKE4, selectively depend on handy FAKE5 modules (cherry picked from commit 0dfc3d4) * update proc and prefer exec over start (cherry picked from commit c5eff44) * Differ and Cluster to separate files (cherry picked from commit 30c88fd) * Differ and Cluster separate, move remaining paket items over (cherry picked from commit c379a4b) * remove paket, now relying on the tools as DotNetCliTools (cherry picked from commit 4f46084) * update cluster command, handover from yaml to environment config now more explicit (cherry picked from commit d3ad1c8) * Pull ILRepack in and make sure its avabilable in ouput path thanks to new GeneratePathProperty (cherry picked from commit 189b256) * nuget.exe now pulled in though NuGet (cherry picked from commit bcc3148) * try to remove sn.exe and resolve it from SDK (cherry picked from commit 1254c8a) * DocGenerator run by referencing dll (cherry picked from commit 78f50b9) * make sure canary target works locally again (cherry picked from commit f8c110d) * make sure release command works (cherry picked from commit ffaa06b) * remove sn.exe from source control (cherry picked from commit 9c909d0) * fix IDE build on linux * update build.sh to use our build scripts location * update latest mono and sdk on build server, local build works so wondering if updating CI does the trick * update to latest mono and sdk fixed typeproviders yay, however took 16 minutes to pull down on azure pipelines. Rewrote global json handling without type providers * update path to global.json, json.net does not like private record types * Tests.Benchmarking needs conditional net461 TFM * update casing issues in the build * Working diff target (cherry picked from commit 5e858c5)
1 parent be73e36 commit eee172b

39 files changed

+1076
-2080
lines changed

.paket/Paket.Restore.targets

-363
This file was deleted.

.paket/paket.bootstrapper.exe

-62.8 KB
Binary file not shown.

NuGet.config

+2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
<packageSources>
44
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
55
<add key="Elastic Abstractions CI" value="https://ci.appveyor.com/nuget/elasticsearch-net-abstractions" />
6+
<add key="AssemblyRewriter" value="https://ci.appveyor.com/nuget/assemblyrewriter" />
7+
<add key="AssemblyDiffer" value="https://ci.appveyor.com/nuget/assemblydiffer" />
68
</packageSources>
79
</configuration>

build.bat

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,2 @@
11
@echo off
2-
3-
.paket\paket.bootstrapper.exe
4-
IF EXIST paket.lock (.paket\paket.exe restore)
5-
IF NOT EXIST paket.lock (.paket\paket.exe install)
6-
"packages\build\FAKE\tools\Fake.exe" "build\\scripts\\Targets.fsx" "cmdline=%*"
2+
dotnet run --project build/scripts -- %*

build.sh

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
#!/usr/bin/env bash
2-
FAKE="packages/build/FAKE/tools/FAKE.exe"
3-
BUILDSCRIPT="build/scripts/Targets.fsx"
4-
5-
mono .paket/paket.bootstrapper.exe
6-
if [[ -f paket.lock ]]; then mono .paket/paket.exe restore; fi
7-
if [[ ! -f paket.lock ]]; then mono .paket/paket.exe install; fi
8-
mono $FAKE $BUILDSCRIPT "cmdline=$*" --fsiargs -d:MONO
2+
set -euo pipefail
3+
dotnet run --project build/scripts -- "$@"

build/scripts/Benchmarking.fs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
namespace Scripts
2+
3+
open System.IO
4+
open Commandline
5+
6+
module Benchmarker =
7+
8+
let private testsProjectDirectory = Path.GetFullPath(Paths.TestsSource("Tests.Benchmarking"))
9+
10+
let Run args =
11+
12+
let url = match args.CommandArguments with | Benchmark b -> Some b.Endpoint | _ -> None
13+
let username = match args.CommandArguments with | Benchmark b -> b.Username | _ -> None
14+
let password = match args.CommandArguments with | Benchmark b -> b.Password | _ -> None
15+
let runInteractive = not args.NonInteractive
16+
let credentials = (username, password)
17+
let runCommandPrefix = "run -f netcoreapp2.1 -c Release"
18+
let runCommand =
19+
match (runInteractive, url, credentials) with
20+
| (false, Some url, (Some username, Some password)) -> sprintf "%s -- --all \"%s\" \"%s\" \"%s\"" runCommandPrefix url username password
21+
| (false, Some url, _) -> sprintf "%s -- --all \"%s\"" runCommandPrefix url
22+
| (false, _, _) -> sprintf "%s -- --all" runCommandPrefix
23+
| (true, _, _) -> runCommandPrefix
24+
25+
Tooling.DotNet.ExecIn testsProjectDirectory [runCommand] |> ignore

build/scripts/Benchmarking.fsx

-32
This file was deleted.

build/scripts/Building.fs

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
namespace Scripts
2+
3+
open System
4+
open System.IO
5+
6+
open FSharp.Data
7+
8+
open Paths
9+
open Projects
10+
open Tooling
11+
open Versioning
12+
open Fake.Core
13+
open Fake.IO
14+
open Commandline
15+
16+
module Build =
17+
18+
let Restore() = DotNet.Exec ["restore"; Solution; ] |> ignore
19+
20+
let Compile args (ArtifactsVersion(version)) =
21+
let sourceLink = if args.DoSourceLink then "1" else ""
22+
let props =
23+
[
24+
"CurrentVersion", (version.Full.ToString());
25+
"CurrentAssemblyVersion", (version.Assembly.ToString());
26+
"CurrentAssemblyFileVersion", (version.AssemblyFile.ToString());
27+
"DoSourceLink", sourceLink;
28+
"FakeBuild", "1";
29+
"OutputPathBaseDir", Path.GetFullPath Paths.BuildOutput;
30+
]
31+
|> List.map (fun (p,v) -> sprintf "%s=%s" p v)
32+
|> String.concat ";"
33+
|> sprintf "/property:%s"
34+
35+
DotNet.Exec ["build"; Solution; "-c"; "Release"; props] |> ignore
36+
37+
38+
let Clean () =
39+
printfn "Cleaning known output folders"
40+
Shell.cleanDir Paths.BuildOutput
41+
DotNet.Exec ["clean"; Solution; "-c"; "Release"] |> ignore
42+
DotNetProject.All |> Seq.iter(fun p -> Shell.cleanDir (Paths.BinFolder p.Name))
43+
44+

build/scripts/Building.fsx

-122
This file was deleted.

build/scripts/Cluster.fs

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
namespace Scripts
2+
3+
open System
4+
open System.IO
5+
open Fake.Core
6+
open Fake.IO
7+
open Commandline
8+
9+
module Cluster =
10+
11+
let Run args =
12+
let clusterName = Option.defaultValue "" <| match args.CommandArguments with | Cluster c -> Some c.Name | _ -> None
13+
let clusterVersion = Option.defaultValue "" <|match args.CommandArguments with | Cluster c -> c.Version | _ -> None
14+
15+
let testsProjectDirectory = Path.Combine(Path.GetFullPath(Paths.Output("Tests.ClusterLauncher")), "netcoreapp2.1")
16+
let tempDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
17+
18+
let sourceDir = Paths.Source("Tests/Tests.Configuration");
19+
let defaultYaml = Path.Combine(sourceDir, "tests.default.yaml");
20+
let userYaml = Path.Combine(sourceDir, "tests.yaml");
21+
let e f = File.Exists f;
22+
match ((e userYaml), (e defaultYaml)) with
23+
| (true, _) -> Environment.setEnvironVar "NEST_YAML_FILE" (Path.GetFullPath(userYaml))
24+
| (_, true) -> Environment.setEnvironVar "NEST_YAML_FILE" (Path.GetFullPath(defaultYaml))
25+
| _ -> failwithf "Expected to find a tests.default.yaml or tests.yaml in %s" sourceDir
26+
27+
printfn "%s" testsProjectDirectory
28+
29+
Shell.copyDir tempDir testsProjectDirectory (fun s -> true)
30+
31+
let command = sprintf "%s %s" clusterName clusterVersion
32+
let timeout = TimeSpan.FromMinutes(120.)
33+
let dll = Path.Combine(tempDir, "Tests.ClusterLauncher.dll");
34+
Tooling.DotNet.ExecInWithTimeout tempDir [dll; command] timeout |> ignore
35+
36+
Shell.deleteDir tempDir
37+

0 commit comments

Comments
 (0)