-
Notifications
You must be signed in to change notification settings - Fork 34
/
build.fsx
187 lines (157 loc) · 7 KB
/
build.fsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
// --------------------------------------------------------------------------------------
// FAKE build script
// --------------------------------------------------------------------------------------
#r "paket: groupref build //"
#load "./.fake/build.fsx/intellisense.fsx"
#if !FAKE
#r "netstandard"
#endif
open Fake.Core.TargetOperators
open Fake.Core
open Fake.DotNet
open Fake.IO.Globbing.Operators
open System
open System.IO
open Fake.IO
open Fake.Azure
open Fake.DotNet.NuGet
open Fake.Tools.Git
open Fake.IO.FileSystemOperators
// The name of the project
// (used by attributes in AssemblyInfo, name of a NuGet package and directory in 'src')
let project = "FSharp.Azure.StorageTypeProvider"
// Short summary of the project
// (used as description in AssemblyInfo and as a short summary for NuGet package)
let summary = "Allows easy access to Azure Storage assets through F# scripts."
// Git configuration (used for publishing documentation in gh-pages branch)
// The profile where the project is posted
let gitOwner = "fsprojects"
let gitHome = "https://github.com/" + gitOwner
// The name of the project on GitHub
let gitName = "AzureStorageTypeProvider"
// Read additional information from the release notes document
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
let buildDir = "bin"
// TypeProvider path
let projectPath = Path.getFullName "./src/FSharp.Azure.StorageTypeProvider"
// Test path
let testPath = Path.getFullName "./tests/IntegrationTests"
// Read additional information from the release notes document
// Test Output Dir
let testOutPutDir = "TestOutput"
let release =
File.ReadAllLines "RELEASE_NOTES.md"
|> ReleaseNotes.parseAll
|> List.head
// Generate assembly info files with the right version & up-to-date information
Target.Create "AssemblyInfo" (fun _ ->
let fileName = "src/" + project + "/AssemblyInfo.fs"
AssemblyInfoFile.createFSharp fileName [ AssemblyInfo.Title project
AssemblyInfo.Product project
AssemblyInfo.Description summary
AssemblyInfo.Version release.AssemblyVersion
AssemblyInfo.FileVersion release.AssemblyVersion ])
let inline withWorkDir wd =
DotNet.Options.withWorkingDirectory wd
let runDotNet cmd workingDir =
let result =
DotNet.exec (withWorkDir workingDir) cmd ""
if result.ExitCode <> 0 then failwithf "'dotnet %s' failed in %s" cmd workingDir
// --------------------------------------------------------------------------------------
// Clean build results
Target.Create "Clean" (fun _ ->
try Shell.cleanDirs [ "bin"; "temp"; "tests/integrationtests/bin" ] with _ -> ()
)
// --------------------------------------------------------------------------------------
// Restore project
Target.Create "RestoreProject" (fun _ ->
DotNet.restore id projectPath
)
// --------------------------------------------------------------------------------------
// Build library project
Target.Create "Build" (fun _ ->
DotNet.publish id projectPath
)
// --------------------------------------------------------------------------------------
// Run the unit tests using test runner
Target.Create "ResetTestData" (fun _ ->
let script = Path.Combine(testPath, "ResetTestData.fsx")
Emulators.startStorageEmulator()
Fsi.exec (fun p ->
{ p with
TargetProfile = Fsi.Profile.Netcore
WorkingDirectory = testPath
}) script [""]
|> snd
|> Seq.iter(fun x -> printfn "%s" x)) ///ToBeFixed
// Run integration tests
let root = __SOURCE_DIRECTORY__
let testNetCoreDir = root </> "tests" </> "IntegrationTests" </> "bin" </> "Release" </> "netcoreapp2.0" </> "win10-x64" </> "publish"
Target.Create "RunTests" (fun _ ->
let result = DotNet.exec (withWorkDir testPath) "publish --self-contained -c Release -r win10-x64" ""
if not result.OK then failwith "Publish failed"
printfn "Dkr: %s" testNetCoreDir
let result = DotNet.exec (withWorkDir testNetCoreDir) "" "IntegrationTests.dll"
if result.OK then
printfn "Expecto for netcore finished without Errors"
else
printfn "Expecto for netcore finished with Errors"
)
// --------------------------------------------------------------------------------------
// Build a NuGet package
Target.Create "NuGet" (fun _ ->
Fake.IO.Directory.create @"bin\package"
NuGet.NuGet (fun p ->
{ p with
Authors = [ "Isaac Abraham" ]
Project = project
Title = "F# Azure Storage Type Provider"
Summary = summary
Description = "The F# Azure Storage Type Provider allows simple access to Blob, Table and Queue assets, using Azure Storage metadata to intelligently infer schema where possible, whilst providing a simple API for common tasks."
Version = release.NugetVersion
ReleaseNotes = release.Notes |> String.concat Environment.NewLine
Tags = "azure, f#, fsharp, type provider, blob, table, queue, script"
OutputPath = @"bin\package"
Dependencies = [ "WindowsAzure.Storage", "9.3.2"
"FSharp.Compiler.Tools", "10.2.1" ]
References = [ "FSharp.Azure.StorageTypeProvider.dll" ]
Files =
([ "FSharp.Azure.StorageTypeProvider.xml"; "FSharp.Azure.StorageTypeProvider.dll"
"Microsoft.WindowsAzure.Storage.dll"; "Newtonsoft.Json.dll" ]
|> List.map (fun file -> "../bin/netstandard2.0/publish/" + file, Some "lib/netstandard2.0", None))
@ [ "StorageTypeProvider.fsx", None, None ] })
("nuget/" + project + ".nuspec"))
[<AutoOpen>]
module AppVeyorHelpers =
let execOnAppveyor arguments =
let result =
Process.execSimple(fun info ->
{ info with
FileName = "appveyor"
Arguments = arguments})
(TimeSpan.FromMinutes 2.)
if result <> 0 then failwith (sprintf "Failed to execute appveyor command: %s" arguments)
Trace.trace "Published packages"
let publishOnAppveyor folder =
!! (folder + "*.nupkg")
|> Seq.iter (sprintf "PushArtifact %s" >> execOnAppveyor)
// --------------------------------------------------------------------------------------
// Release Scripts
Target.Create "LocalDeploy" (fun _ ->
DirectoryInfo @"bin"
|> DirectoryInfo.getMatchingFiles "*.nupkg"
|> Seq.map(fun x -> x.FullName)
|> Shell.copyFiles @"..\..\LocalPackages")
Target.Create "BuildServerDeploy" (fun _ -> publishOnAppveyor buildDir)
// --------------------------------------------------------------------------------------
// Run all targets by default. Invoke 'build <Target>' to override
Target.Create "All" ignore
"Clean"
==> "AssemblyInfo"
==> "Build"
==> "Nuget"
==> "ResetTestData"
==> "RunTests"
=?> ("LocalDeploy", BuildServer.isLocalBuild)
=?> ("BuildServerDeploy", BuildServer.buildServer = Fake.Core.BuildServer.AppVeyor)
Target.RunOrDefault "RunTests"