Skip to content
This repository was archived by the owner on Mar 20, 2025. It is now read-only.

Commit be1bd45

Browse files
committed
Update build system
1 parent d670fdf commit be1bd45

File tree

4 files changed

+118
-64
lines changed

4 files changed

+118
-64
lines changed

build-system/azure-pipeline.template.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ parameters:
22
name: ''
33
vmImage: ''
44
displayName: ''
5+
artifactName: 'akkaBuild'
56
scriptFileName: ''
67
scriptArgs: 'all'
8+
outputDirectory: ''
79
timeoutInMinutes: 120
810

911
jobs:
@@ -17,6 +19,11 @@ jobs:
1719
clean: false # whether to fetch clean each time
1820
submodules: recursive # set to 'true' for a single level of submodules or 'recursive' to get submodules of submodules
1921
persistCredentials: true
22+
- task: UseDotNet@2
23+
displayName: 'Use .NET Core Runtime 3.1.10'
24+
inputs:
25+
packageType: runtime
26+
version: 3.1.10
2027
# Linux or macOS
2128
- task: Bash@3
2229
displayName: Linux / OSX Build
@@ -39,6 +46,17 @@ jobs:
3946
testResultsFiles: '**/*.trx' #TestResults folder usually
4047
testRunTitle: ${{ parameters.name }}
4148
mergeTestResults: true
49+
- task: CopyFiles@2
50+
displayName: 'Copy Build Output'
51+
inputs:
52+
sourceFolder: ${{ parameters.outputDirectory }}
53+
contents: '**\*'
54+
targetFolder: $(Build.ArtifactStagingDirectory)
55+
continueOnError: boolean # 'true' if future steps should run even if this step fails; defaults to 'false'
56+
- task: PublishBuildArtifacts@1
57+
inputs:
58+
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
59+
artifactName: ${{ parameters.artifactName }}
4260
- script: 'echo 1>&2'
4361
failOnStderr: true
4462
displayName: 'If above is partially succeeded, then fail'

build-system/pr-validation.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ jobs:
2727
parameters:
2828
name: 'linux_pr'
2929
displayName: 'Linux PR Validation'
30-
vmImage: 'ubuntu-16.04'
31-
scriptFileName: ./build.sh
32-
scriptArgs: RunTests
30+
vmImage: 'ubuntu-18.04'
31+
scriptFileName: './build.sh'
32+
scriptArgs: RunTestsNetCore
33+
outputDirectory: 'TestResults'
34+
artifactName: 'net_core_tests-$(Build.BuildId)'

build-system/windows-release.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# See https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema for reference
33

44
pool:
5-
vmImage: vs2017-win2016
5+
vmImage: windows-2019
66
demands: Cmd
77

88
trigger:
@@ -21,6 +21,11 @@ variables:
2121
- name: githubRepositoryName
2222
value: akkadotnet/Akka.Persistence.PostgreSql
2323
steps:
24+
- task: UseDotNet@2
25+
displayName: 'Use .NET Core Runtime 3.1.10'
26+
inputs:
27+
packageType: runtime
28+
version: 3.1.10
2429
- task: BatchScript@1
2530
displayName: 'FAKE Build'
2631
inputs:

build.fsx

Lines changed: 89 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -7,56 +7,65 @@ open System.Text
77

88
open Fake
99
open Fake.DotNetCli
10+
open Fake.DocFxHelper
11+
open Fake.NuGet.Install
1012

11-
//--------------------------------------------------------------------------------
12-
// Information about the project for Nuget and Assembly info files
13-
//--------------------------------------------------------------------------------
14-
15-
let product = "Akka.NET"
16-
let authors = [ "Akka.NET Team" ]
17-
let copyright = "Copyright © 2013-2015 Akka.NET Team"
18-
let company = "Akka.NET Team"
19-
let description = "Akka.NET is a port of the popular Java/Scala framework Akka to .NET"
20-
let tags = ["akka";"actors";"actor";"model";"Akka";"concurrency"]
13+
// Variables
2114
let configuration = "Release"
15+
let solution = System.IO.Path.GetFullPath(string "./src/Akka.Persistence.PostgreSql.sln")
2216

23-
//--------------------------------------------------------------------------------
2417
// Directories
25-
//--------------------------------------------------------------------------------
26-
27-
let slnFile = __SOURCE_DIRECTORY__ @@ "src/Akka.Persistence.PostgreSql.sln"
18+
let toolsDir = __SOURCE_DIRECTORY__ @@ "tools"
2819
let output = __SOURCE_DIRECTORY__ @@ "bin"
29-
let outputTests = output @@ "TestResults"
30-
let outputPerfTests = output @@ "perf"
20+
let outputTests = __SOURCE_DIRECTORY__ @@ "TestResults"
21+
let outputPerfTests = __SOURCE_DIRECTORY__ @@ "PerfResults"
3122
let outputBinaries = output @@ "binaries"
3223
let outputNuGet = output @@ "nuget"
33-
let outputBinariesNet45 = outputBinaries @@ "net45"
34-
let outputBinariesNetStandard = outputBinaries @@ "netstandard1.6"
24+
let outputBinariesNet47 = outputBinaries @@ "net471"
25+
let outputBinariesNetStandard = outputBinaries @@ "netstandard2.0"
3526

3627
// Read release notes and version
3728
let buildNumber = environVarOrDefault "BUILD_NUMBER" "0"
38-
let preReleaseVersionSuffix = (if (not (buildNumber = "0")) then (buildNumber) else "") + "-beta"
39-
let versionSuffix =
40-
match (getBuildParam "nugetprerelease") with
41-
| "dev" -> preReleaseVersionSuffix
42-
| _ -> ""
29+
let preReleaseVersionSuffix = "beta" + (if (not (buildNumber = "0")) then (buildNumber) else DateTime.UtcNow.Ticks.ToString())
4330

4431
let releaseNotes =
45-
File.ReadLines "./RELEASE_NOTES.md"
32+
File.ReadLines (__SOURCE_DIRECTORY__ @@ "RELEASE_NOTES.md")
4633
|> ReleaseNotesHelper.parseReleaseNotes
4734

35+
let versionFromReleaseNotes =
36+
match releaseNotes.SemVer.PreRelease with
37+
| Some r -> r.Origin
38+
| None -> ""
39+
40+
let versionSuffix =
41+
match (getBuildParam "nugetprerelease") with
42+
| "dev" -> preReleaseVersionSuffix
43+
| "" -> versionFromReleaseNotes
44+
| str -> str
45+
46+
// Configuration values for tests
47+
let testNetFrameworkVersion = "net471"
48+
let testNetCoreVersion = "netcoreapp3.1"
49+
let testNetVersion = "net5.0"
50+
4851
printfn "Assembly version: %s\nNuget version; %s\n" releaseNotes.AssemblyVersion releaseNotes.NugetVersion
4952

5053
//--------------------------------------------------------------------------------
5154
// Clean build results
5255
//--------------------------------------------------------------------------------
5356

5457
Target "Clean" (fun _ ->
58+
ActivateFinalTarget "KillCreatedProcesses"
59+
5560
CleanDir output
5661
CleanDir outputTests
5762
CleanDir outputPerfTests
63+
CleanDir outputBinaries
5864
CleanDir outputNuGet
65+
CleanDir outputBinariesNet47
66+
CleanDir outputBinariesNetStandard
5967
CleanDir "docs/_site"
68+
6069
CleanDirs !! "./**/bin"
6170
CleanDirs !! "./**/obj"
6271
)
@@ -69,8 +78,8 @@ Target "RestorePackages" (fun _ ->
6978
DotNetCli.Restore
7079
(fun p ->
7180
{ p with
72-
Project = slnFile
73-
NoCache = false })
81+
Project = solution
82+
NoCache = true })
7483
)
7584

7685
//--------------------------------------------------------------------------------
@@ -106,6 +115,22 @@ Target "Build" (fun _ ->
106115
// Run tests
107116
//--------------------------------------------------------------------------------
108117

118+
type Runtime =
119+
| NetCore
120+
| Net
121+
| NetFramework
122+
123+
let getTestAssembly runtime project =
124+
let assemblyPath = match runtime with
125+
| NetCore -> !! ("src" @@ "**" @@ "bin" @@ "Release" @@ testNetCoreVersion @@ fileNameWithoutExt project + ".dll")
126+
| NetFramework -> !! ("src" @@ "**" @@ "bin" @@ "Release" @@ testNetFrameworkVersion @@ fileNameWithoutExt project + ".dll")
127+
| Net -> !! ("src" @@ "**" @@ "bin" @@ "Release" @@ testNetVersion @@ fileNameWithoutExt project + ".dll")
128+
129+
if Seq.isEmpty assemblyPath then
130+
None
131+
else
132+
Some (assemblyPath |> Seq.head)
133+
109134
module internal ResultHandling =
110135
let (|OK|Failure|) = function
111136
| 0 -> OK
@@ -125,62 +150,55 @@ module internal ResultHandling =
125150
>> Option.iter (failBuildWithMessage errorLevel)
126151

127152
Target "RunTests" <| fun _ ->
128-
let projects =
129-
match (isWindows) with
130-
| true -> !! "./src/**/*.Tests.csproj"
131-
| _ -> !! "./src/**/*.Tests.csproj" // if you need to filter specs for Linux vs. Windows, do it here
153+
let projects =
154+
match (isWindows) with
155+
| true -> !! "./src/**/*.Tests.*sproj"
156+
| _ -> !! "./src/**/*.Tests.*sproj" // if you need to filter specs for Linux vs. Windows, do it here
132157

133158
ensureDirectory outputTests
134159

135160
let runSingleProject project =
161+
let arguments =
162+
(sprintf "test -c Release --no-build --logger:trx --logger:\"console;verbosity=normal\" --framework %s --results-directory \"%s\" -- -parallel none" testNetFrameworkVersion outputTests)
163+
136164
let result = ExecProcess(fun info ->
137165
info.FileName <- "dotnet"
138166
info.WorkingDirectory <- (Directory.GetParent project).FullName
139-
info.Arguments <- (sprintf "xunit -f net452 -c Release -parallel none -teamcity -xml %s_net452_xunit.xml" (outputTests @@ fileNameWithoutExt project))) (TimeSpan.FromMinutes 30.)
140-
141-
ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.DontFailBuild result
167+
info.Arguments <- arguments) (TimeSpan.FromMinutes 30.0)
142168

143-
// dotnet process will be killed by ExecProcess (or throw if can't) '
144-
// but per https://github.com/xunit/xunit/issues/1338 xunit.console may not
145-
killProcess "xunit.console"
146-
killProcess "dotnet"
169+
ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.Error result
147170

148-
projects |> Seq.iter (log)
171+
CreateDir outputTests
149172
projects |> Seq.iter (runSingleProject)
150173

151174
Target "RunTestsNetCore" <| fun _ ->
152-
let projects =
153-
match (isWindows) with
154-
| true -> !! "./src/**/*.Tests.csproj"
155-
| _ -> !! "./src/**/*.Tests.csproj" // if you need to filter specs for Linux vs. Windows, do it here
175+
let projects =
176+
match (isWindows) with
177+
| true -> !! "./src/**/*.Tests.*sproj"
178+
| _ -> !! "./src/**/*.Tests.*sproj" // if you need to filter specs for Linux vs. Windows, do it here
156179

157180
ensureDirectory outputTests
158181

159182
let runSingleProject project =
183+
let arguments =
184+
(sprintf "test -c Release --no-build --logger:trx --logger:\"console;verbosity=normal\" --framework %s --results-directory \"%s\" -- -parallel none" testNetCoreVersion outputTests)
185+
160186
let result = ExecProcess(fun info ->
161187
info.FileName <- "dotnet"
162188
info.WorkingDirectory <- (Directory.GetParent project).FullName
163-
info.Arguments <- (sprintf "xunit -f netcoreapp1.1 -c Release -parallel none -teamcity -xml %s_netcore_xunit.xml" (outputTests @@ fileNameWithoutExt project))) (TimeSpan.FromMinutes 30.)
164-
165-
ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.DontFailBuild result
189+
info.Arguments <- arguments) (TimeSpan.FromMinutes 30.0)
166190

167-
// dotnet process will be killed by ExecProcess (or throw if can't) '
168-
// but per https://github.com/xunit/xunit/issues/1338 xunit.console may not
169-
killProcess "xunit.console"
170-
killProcess "dotnet"
191+
ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.Error result
171192

172-
projects |> Seq.iter (log)
193+
CreateDir outputTests
173194
projects |> Seq.iter (runSingleProject)
174195

175196
//--------------------------------------------------------------------------------
176197
// Nuget targets
177198
//--------------------------------------------------------------------------------
178199

179-
let overrideVersionSuffix (project:string) =
180-
match project with
181-
| _ -> versionSuffix // add additional matches to publish different versions for different projects in solution
182-
183200
Target "CreateNuget" (fun _ ->
201+
CreateDir outputNuGet // need this to stop Azure pipelines copy stage from error-ing out
184202
let projects = !! "src/**/*.csproj"
185203
-- "src/**/*Tests.csproj" // Don't publish unit tests
186204
-- "src/**/*Tests*.csproj"
@@ -192,13 +210,14 @@ Target "CreateNuget" (fun _ ->
192210
Project = project
193211
Configuration = configuration
194212
AdditionalArgs = ["--include-symbols"]
195-
VersionSuffix = overrideVersionSuffix project
196-
OutputPath = outputNuGet })
213+
VersionSuffix = versionSuffix
214+
OutputPath = "\"" + outputNuGet + "\"" })
197215

198216
projects |> Seq.iter (runSingleProject)
199217
)
200218

201219
Target "PublishNuget" (fun _ ->
220+
202221
let projects = !! "./bin/nuget/*.nupkg" -- "./bin/nuget/*.symbols.nupkg"
203222
let apiKey = getBuildParamOrDefault "nugetkey" ""
204223
let source = getBuildParamOrDefault "nugetpublishurl" ""
@@ -225,6 +244,14 @@ Target "PublishNuget" (fun _ ->
225244
projects |> Seq.iter (runSingleProject)
226245
)
227246

247+
FinalTarget "KillCreatedProcesses" (fun _ ->
248+
log "Shutting down dotnet build-server"
249+
let result = ExecProcess(fun info ->
250+
info.FileName <- "dotnet"
251+
info.WorkingDirectory <- __SOURCE_DIRECTORY__
252+
info.Arguments <- "build-server shutdown") (System.TimeSpan.FromMinutes 2.0)
253+
if result <> 0 then failwithf "dotnet build-server shutdown failed"
254+
)
228255

229256
//--------------------------------------------------------------------------------
230257
// Help
@@ -328,22 +355,24 @@ Target "HelpDocs" <| fun _ ->
328355
//--------------------------------------------------------------------------------
329356

330357
Target "BuildRelease" DoNothing
358+
Target "All" DoNothing
331359
Target "Nuget" DoNothing
332360

333361
// build dependencies
334-
"Clean" ==> "AssemblyInfo" ==> "RestorePackages" ==> "Build" ==> "BuildRelease"
362+
"Clean" ==> "AssemblyInfo" ==> "RestorePackages" ==> "Build"
363+
"Build" ==> "BuildRelease"
335364

336365
// test dependencies
337-
"RestorePackages" ==> "RunTests"
338-
"RestorePackages" ==> "RunTestsNetCore"
366+
"Build" ==> "RunTests"
367+
"Build" ==> "RunTestsNetCore"
339368

340369
// nuget dependencies
341370
"BuildRelease" ==> "CreateNuget"
342371
"CreateNuget" ==> "PublishNuget" ==> "Nuget"
343372

344-
Target "All" DoNothing
345373
"BuildRelease" ==> "All"
346374
"RunTests" ==> "All"
375+
"RunTestsNetCore" ==> "All"
347376
"Nuget" ==> "All"
348377

349378
RunTargetOrDefault "Help"

0 commit comments

Comments
 (0)