PageRenderTime 62ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/build.fsx

https://gitlab.com/Hexexpeck/GitHub-API-.NET
F# | 262 lines | 205 code | 44 blank | 13 comment | 6 complexity | 0e8cd30aa10aa08efb4a98a23e83df62 MD5 | raw file
  1. #r @"tools/FAKE.Core/tools/FakeLib.dll"
  2. #load "tools/SourceLink.Fake/tools/SourceLink.fsx"
  3. open Fake
  4. open System
  5. open SourceLink
  6. let authors = ["GitHub"]
  7. // project name and description
  8. let projectName = "Octokit"
  9. let projectDescription = "An async-based GitHub API client library for .NET"
  10. let projectSummary = projectDescription // TODO: write a summary
  11. let reactiveProjectName = "Octokit.Reactive"
  12. let reactiveProjectDescription = "An IObservable based GitHub API client library for .NET using Reactive Extensions"
  13. let reactiveProjectSummary = reactiveProjectDescription // TODO: write a summary
  14. // directories
  15. let buildDir = "./Octokit/bin"
  16. let reactiveBuildDir = "./Octokit.Reactive/bin"
  17. let testResultsDir = "./testresults"
  18. let packagingRoot = "./packaging/"
  19. let samplesDir = "./samples"
  20. let packagingDir = packagingRoot @@ "octokit"
  21. let reactivePackagingDir = packagingRoot @@ "octokit.reactive"
  22. let linqPadDir = "./tools/LINQPad"
  23. let releaseNotes =
  24. ReadFile "ReleaseNotes.md"
  25. |> ReleaseNotesHelper.parseReleaseNotes
  26. let buildMode = getBuildParamOrDefault "buildMode" "Release"
  27. MSBuildDefaults <- {
  28. MSBuildDefaults with
  29. ToolsVersion = Some "14.0"
  30. Verbosity = Some MSBuildVerbosity.Minimal }
  31. Target "Clean" (fun _ ->
  32. CleanDirs [buildDir; reactiveBuildDir; testResultsDir; packagingRoot; packagingDir; reactivePackagingDir]
  33. )
  34. open Fake.AssemblyInfoFile
  35. open Fake.Testing
  36. Target "AssemblyInfo" (fun _ ->
  37. CreateCSharpAssemblyInfo "./SolutionInfo.cs"
  38. [ Attribute.Product projectName
  39. Attribute.Version releaseNotes.AssemblyVersion
  40. Attribute.FileVersion releaseNotes.AssemblyVersion
  41. Attribute.ComVisible false ]
  42. )
  43. Target "CheckProjects" (fun _ ->
  44. !! "./Octokit/Octokit*.csproj"
  45. |> Fake.MSBuild.ProjectSystem.CompareProjectsTo "./Octokit/Octokit.csproj"
  46. !! "./Octokit.Reactive/Octokit.Reactive*.csproj"
  47. |> Fake.MSBuild.ProjectSystem.CompareProjectsTo "./Octokit.Reactive/Octokit.Reactive.csproj"
  48. )
  49. let codeFormatter = @"tools\Octokit.CodeFormatter\tools\CodeFormatter.exe"
  50. Target "FormatCode" (fun _ ->
  51. [ "Octokit"
  52. "Octokit.Reactive"
  53. "Octokit.Tests"
  54. "Octokit.Tests.Conventions"
  55. "Octokit.Tests.Integration"]
  56. |> Seq.iter (fun pf ->
  57. let project = pf + "/" + pf + ".csproj"
  58. ExecProcess (fun info ->
  59. info.FileName <- codeFormatter
  60. info.Arguments <- project + " /nocopyright /nounicode") (TimeSpan.FromMinutes 1.0)
  61. |> ignore
  62. )
  63. )
  64. Target "FixProjects" (fun _ ->
  65. !! "./Octokit/Octokit*.csproj"
  66. |> Fake.MSBuild.ProjectSystem.FixProjectFiles "./Octokit/Octokit.csproj"
  67. !! "./Octokit.Reactive/Octokit.Reactive*.csproj"
  68. |> Fake.MSBuild.ProjectSystem.FixProjectFiles "./Octokit.Reactive/Octokit.Reactive.csproj"
  69. )
  70. let setParams defaults = {
  71. defaults with
  72. ToolsVersion = Some("14.0")
  73. Targets = ["Build"]
  74. Properties =
  75. [
  76. "Configuration", buildMode
  77. ]
  78. }
  79. let Exec command args =
  80. let result = Shell.Exec(command, args)
  81. if result <> 0 then failwithf "%s exited with error %d" command result
  82. Target "BuildApp" (fun _ ->
  83. build setParams "./Octokit.sln"
  84. |> DoNothing
  85. )
  86. Target "BuildMono" (fun _ ->
  87. // xbuild does not support msbuild tools version 14.0 and that is the reason
  88. // for using the xbuild command directly instead of using msbuild
  89. Exec "xbuild" "./Octokit-Mono.sln /t:Build /tv:12.0 /v:m /p:RestorePackages='False' /p:Configuration='Release' /logger:Fake.MsBuildLogger+ErrorLogger,'../octokit.net/tools/FAKE.Core/tools/FakeLib.dll'"
  90. )
  91. Target "ConventionTests" (fun _ ->
  92. !! (sprintf "./Octokit.Tests.Conventions/bin/%s/**/Octokit.Tests.Conventions.dll" buildMode)
  93. |> xUnit2 (fun p ->
  94. {p with
  95. HtmlOutputPath = Some (testResultsDir @@ "xunit.html") })
  96. )
  97. Target "UnitTests" (fun _ ->
  98. !! (sprintf "./Octokit.Tests/bin/%s/**/Octokit.Tests*.dll" buildMode)
  99. |> xUnit2 (fun p ->
  100. {p with
  101. HtmlOutputPath = Some (testResultsDir @@ "xunit.html") })
  102. )
  103. Target "IntegrationTests" (fun _ ->
  104. if hasBuildParam "OCTOKIT_GITHUBUSERNAME" && hasBuildParam "OCTOKIT_GITHUBPASSWORD" then
  105. !! (sprintf "./Octokit.Tests.Integration/bin/%s/**/Octokit.Tests.Integration.dll" buildMode)
  106. |> xUnit2 (fun p ->
  107. {p with
  108. HtmlOutputPath = Some (testResultsDir @@ "xunit.html")
  109. TimeOut = TimeSpan.FromMinutes 10.0 })
  110. else
  111. "The integration tests were skipped because the OCTOKIT_GITHUBUSERNAME and OCTOKIT_GITHUBPASSWORD environment variables are not set. " +
  112. "Please configure these environment variables for a GitHub test account (DO NOT USE A \"REAL\" ACCOUNT)."
  113. |> traceImportant
  114. )
  115. Target "SourceLink" (fun _ ->
  116. [ "Octokit/Octokit.csproj"
  117. "Octokit/Octokit-netcore45.csproj"
  118. "Octokit/Octokit-Portable.csproj"
  119. "Octokit.Reactive/Octokit.Reactive.csproj" ]
  120. |> Seq.iter (fun pf ->
  121. let proj = VsProj.LoadRelease pf
  122. let url = "https://raw.githubusercontent.com/octokit/octokit.net/{0}/%var2%"
  123. SourceLink.Index proj.Compiles proj.OutputFilePdb __SOURCE_DIRECTORY__ url
  124. )
  125. )
  126. Target "ValidateLINQPadSamples"(fun _ ->
  127. "The current LINQPad snippets reference the latest release of Octokit on NuGet, which may be very far behind what is currently on master. " +
  128. "These tests have been ported to SelfTests in the integration test suite. If someone would like to port them to F#, have a read of the details in https://github.com/octokit/octokit.net/issues/1081."
  129. |> traceImportant
  130. // directoryInfo(samplesDir @@ "linqpad-samples")
  131. // |> filesInDir
  132. // |> Array.map(fun f -> f.FullName)
  133. // |> Seq.iter (fun sample ->
  134. // let result = ExecProcess (fun info ->
  135. // info.FileName <- linqPadDir @@ "lprun.exe"
  136. // info.Arguments <- " -compileonly " + sample) (TimeSpan.FromMinutes 5.0)
  137. // if result <> 0 then failwithf "lprun.exe returned with a non-zero exit code for %s" sample
  138. // )
  139. )
  140. Target "CreateOctokitPackage" (fun _ ->
  141. let net45Dir = packagingDir @@ "lib/net45/"
  142. let netcore45Dir = packagingDir @@ "lib/netcore451/"
  143. let portableDir = packagingDir @@ "lib/portable-net45+wp80+win+wpa81/"
  144. let linqpadSamplesDir = packagingDir @@ "linqpad-samples"
  145. CleanDirs [net45Dir; netcore45Dir; portableDir;linqpadSamplesDir]
  146. CopyFile net45Dir (buildDir @@ "Release/Net45/Octokit.dll")
  147. CopyFile net45Dir (buildDir @@ "Release/Net45/Octokit.XML")
  148. CopyFile net45Dir (buildDir @@ "Release/Net45/Octokit.pdb")
  149. CopyFile netcore45Dir (buildDir @@ "Release/NetCore45/Octokit.dll")
  150. CopyFile netcore45Dir (buildDir @@ "Release/NetCore45/Octokit.XML")
  151. CopyFile netcore45Dir (buildDir @@ "Release/NetCore45/Octokit.pdb")
  152. CopyFile portableDir (buildDir @@ "Release/Portable/Octokit.dll")
  153. CopyFile portableDir (buildDir @@ "Release/Portable/Octokit.XML")
  154. CopyFile portableDir (buildDir @@ "Release/Portable/Octokit.pdb")
  155. CopyDir packagingDir "./samples" allFiles
  156. CopyFiles packagingDir ["LICENSE.txt"; "README.md"; "ReleaseNotes.md"]
  157. NuGet (fun p ->
  158. {p with
  159. Authors = authors
  160. Project = projectName
  161. Description = projectDescription
  162. OutputPath = packagingRoot
  163. Summary = projectSummary
  164. WorkingDir = packagingDir
  165. Version = releaseNotes.AssemblyVersion
  166. ReleaseNotes = toLines releaseNotes.Notes
  167. AccessKey = getBuildParamOrDefault "nugetkey" ""
  168. Publish = hasBuildParam "nugetkey" }) "octokit.nuspec"
  169. )
  170. Target "CreateOctokitReactivePackage" (fun _ ->
  171. let net45Dir = reactivePackagingDir @@ "lib/net45/"
  172. let linqpadSamplesDir = reactivePackagingDir @@ "linqpad-samples"
  173. CleanDirs [net45Dir;linqpadSamplesDir]
  174. CopyFile net45Dir (reactiveBuildDir @@ "Release/Net45/Octokit.Reactive.dll")
  175. CopyFile net45Dir (reactiveBuildDir @@ "Release/Net45/Octokit.Reactive.XML")
  176. CopyFile net45Dir (reactiveBuildDir @@ "Release/Net45/Octokit.Reactive.pdb")
  177. CopyFiles reactivePackagingDir ["LICENSE.txt"; "README.md"; "ReleaseNotes.md"]
  178. NuGet (fun p ->
  179. {p with
  180. Authors = authors
  181. Project = reactiveProjectName
  182. Description = reactiveProjectDescription
  183. OutputPath = packagingRoot
  184. Summary = reactiveProjectSummary
  185. WorkingDir = reactivePackagingDir
  186. Version = releaseNotes.AssemblyVersion
  187. ReleaseNotes = toLines releaseNotes.Notes
  188. Dependencies =
  189. ["Octokit", NormalizeVersion releaseNotes.AssemblyVersion
  190. "Rx-Main", GetPackageVersion "./packages/" "Rx-Main"]
  191. AccessKey = getBuildParamOrDefault "nugetkey" ""
  192. Publish = hasBuildParam "nugetkey" }) "Octokit.Reactive.nuspec"
  193. )
  194. Target "Default" DoNothing
  195. Target "CreatePackages" DoNothing
  196. "Clean"
  197. ==> "AssemblyInfo"
  198. ==> "CheckProjects"
  199. ==> "BuildApp"
  200. "Clean"
  201. ==> "AssemblyInfo"
  202. ==> "CheckProjects"
  203. ==> "BuildMono"
  204. "UnitTests"
  205. ==> "Default"
  206. "ConventionTests"
  207. ==> "Default"
  208. "IntegrationTests"
  209. ==> "Default"
  210. "SourceLink"
  211. ==> "CreatePackages"
  212. "CreateOctokitPackage"
  213. ==> "CreatePackages"
  214. "CreateOctokitReactivePackage"
  215. ==> "CreatePackages"
  216. "ValidateLINQPadSamples"
  217. ==> "CreatePackages"
  218. RunTargetOrDefault "Default"