Skip to content
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

Revert fsi exe in fake deploy #653

Merged
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
2 changes: 1 addition & 1 deletion src/app/FAKE/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ try

//TODO if printDetails then printEnvironment cmdArgs args

if not (runBuildScriptWithFsiArgsAt "" printDetails fsiArgs envVars) then Environment.ExitCode <- 1
if not (runBuildScriptWithFsiArgsAt printDetails fsiArgs envVars) then Environment.ExitCode <- 1
else if printDetails then log "Ready."

()
Expand Down
11 changes: 4 additions & 7 deletions src/app/Fake.Deploy/DeploymentAgent.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

open System
open System.IO
open System.Net
open System.Threading
open System.Diagnostics
open Fake
open Fake.DeploymentHelper
open Fake.DeployAgentModule
open Fake.HttpListenerHelper
open Nancy
open Nancy.Hosting.Self
open Nancy.Security
Expand All @@ -30,7 +27,7 @@ let runDeployment workDir (ctx : Nancy.Request) =
let packageBytes = getBodyFromNancyRequest ctx
let package, scriptFile = unpack workDir false packageBytes
let scriptArguments = getScriptArgumentsFromNancyRequest ctx
let response = doDeployment package.Name scriptFile scriptArguments
let response = doDeployment scriptFile scriptArguments
match response with
| FakeDeployAgentHelper.Success _ ->
logger (sprintf "Successfully deployed %s %s" package.Id package.Version, EventLogEntryType.Information)
Expand Down Expand Up @@ -62,10 +59,10 @@ type DeployAgentModule() as http =
http.RequiresAuthentication()


http.post "/" (fun p ->
http.post "/" (fun _ ->
runDeployment workDir http.Request)

http.get "/deployments/" (fun p ->
http.get "/deployments/" (fun _ ->
let status = http.Request.Query ?> "status"
match status with
| "active" -> getActiveReleases workDir
Expand All @@ -92,4 +89,4 @@ type DeployAgentModule() as http =
.AsJson result
)

http.get "/statistics/" (fun p -> getStatistics() |> http.Response.AsJson)
http.get "/statistics/" (fun _ -> getStatistics() |> http.Response.AsJson)
18 changes: 7 additions & 11 deletions src/app/Fake.Deploy/DeploymentHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
module Fake.DeploymentHelper

open System
open System.Configuration
open System.IO
open System.Net
open Fake.FakeDeployAgentHelper

/// Allows to specify a deployment version
Expand Down Expand Up @@ -72,12 +70,10 @@ let unpack workDir isRollback packageBytes =
package, scriptFile

/// Runs a deployment script from the given package
let doDeployment packageName scriptFileName scriptArgs =
let doDeployment scriptFileName scriptArgs =
try
TargetHelper.reset()
let workingDirectory = DirectoryName scriptFileName
let (result, messages) =
FSIHelper.executeBuildScriptWithArgsAndReturnMessages workingDirectory (FullName scriptFileName) scriptArgs
let (result, messages) = FSIHelper.executeFSIWithScriptArgsAndReturnMessages (FullName scriptFileName) scriptArgs
if result then
Success { Messages = messages
IsError = false
Expand All @@ -96,8 +92,8 @@ let doDeployment packageName scriptFileName scriptArgs =
let runDeploymentFromPackageFile workDir packageFileName scriptArgs =
try
let packageBytes = ReadFileAsBytes packageFileName
let package, scriptFile = unpack workDir false packageBytes
doDeployment package.Name scriptFile scriptArgs
let _, scriptFile = unpack workDir false packageBytes
doDeployment scriptFile scriptArgs
with e ->
Failure { Messages = Seq.empty
IsError = true
Expand All @@ -113,10 +109,10 @@ let rollback workDir (app : string) (version : string) =
IsError = true
Exception = (Exception "Cannot rollback to currently active version") }
else
let package, scriptFile = unpack workDir true (backupPackageFileName |> ReadFileAsBytes)
doDeployment package.Name scriptFile [||]
let _, scriptFile = unpack workDir true (backupPackageFileName |> ReadFileAsBytes)
doDeployment scriptFile [||]
with
| :? FileNotFoundException as e ->
| :? FileNotFoundException ->
let msg =
sprintf
"Failed to rollback to %s %s could not find package file or deployment script file ensure the version is within the backup directory and the deployment script is in the root directory of the *.nupkg file"
Expand Down
19 changes: 9 additions & 10 deletions src/app/FakeLib/FSIHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module Fake.FSIHelper

open System
open System.IO
open System.Linq
open System.Diagnostics
open System.Threading

Expand Down Expand Up @@ -78,7 +77,7 @@ let executeFSIWithArgs workingDirectory script extraFsiArgs args =
result = 0

/// Run the given build script with fsi.exe and allows for extra arguments to the script. Returns output.
let executeFSIWithScriptArgsAndReturnMessages workingDirectory script (scriptArgs: string[]) =
let executeFSIWithScriptArgsAndReturnMessages script (scriptArgs: string[]) =
let (result, messages) =
ExecProcessRedirected (fun si ->
FsiStartInfo "" (FsiArgs([], script, scriptArgs |> List.ofArray)) [] si)
Expand All @@ -89,7 +88,7 @@ let executeFSIWithScriptArgsAndReturnMessages workingDirectory script (scriptArg
open Microsoft.FSharp.Compiler.Interactive.Shell

/// Run the given FAKE script with fsi.exe at the given working directory. Provides full access to Fsi options and args. Redirect output and error messages.
let internal runFAKEScriptWithFsiArgsAndRedirectMessages workingDirectory printDetails (FsiArgs(fsiOptions, script, scriptArgs)) args onErrMsg onOutMsg =
let internal runFAKEScriptWithFsiArgsAndRedirectMessages printDetails (FsiArgs(fsiOptions, script, scriptArgs)) args onErrMsg onOutMsg =
if printDetails then traceFAKE "Running Buildscript: %s" script

// Add arguments to the Environment
Expand Down Expand Up @@ -138,28 +137,28 @@ let internal runFAKEScriptWithFsiArgsAndRedirectMessages workingDirectory printD
raise exn

/// Run the given buildscript with fsi.exe and allows for extra arguments to the script. Returns output.
let executeBuildScriptWithArgsAndReturnMessages workingDirectory script (scriptArgs: string[]) =
let executeBuildScriptWithArgsAndReturnMessages script (scriptArgs: string[]) =
let messages = ref []
let appendMessage isError msg =
messages := { IsError = isError
Message = msg
Timestamp = DateTimeOffset.UtcNow } :: !messages
let result =
runFAKEScriptWithFsiArgsAndRedirectMessages
workingDirectory true (FsiArgs([], script, scriptArgs |> List.ofArray)) []
true (FsiArgs([], script, scriptArgs |> List.ofArray)) []
(appendMessage true) (appendMessage false)
(result, !messages)

/// Run the given buildscript with fsi.exe at the given working directory. Provides full access to Fsi options and args.
let runBuildScriptWithFsiArgsAt workingDirectory printDetails (FsiArgs(fsiOptions, script, scriptArgs)) args =
let runBuildScriptWithFsiArgsAt printDetails (FsiArgs(fsiOptions, script, scriptArgs)) args =
runFAKEScriptWithFsiArgsAndRedirectMessages
workingDirectory printDetails (FsiArgs(fsiOptions, script, scriptArgs)) args
printDetails (FsiArgs(fsiOptions, script, scriptArgs)) args
traceError (fun s-> traceFAKE "%s" s)

/// Run the given buildscript with fsi.exe at the given working directory.
let runBuildScriptAt workingDirectory printDetails script extraFsiArgs args =
runBuildScriptWithFsiArgsAt workingDirectory printDetails (FsiArgs(extraFsiArgs, script, [])) args
let runBuildScriptAt printDetails script extraFsiArgs args =
runBuildScriptWithFsiArgsAt printDetails (FsiArgs(extraFsiArgs, script, [])) args

/// Run the given buildscript with fsi.exe
let runBuildScript printDetails script extraFsiArgs args =
runBuildScriptAt "" printDetails script extraFsiArgs args
runBuildScriptAt printDetails script extraFsiArgs args