Skip to content
Merged
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
Empty file modified build.sh
100644 → 100755
Empty file.
44 changes: 0 additions & 44 deletions build/Elastic.CommonSchema.Serilog.nuspec

This file was deleted.

34 changes: 0 additions & 34 deletions build/Elastic.CommonSchema.nuspec

This file was deleted.

5 changes: 0 additions & 5 deletions build/scripts/Building.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
open System.IO

open Paths
open Projects
open Tooling
open Versioning
open Fake.Core
Expand All @@ -15,14 +14,11 @@ module Build =
let Restore() = DotNet.Exec ["restore"; Solution; ] |> ignore

let Compile args (ArtifactsVersion(version)) =
let sourceLink = if args.DoSourceLink then "1" else ""
let props =
[
"CurrentVersion", (version.Full.ToString());
"CurrentAssemblyVersion", (version.Assembly.ToString());
"CurrentAssemblyFileVersion", (version.AssemblyFile.ToString());
"DoSourceLink", sourceLink;
"FakeBuild", "1";
"OutputPathBaseDir", Path.GetFullPath Paths.BuildOutput;
]
|> List.map (fun (p,v) -> sprintf "%s=%s" p v)
Expand All @@ -35,4 +31,3 @@ module Build =
printfn "Cleaning known output folders"
Shell.cleanDir Paths.BuildOutput
DotNet.Exec ["clean"; Solution; "-c"; "Release"] |> ignore
DotNetProject.All |> Seq.iter(fun p -> Shell.cleanDir (Paths.BinFolder p.Name))
5 changes: 3 additions & 2 deletions build/scripts/Commandline.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Targets:
- default target if non provided.
* clean
- cleans build output folders
* tests
- tests all the projects under /tests
* release <version>
- 0 create a release worthy nuget packages for [version] under build\output
* canary
Expand All @@ -39,7 +41,6 @@ Targets:
ValidMonoTarget: bool;
NeedsFullBuild: bool;
NeedsClean: bool;
DoSourceLink: bool;

CommandArguments: CommandArguments;
}
Expand Down Expand Up @@ -75,7 +76,6 @@ Targets:
| ("diff") -> false
| _ -> true;
CommandArguments = Unknown
DoSourceLink = false
}

let arguments =
Expand All @@ -88,6 +88,7 @@ Targets:
match arguments with
| [] | ["build"] | ["clean"] | ["touch"; ] | ["temp"; ] | ["canary"; ] -> parsed
| "diff" :: tail -> { parsed with RemainingArguments = tail }
| "test" :: tail -> { parsed with RemainingArguments = tail }
| ["release"; version] -> { parsed with CommandArguments = SetVersion { Version = version } }

| _ ->
Expand Down
24 changes: 2 additions & 22 deletions build/scripts/Paths.fs
Original file line number Diff line number Diff line change
@@ -1,36 +1,16 @@
namespace Scripts

open Projects

module Paths =

let OwnerName = "elastic"
let RepositoryName = "ecs-dotnet"
let Repository = sprintf "https://github.com/%s/%s" OwnerName RepositoryName

let BuildFolder = "build"
let private buildFolder = "build"
let TargetsFolder = "build/scripts"
let BuildOutput = sprintf "%s/output" BuildFolder

let ProjectOutputFolder (project:DotNetProject) (framework:DotNetFramework) =
sprintf "%s/%s/%s" BuildOutput project.Name framework.Identifier.Nuget

let Tool tool = sprintf "packages/build/%s" tool
let CheckedInToolsFolder = "build/tools"
let KeysFolder = sprintf "%s/keys" BuildFolder
let NugetOutput = sprintf "%s/_packages" BuildOutput
let SourceFolder = "src"
let BuildOutput = sprintf "%s/output" buildFolder

let Solution = "src/ecs-dotnet.sln"

let CheckedInTool(tool) = sprintf "%s/%s" CheckedInToolsFolder tool
let Keys(keyFile) = sprintf "%s/%s" KeysFolder keyFile
let Output(folder) = sprintf "%s/%s" BuildOutput folder
let Source(folder) = sprintf "%s/%s" SourceFolder folder

let ProjFile(project:DotNetProject) =
sprintf "%s/%s/%s.csproj" SourceFolder project.Name project.Name

let BinFolder (folder:string) =
let f = folder.Replace(@"\", "/")
sprintf "%s/%s/bin/Release" SourceFolder f
63 changes: 0 additions & 63 deletions build/scripts/Projects.fs

This file was deleted.

69 changes: 9 additions & 60 deletions build/scripts/Releasing.fs
Original file line number Diff line number Diff line change
@@ -1,67 +1,16 @@
namespace Scripts

open System
open System.IO
open System.Linq
open System.Text
open System.Xml
open System.Xml.Linq
open System.Xml.XPath
open Fake.Core;

open Projects
open Versioning

module Release =

let private year = sprintf "%i" DateTime.UtcNow.Year

let private addKeyValue key value (builder:StringBuilder) =
if (not (String.IsNullOrEmpty value)) then builder.AppendFormat("{0}=\"{1}\";", key, value)
else builder

let private currentMajorVersion version = sprintf "%i" <| version.Full.Major
let private nextMajorVersion version = sprintf "%i" <| version.Full.Major + 1u

let private props version =
let currentMajorVersion = currentMajorVersion version
let nextMajorVersion = nextMajorVersion version
new StringBuilder()
|> addKeyValue "currentMajorVersion" currentMajorVersion
|> addKeyValue "nextMajorVersion" nextMajorVersion
|> addKeyValue "year" year

let pack file n properties version =
Tooling.Nuget.Exec [ "pack"; file;
"-version"; version.Full.ToString();
"-outputdirectory"; Paths.BuildOutput;
"-properties"; properties;
let NugetPack (ArtifactsVersion(version)) =

Tooling.DotNet.ExecIn "src" [ "pack";
"-c"; "Release";
(sprintf "-p:Version=%s" <| version.Full.ToString());
(sprintf "-p:CurrentVersion=%s" <| version.Full.ToString());
(sprintf "-p:CurrentAssemblyVersion=%s" <| version.Assembly.ToString());
(sprintf "-p:CurrentAssemblyFileVersion=%s" <| version.AssemblyFile.ToString());
"--output"; (sprintf "../%s" <| Paths.BuildOutput)
] |> ignore
printfn "%s" Paths.BuildOutput
let file = sprintf "%s.%O.nupkg" n version.Full
let nugetOutFile = Paths.Output(file)
let outputFile = Path.Combine(Paths.NugetOutput, file)

File.Move(nugetOutFile, outputFile)

let private nugetPackMain (_:DotNetProject) nugetId nuspec properties version =
pack nuspec nugetId properties version

let private packProjects version callback =
Directory.CreateDirectory Paths.NugetOutput |> ignore

DotNetProject.AllPublishable
|> Seq.iter(fun p ->

let properties =
props version
|> StringBuilder.toText

let nugetId = p.NugetId
let nuspec = (sprintf @"build/%s.nuspec" nugetId)

callback p nugetId nuspec properties version
)

let NugetPack (ArtifactsVersion(version)) = packProjects version nugetPackMain

4 changes: 3 additions & 1 deletion build/scripts/Targets.fs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ module Main =

// the following are expected to be called as targets directly
let buildChain = [
"clean"; "version"; "restore"; "full-build";
"clean"; "version"; "restore"; "full-build"; "test"
]
command "build" buildChain <| fun _ -> printfn "STARTING BUILD"

target "test" <| fun _ -> Tests.TestAll artifactsVersion

command "canary" [ "version"; "release";] <| fun _ -> printfn "Finished Release Build %O" artifactsVersion

Expand Down
42 changes: 42 additions & 0 deletions build/scripts/Testing.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
namespace Scripts

open System
open Tooling
open Fake.Core
open Fake.IO.Globbing.Operators
open System.IO
open Commandline
open Versioning

module Tests =

let TestAll (ArtifactsVersion(version)) =
Directory.CreateDirectory Paths.BuildOutput |> ignore
let command =
let p = [
"test"; "."; "-c"; "RELEASE";
(sprintf "-p:Version=%s" <| version.Full.ToString());
]
//make sure we only test netcoreapp on linux or requested on the command line to only test-one
match Environment.isLinux with
| true ->
printfn "Running on linux defaulting tests to .NET Core only"
["--framework"; "netcoreapp3.0"] |> List.append p
| _ -> p
let commandWithCodeCoverage =
// TODO /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura
// Using coverlet.msbuild package
// https://github.com/tonerdo/coverlet/issues/110
// Bites us here as well a PR is up already but not merged will try again afterwards
// https://github.com/tonerdo/coverlet/pull/329
match false with
| true -> [ "--logger"; "trx"; "--collect"; "\"Code Coverage\""; "-v"; "m"] |> List.append command
| _ -> command

let testProjects = !! "tests/**/*.csproj"

for projectFile in testProjects do
let folder = (FileInfo projectFile).Directory.FullName
printfn "Running tests in %s" folder

Tooling.DotNet.ExecInWithTimeout folder commandWithCodeCoverage (TimeSpan.FromMinutes 30.)
Loading