Skip to content

Commit

Permalink
Fix compile errors
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <tsfarr@amazon.com>
  • Loading branch information
Xtansia committed Jul 24, 2023
1 parent 4ee0394 commit d454abe
Showing 1 changed file with 88 additions and 85 deletions.
173 changes: 88 additions & 85 deletions build/scripts/Targets.fs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
namespace Scripts

open System
open System.Collections.Generic
open System.IO

open Bullseye
Expand All @@ -40,7 +41,7 @@ module Main =
let private target name action = Targets.Target(name, Action(action))
let private skip name = printfn "SKIPPED target '%s' evaluated not to run" name |> ignore
let private conditional name optional action = target name (if optional then action else (fun _ -> skip name))
let private command name dependencies action = Targets.Target(name, dependencies, Action(action))
let private command name (dependencies: IEnumerable<string>) action = Targets.Target(name, dependencies, Action(action))
let private conditionalCommand name dependencies optional action = command name dependencies (if optional then action else (fun _ -> skip name))

/// <summary>Sets command line environments indicating we are building from the command line</summary>
Expand All @@ -58,89 +59,91 @@ module Main =


let [<EntryPoint>] main args =
async {
do! Async.SwitchToThreadPool ()

setCommandLineEnvVars ()

let parsed = Commandline.parse (args |> Array.toList)

let buildVersions = Versioning.BuildVersioning parsed
let artifactsVersion = Versioning.ArtifactsVersion buildVersions
Versioning.Validate parsed.Target buildVersions

let isCanary = parsed.Target = "canary";

Tests.SetTestEnvironmentVariables parsed

let testChain = ["clean"; "version"; "restore"; "full-build"; ]
let buildChain = ["test"; "inherit-doc" ]
let releaseChain =
[
"build";
"nuget-pack";
"nuget-pack-versioned";
"validate-artifacts";
"generate-release-notes"
]
let canaryChain = [ "version"; "release"; "test-nuget-package";]

// the following are expected to be called as targets directly
conditional "clean" (parsed.ReleaseBuild || parsed.Target = "clean") <| fun _ -> Build.Clean parsed
target "version" <| fun _ -> printfn "Artifacts Version: %O" artifactsVersion

target "restore" Build.Restore
target "full-build" <| fun _ -> Build.Compile parsed artifactsVersion

//TEST
conditionalCommand "test" testChain (not parsed.SkipTests && not isCanary) <| fun _ -> Tests.RunUnitTests parsed

target "inherit-doc" <| InheritDoc.PatchInheritDocs

//BUILD
command "build" buildChain <| fun _ -> printfn "STARTING BUILD"

target "nuget-pack" <| fun _ -> Build.Pack artifactsVersion

conditional "nuget-pack-versioned" (isCanary) <| fun _ -> Build.VersionedPack artifactsVersion

conditional "generate-release-notes" (not isCanary) <| fun _ -> ReleaseNotes.GenerateNotes buildVersions

target "validate-artifacts" <| fun _ -> Versioning.ValidateArtifacts artifactsVersion

//RELEASE
command "release" releaseChain <| fun _ ->
let outputPath = match parsed.CommandArguments with | Commandline.SetVersion c -> c.OutputLocation | _ -> None
match outputPath with
| None ->
printfn "Finished Release Build %O, artifacts available at: %s" artifactsVersion Paths.BuildOutput
| Some path ->
Fake.IO.Shell.cp_r Paths.BuildOutput path
let zipName = sprintf "opencsearch-net-%O.zip" artifactsVersion.Full
let outputZip = Path.Combine(path, zipName)
let files = !! (sprintf "%s/*.*" path) -- outputZip
Fake.IO.Zip.createZip "." outputZip "opensearch-project/opensearch-net artifact" 9 true files
printfn "Finished Release Build %O, output copied to: %s" artifactsVersion path

conditional "test-nuget-package" (not parsed.SkipTests) <| fun _ -> Tests.RunReleaseUnitTests artifactsVersion parsed

//CANARY
command "canary" canaryChain <| fun _ -> printfn "Finished Release Build %O" artifactsVersion

// ADDITIONAL COMMANDS

command "cluster" [ "restore"; "full-build" ] <| fun _ ->
ReposTooling.LaunchCluster parsed

command "codegen" [ ] <| fun _ ->
ReposTooling.GenerateApi parsed.RemainingArguments

command "rest-spec-tests" [ ] <| fun _ ->
ReposTooling.RestSpecTests parsed.RemainingArguments

command "benchmark" [ "clean"; "full-build"; ] <| fun _ -> Benchmarker.Run parsed

command "integrate" [ "clean"; "restore"; "full-build";] <| fun _ -> Tests.RunIntegrationTests parsed

do! Targets.RunTargetsAndExitAsync([parsed.Target], (fun e -> e.GetType() = typeof<ProcExecException>)) |> Async.AwaitTask
} |> Async.RunSynchronously

setCommandLineEnvVars ()

let parsed = Commandline.parse (args |> Array.toList)

let buildVersions = Versioning.BuildVersioning parsed
let artifactsVersion = Versioning.ArtifactsVersion buildVersions
Versioning.Validate parsed.Target buildVersions

let isCanary = parsed.Target = "canary";

Tests.SetTestEnvironmentVariables parsed

let testChain = ["clean"; "version"; "restore"; "full-build"; ]
let buildChain = ["test"; "inherit-doc" ]
let releaseChain =
[
"build";
"nuget-pack";
"nuget-pack-versioned";
"validate-artifacts";
"generate-release-notes"
]
let canaryChain = [ "version"; "release"; "test-nuget-package";]

// the following are expected to be called as targets directly
conditional "clean" (parsed.ReleaseBuild || parsed.Target = "clean") <| fun _ -> Build.Clean parsed
target "version" <| fun _ -> printfn "Artifacts Version: %O" artifactsVersion

target "restore" Build.Restore
target "full-build" <| fun _ -> Build.Compile parsed artifactsVersion

//TEST
conditionalCommand "test" testChain (not parsed.SkipTests && not isCanary) <| fun _ -> Tests.RunUnitTests parsed

target "inherit-doc" <| InheritDoc.PatchInheritDocs

//BUILD
command "build" buildChain <| fun _ -> printfn "STARTING BUILD"

target "nuget-pack" <| fun _ -> Build.Pack artifactsVersion

conditional "nuget-pack-versioned" (isCanary) <| fun _ -> Build.VersionedPack artifactsVersion

conditional "generate-release-notes" (not isCanary) <| fun _ -> ReleaseNotes.GenerateNotes buildVersions

target "validate-artifacts" <| fun _ -> Versioning.ValidateArtifacts artifactsVersion

//RELEASE
command "release" releaseChain <| fun _ ->
let outputPath = match parsed.CommandArguments with | Commandline.SetVersion c -> c.OutputLocation | _ -> None
match outputPath with
| None ->
printfn "Finished Release Build %O, artifacts available at: %s" artifactsVersion Paths.BuildOutput
| Some path ->
Fake.IO.Shell.cp_r Paths.BuildOutput path
let zipName = sprintf "opencsearch-net-%O.zip" artifactsVersion.Full
let outputZip = Path.Combine(path, zipName)
let files = !! (sprintf "%s/*.*" path) -- outputZip
Fake.IO.Zip.createZip "." outputZip "opensearch-project/opensearch-net artifact" 9 true files
printfn "Finished Release Build %O, output copied to: %s" artifactsVersion path

conditional "test-nuget-package" (not parsed.SkipTests) <| fun _ -> Tests.RunReleaseUnitTests artifactsVersion parsed

//CANARY
command "canary" canaryChain <| fun _ -> printfn "Finished Release Build %O" artifactsVersion

// ADDITIONAL COMMANDS

command "cluster" [ "restore"; "full-build" ] <| fun _ ->
ReposTooling.LaunchCluster parsed

command "codegen" [ ] <| fun _ ->
ReposTooling.GenerateApi parsed.RemainingArguments

command "rest-spec-tests" [ ] <| fun _ ->
ReposTooling.RestSpecTests parsed.RemainingArguments

command "benchmark" [ "clean"; "full-build"; ] <| fun _ -> Benchmarker.Run parsed

command "integrate" [ "clean"; "restore"; "full-build";] <| fun _ -> Tests.RunIntegrationTests parsed

Targets.RunTargetsAndExit([parsed.Target], (fun e -> e.GetType() = typeof<ProcExecException>), ":")

0

0 comments on commit d454abe

Please sign in to comment.