<commit_before>// include Fake libs
#r "./packages/FAKE/tools/FakeLib.dll"

open Fake
open Fake.Testing.XUnit2

// Directories
let buildDir  = "./build/"
let deployDir = "./deploy/"


// Filesets
let appReferences  =
    !! "/**/*.csproj"
      ++ "/**/*.fsproj"

// version info
let version = "0.1"  // or retrieve from CI server

// Targets
Target "Clean" (fun _ ->
    CleanDirs [buildDir; deployDir]
)

Target "Build" (fun _ ->
    // compile all projects below src/app/
    MSBuildDebug buildDir "Build" appReferences
        |> Log "AppBuild-Output: "
)

Target "Test" (fun _ ->
    !! (buildDir @@ "*.tests.dll")
    |> xUnit2 (fun p -> { p with 
                            HtmlOutputPath = Some ("xunit.html");
                            ToolPath = "packages/xunit.runner.console/tools/xunit.console.exe";
    })
    |> ignore
)

Target "Deploy" (fun _ ->
    !! (buildDir + "/**/*.*")
        -- "*.zip"
        |> Zip buildDir (deployDir + "ApplicationName." + version + ".zip")
)

Target "Watch" (fun _ ->
    use watcher = (!! "build/*.dll") |> WatchChanges (fun changes -> 
        tracefn "%A" changes
        Run "Test")
    
    System.Console.ReadLine() |> ignore //Needed to keep FAKE from exiting

    watcher.Dispose() // Use to stop the watch from elsewhere, ie another task.
)

Target "Docker" (fun _ ->
    ExecProcess (fun info ->
        info.FileName <- "docker"
        info.Arguments <- "build -t cache ."
        info.WorkingDirectory <- ".") (System.TimeSpan.FromMinutes 5.0) |> ignore
)

Target "Migrations" (fun _ ->
    ExecProcess (fun info ->
        info.FileName <- "psql"
        info.Arguments <- "-U postgres -f 0000_CreateLogin.sql"
        info.WorkingDirectory <- "./migrations/up") (System.TimeSpan.FromMinutes 5.0) |> ignore

    ExecProcess (fun info ->
        info.FileName <- "psql"
        info.Arguments <- "-U postgres -f 0001_CreateDatabase.sql"
        info.WorkingDirectory <- "./migrations/up") (System.TimeSpan.FromMinutes 5.0) |> ignore

    ExecProcess (fun info ->
        info.FileName <- "psql"
        info.Arguments <- "-U postgres -f 0002_InstallHstorea.sql"
        info.WorkingDirectory <- "./migrations/up") (System.TimeSpan.FromMinutes 5.0) |> ignore

    ExecProcess (fun info ->
        info.FileName <- "psql"
        info.Arguments <- "-U postgres -f 0003_CreateGithubSchema.sql"
        info.WorkingDirectory <- "./migrations/up") (System.TimeSpan.FromMinutes 5.0) |> ignore

    ExecProcess (fun info ->
        info.FileName <- "psql"
        info.Arguments <- "-U postgres -f 0004_CreateGithubIssues.sql"
        info.WorkingDirectory <- "./migrations/up") (System.TimeSpan.FromMinutes 5.0) |> ignore
)

// Build order<commit_msg>Fixes typo that got checked in<commit_after>// include Fake libs
#r "./packages/FAKE/tools/FakeLib.dll"

open Fake
open Fake.Testing.XUnit2

// Directories
let buildDir  = "./build/"
let deployDir = "./deploy/"


// Filesets
let appReferences  =
    !! "/**/*.csproj"
      ++ "/**/*.fsproj"

// version info
let version = "0.1"  // or retrieve from CI server

// Targets
Target "Clean" (fun _ ->
    CleanDirs [buildDir; deployDir]
)

Target "Build" (fun _ ->
    // compile all projects below src/app/
    MSBuildDebug buildDir "Build" appReferences
        |> Log "AppBuild-Output: "
)

Target "Test" (fun _ ->
    !! (buildDir @@ "*.tests.dll")
    |> xUnit2 (fun p -> { p with 
                            HtmlOutputPath = Some ("xunit.html");
                            ToolPath = "packages/xunit.runner.console/tools/xunit.console.exe";
    })
    |> ignore
)

Target "Deploy" (fun _ ->
    !! (buildDir + "/**/*.*")
        -- "*.zip"
        |> Zip buildDir (deployDir + "ApplicationName." + version + ".zip")
)

Target "Watch" (fun _ ->
    use watcher = (!! "build/*.dll") |> WatchChanges (fun changes -> 
        tracefn "%A" changes
        Run "Test")
    
    System.Console.ReadLine() |> ignore //Needed to keep FAKE from exiting

    watcher.Dispose() // Use to stop the watch from elsewhere, ie another task.
)

Target "Docker" (fun _ ->
    ExecProcess (fun info ->
        info.FileName <- "docker"
        info.Arguments <- "build -t cache ."
        info.WorkingDirectory <- ".") (System.TimeSpan.FromMinutes 5.0) |> ignore
)

Target "Migrations" (fun _ ->
    ExecProcess (fun info ->
        info.FileName <- "psql"
        info.Arguments <- "-U postgres -f 0000_CreateLogin.sql"
        info.WorkingDirectory <- "./migrations/up") (System.TimeSpan.FromMinutes 5.0) |> ignore

    ExecProcess (fun info ->
        info.FileName <- "psql"
        info.Arguments <- "-U postgres -f 0001_CreateDatabase.sql"
        info.WorkingDirectory <- "./migrations/up") (System.TimeSpan.FromMinutes 5.0) |> ignore

    ExecProcess (fun info ->
        info.FileName <- "psql"
        info.Arguments <- "-U postgres -f 0002_InstallHstore.sql"
        info.WorkingDirectory <- "./migrations/up") (System.TimeSpan.FromMinutes 5.0) |> ignore

    ExecProcess (fun info ->
        info.FileName <- "psql"
        info.Arguments <- "-U postgres -f 0003_CreateGithubSchema.sql"
        info.WorkingDirectory <- "./migrations/up") (System.TimeSpan.FromMinutes 5.0) |> ignore

    ExecProcess (fun info ->
        info.FileName <- "psql"
        info.Arguments <- "-U postgres -f 0004_CreateGithubIssues.sql"
        info.WorkingDirectory <- "./migrations/up") (System.TimeSpan.FromMinutes 5.0) |> ignore
)

// Build order
{'fraction_non_alphanumeric': 0.1542142068457858, 'fraction_numerical': 0.013249907986750091, 'mean_word_length': 2.3221271393643033, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '37876', 'n_tokens_mistral': 1863, 'n_tokens_neox': 1712, 'n_words': 422}