Skip to content

Commit b5333cf

Browse files
Merge pull request #170 from rabbitmq/rabbitmq-dotnet-client-169
move code generation, build and test to FAKE
2 parents a840f58 + 9b10d05 commit b5333cf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+574
-19875
lines changed

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ gensrc/
1010
docs/pyle.log
1111
docs/pyle.pid
1212
docs/api-guide.pdf
13+
.DS_Store
14+
TestResults.xml
15+
TestResult.xml
16+
/packages
17+
/.fake
18+
.paket/paket.exe
19+
/NuGet
20+
rabbit-mock.snk
1321

1422
#################
1523
## Visual Studio
@@ -93,7 +101,6 @@ projects/client/Unit*/TestResult.xml
93101

94102
# Development scripts
95103

96-
*.fsx
97104
*.pcap
98105

99106
# Vim

.paket/paket.bootstrapper.exe

35.5 KB
Binary file not shown.

Local.props.example

Lines changed: 0 additions & 24 deletions
This file was deleted.

RUNNING_TESTS.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,28 @@ It is possible to use [Visual Studio Community edition](https://www.visualstudio
1212

1313
## Building
1414

15-
### Copy `Local.props.example` and Edit
15+
On Windows run:
1616

17-
First copy `Local.props.example` to `Local.props` and edit it if needed, specifying whether
18-
you intend to build the client on Mono and what .NET version should be targeted.
17+
build.bat
1918

20-
### Build
19+
On osx/linux run:
2120

22-
Then, build in Visual Studio or build from the command line. To do the latter,
23-
simply run
21+
build.sh
2422

25-
msbuild.exe
23+
This will complete the code AMQP spec generation and build all projects. After this open the solution in Visual Studio.
2624

2725

2826
## Running Tests
2927

3028
Tests can be run from Visual Studio using [NUnit Test Adapter](https://visualstudiogallery.msdn.microsoft.com/6ab922d0-21c0-4f06-ab5f-4ecd1fe7175d).
3129
Note that it may take some time for the adapter to discover tests in the assemblies.
3230

33-
Running the tests from the command line is also straightforward: use
31+
Running the tests from the command line is also straightforward you don't need to build first to do this: use
3432

35-
msbuild.exe /t:RunUnitTests projects/client/Unit/RabbitMQ.Client.Unit.csproj
33+
On Windows run:
34+
35+
run-test.bat
36+
37+
On osx/linux run:
38+
39+
run-test.sh

RabbitMQDotNetClient.userprefs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Properties StartupItem="projects/client/Apigen/RabbitMQ.Client.Apigen.csproj">
2+
<MonoDevelop.Ide.ItemProperties.projects.client.RabbitMQ.Client.Apigen PreferredExecutionTarget="MonoDevelop.Default" />
3+
<MonoDevelop.Ide.Workbench />
4+
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
5+
<MonoDevelop.Ide.DebuggingService.Breakpoints>
6+
<BreakpointStore />
7+
</MonoDevelop.Ide.DebuggingService.Breakpoints>
8+
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
9+
</Properties>

appveyor.props.in

Lines changed: 0 additions & 12 deletions
This file was deleted.

appveyor.yml

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,10 @@ install:
2929
$env:RABBITMQ_RABBITMQCTL_PATH = "$path\rabbitmq_server-$version\sbin\rabbitmqctl.bat"
3030
3131
before_build:
32-
- copy "appveyor.props.in" "Local.props"
3332

34-
build:
35-
parallel: false
36-
project: RabbitMQDotNetClient.sln
37-
publish_nuget: false
38-
publish_nuget_symbols: false
39-
include_nuget_references: false
40-
verbosity: minimal
33+
build_script: fake.bat AppVeyor
34+
35+
test: off
4136

4237
after_build:
4338
- ps: |
@@ -46,15 +41,7 @@ after_build:
4641
nuget pack RabbitMQ.Client.nuspec -version $semver -symbols
4742
nuget pack RabbitMQ.ServiceModel.nuspec -version $semver -symbols
4843
49-
test:
50-
assemblies:
51-
- '**\build\bin\unit-tests.dll'
52-
categories:
53-
except:
54-
- RequireSMP
55-
- LongRunning
56-
5744
artifacts:
58-
- path: '**\*.nupkg'
45+
- path: '*.nupkg'
5946

6047
deploy: off

build.bat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@ECHO OFF
2+
.paket\paket.bootstrapper.exe
3+
.paket\paket.exe restore
4+
packages\FAKE\tools\FAKE.exe build.fsx

build.fsx

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
#!/usr/bin/env fsharpi --exec
2+
#r "./packages/FAKE/tools/FakeLib.dll"
3+
#r "System.Xml.Linq"
4+
open Fake
5+
open System
6+
open System.Xml.Linq
7+
open System.Diagnostics
8+
9+
10+
let (|IsWin8OrHigher|_|) (ov: OperatingSystem) =
11+
if ov.Platform = PlatformID.Win32NT && ov.Version > Version("6.2") then
12+
Some ()
13+
else None
14+
15+
type BuildEnv =
16+
| AppVeyor
17+
| Mono
18+
| Windows
19+
| Windows8Plus
20+
21+
let getEnv = Environment.GetEnvironmentVariable
22+
23+
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
24+
25+
let targetFramework = "v4.5"
26+
27+
let context =
28+
let osVersion = Environment.OSVersion
29+
match getEnv "APPVEYOR_BUILD_VERSION" with
30+
| null ->
31+
let buildEnv =
32+
match osVersion with
33+
| IsWin8OrHigher _ -> Windows8Plus
34+
| _ when isMono -> Mono
35+
| _ -> Windows
36+
match getEnv "RABBIT_VSN" with
37+
| null ->
38+
tracefn "warn: no version environment variable specificed -defaulting to 0.0.0.0"
39+
buildEnv, "0.0.0.0"
40+
| v -> buildEnv, v
41+
| v ->
42+
AppVeyor, v
43+
44+
45+
tracefn "Fake: context %A" context
46+
47+
let buildEnv, version = context
48+
49+
let (</>) a b = IO.Path.Combine(a, b)
50+
51+
let localPropsFile = "./Local.props"
52+
let projects =
53+
[ "RabbitMQ.Client" ; "RabbitMQ.Client.WinRT" ]
54+
let apiGenExe = "./gensrc/rabbitmq-dotnet-apigen.exe"
55+
let specsDir = "./docs/specs"
56+
let amqpSpec0_9_1BaseName = "amqp0-9-1.stripped.xml"
57+
let amqpSpec0_9BaseName = "amqp0-9.stripped.xml"
58+
let amqpSpec0_9_1i = specsDir </> amqpSpec0_9_1BaseName
59+
let autogeneratedApi0_9_1BaseName = "autogenerated-api-0-9-1.cs"
60+
61+
let createGensrcDirs () =
62+
projects
63+
|> List.map (fun p -> "./gensrc" </> p)
64+
|> List.map IO.Directory.CreateDirectory
65+
|> ignore
66+
67+
let deleteGensrcDirs () =
68+
projects
69+
|> List.map (fun p -> "./gensrc" </> p)
70+
|> List.map (fun p ->
71+
if IO.Directory.Exists p then IO.Directory.Delete(p, true))
72+
|> ignore
73+
74+
let generateApi () =
75+
projects
76+
|> List.map (fun p -> "./gensrc/" </> p)
77+
|> List.iter (fun p ->
78+
let autogeneratedApi0_9_1 = p </> autogeneratedApi0_9_1BaseName
79+
ExecProcess
80+
(fun si ->
81+
si.FileName <- apiGenExe
82+
si.Arguments <- "/apiName:AMQP_0_9_1 " + amqpSpec0_9_1i + " " + autogeneratedApi0_9_1)
83+
(TimeSpan.FromMinutes 1.)
84+
|> fun res -> if res <> 0 then failwith "generateApi process failed")
85+
86+
let assemblyInfos = !!(@"./projects/**/AssemblyInfo.cs")
87+
--(@"**\*Scripts*\**")
88+
89+
let appRefs =
90+
let main =
91+
!! "./projects/client/RabbitMQ.Client/**/*.csproj"
92+
++ "./projects/client/Unit/**/*.csproj"
93+
++ "./projects/wcf/**/*.csproj"
94+
match buildEnv with
95+
| Windows8Plus | AppVeyor ->
96+
!! "./projects/**/*.csproj"
97+
| _ -> main
98+
99+
let appGenRef = [ "./projects/client/Apigen/RabbitMQ.Client.Apigen.csproj" ]
100+
101+
Target "BuildApigen" (fun _ ->
102+
MSBuildRelease "./gensrc" "Build" appGenRef
103+
|> Log "Build: ")
104+
105+
Target "BuildClient" (fun _ ->
106+
MSBuild null "Build" ["Configuration", "Release"; "Platform", "AnyCPU" ] appRefs
107+
|> Log "Build: ")
108+
109+
Target "Clean" (fun _ ->
110+
deleteGensrcDirs()
111+
MSBuild null "Clean" ["Configuration", "Release"; "Platform", "AnyCPU" ] appRefs
112+
|> Log "Clean: ")
113+
114+
Target "UpdateAssemblyInfos"
115+
(fun _ ->
116+
trace (sprintf "Updating assembly infos to: %s" version)
117+
ReplaceAssemblyInfoVersionsBulk assemblyInfos (fun f ->
118+
{ f with AssemblyVersion = version }))
119+
120+
let test excludes =
121+
!! ("./projects/client/**/build/**/unit-tests.dll")
122+
|> NUnit (fun p ->
123+
{ p with
124+
TimeOut = TimeSpan.FromMinutes 30.
125+
ExcludeCategory = excludes
126+
DisableShadowCopy = true;
127+
OutputFile = "./TestResults.xml"})
128+
129+
Target "Test" (fun _ ->
130+
match buildEnv with
131+
| Mono -> "MonoBug"
132+
| _ -> ""
133+
|> test)
134+
135+
Target "TestQuick" (fun _ ->
136+
let excludes =
137+
match buildEnv with
138+
| Mono -> "RequireSMP,LongRunning,MonoBug"
139+
| _ -> "RequireSMP,LongRunning"
140+
!! ("./projects/client/Unit/build/**/unit-tests.dll")
141+
|> NUnit (fun p ->
142+
{ p with
143+
TimeOut = TimeSpan.FromMinutes 30.
144+
ExcludeCategory = excludes
145+
DisableShadowCopy = true;
146+
OutputFile = "./TestResults.xml"}))
147+
148+
Target "AppVeyorTest" (fun _ ->
149+
test "RequireSMP,LongRunning,GCTest")
150+
151+
Target "CreateGensrcDir" createGensrcDirs
152+
153+
Target "GenerateApi" generateApi
154+
Target "Default" id
155+
Target "AppVeyor" id
156+
157+
Target "Pack" (fun _ ->
158+
IO.Directory.CreateDirectory "NuGet" |> ignore
159+
NuGetPack (fun p -> { p with Version = version; WorkingDir = __SOURCE_DIRECTORY__ }) "./RabbitMQ.Client.nuspec")
160+
161+
"Clean"
162+
==> "CreateGensrcDir"
163+
==> "BuildApigen"
164+
==> "GenerateApi"
165+
==> "UpdateAssemblyInfos"
166+
==> "BuildClient"
167+
==> "Default"
168+
169+
"BuildClient"
170+
==> "Test"
171+
172+
"BuildClient"
173+
==> "TestQuick"
174+
175+
"BuildClient"
176+
==> "AppVeyorTest"
177+
==> "AppVeyor"
178+
179+
RunTargetOrDefault "Default"

build.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
mono .paket/paket.bootstrapper.exe
6+
mono .paket/paket.exe restore
7+
mono ./packages/FAKE/tools/FAKE.exe build.fsx

0 commit comments

Comments
 (0)