Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
language: csharp

mono:
- beta
- latest
- 4.8.1
- 4.2.2
- 4.0.5
- weekly
- nightly

# beta doesn't work because of whacky msbuild package install problems
# beta

# 5.4.0 doesn't work because of missing SDK build things for F# new styleprojects + msbuild
# - latest

# 5.2.0 doesn't work because of missing SDK build things for F# new styleprojects + msbuild
# - 5.2.0

dotnet: 2.0.0

os:
- linux
- osx

matrix:
allow_failures:
- mono: beta

sudo: false # use the new container-based Travis infrastructure
sudo: true # use the new container-based Travis infrastructure

script:
- ./build.sh RunTests
161 changes: 46 additions & 115 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
// --------------------------------------------------------------------------------------

#I "packages/FAKE/tools"
#r "FakeLib.dll"

#r "packages/FAKE/tools/FakeLib.dll"

open System
open System.IO
open Fake.AssemblyInfoFile
open Fake.Git
open Fake.Testing
open Fake.FscHelper
open Fake


// --------------------------------------------------------------------------------------
// Information about the project to be used at NuGet
// --------------------------------------------------------------------------------------
Expand All @@ -28,12 +24,19 @@ let tags = "F# fsharp typeprovider"
let gitHome = "https://github.com/fsprojects"
let gitName = "FSharp.TypeProviders.SDK"

let config = "Release"

// Read release notes & version info from RELEASE_NOTES.md
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
let release =
File.ReadLines "RELEASE_NOTES.md"
|> ReleaseNotesHelper.parseReleaseNotes


let exec p args =
printfn "Executing %s %s" p args
Shell.Exec(p, args) |> function 0 -> () | d -> failwithf "%s %s exited with error %d" p args d

let pullRequest =
match getBuildParamOrDefault "APPVEYOR_PULL_REQUEST_NUMBER" "" with
| "" ->
Expand All @@ -44,21 +47,16 @@ let pullRequest =
Some <| int a

let buildNumber =
int (getBuildParamOrDefault "APPVEYOR_BUILD_VERSION" "0")
getBuildParamOrDefault "APPVEYOR_BUILD_VERSION" "0"

let version =
match pullRequest with
| None ->
sprintf "%s.%d" release.AssemblyVersion buildNumber
sprintf "%s.%s" release.AssemblyVersion buildNumber
| Some num ->
sprintf "%s-pull-%d-%05d" release.AssemblyVersion num buildNumber
sprintf "%s-pull-%d-%s" release.AssemblyVersion num buildNumber
let releaseNotes = release.Notes |> String.concat "\n"
let outputPath = "./output/"
let workingDir = "./temp/"
let srcDir = "src"
let exampleDir = "examples"
let testDir = "test"
let nunitDir = "packages/NUnit/lib/net45"

let sources =
[srcDir @@ "ProvidedTypes.fsi"
Expand All @@ -68,124 +66,57 @@ let sources =
srcDir @@ "ProvidedTypesContext.fs"
srcDir @@ "ProvidedTypesTesting.fs" ]


// --------------------------------------------------------------------------------------
// Clean build results

Target "Clean" (fun _ ->
CleanDirs [outputPath; workingDir]
CleanDirs []
)

// --------------------------------------------------------------------------------------
// Compile ProvidedTypes as a smoke test
Target "Restore" (fun _ ->
exec "dotnet" "restore"
)
Target "Compile" (fun _ ->
// sources
// |> Compile [
// FscHelper.Target TargetType.Library
// Platform PlatformType.AnyCpu
// Reference "System.Reflection.Metadata.dll"
// ]

!! "FSharp.TypeProviders.SDK.sln"
|> MSBuildRelease "" "Build"
|> ignore
#if MONO
// We don't use dotnet build because of https://github.com/dotnet/sdk/issues/335
exec "msbuild" ("src/FSharp.TypeProviders.SDK.fsproj /p:Configuration=" + config)
exec "msbuild" ("tests/FSharp.TypeProviders.SDK.Tests.fsproj /p:Configuration=" + config)
#else
exec "dotnet" "build"
#endif
)

type ExampleWithTests =
{ Name : string
ProviderSourceFiles : string list
TestSourceFiles : string list }


// --------------------------------------------------------------------------------------
// Compile example providers and accompanying test dlls
#if EXAMPLES
Target "Examples" (fun _ ->
let examples =
[
{ Name = "StaticProperty"; ProviderSourceFiles = ["StaticProperty.fsx"]; TestSourceFiles = ["StaticProperty.Tests.fsx"]}
{ Name = "ErasedWithConstructor"; ProviderSourceFiles = ["ErasedWithConstructor.fsx"]; TestSourceFiles = ["ErasedWithConstructor.Tests.fsx"]}
]

if not (Directory.Exists testDir) then
Directory.CreateDirectory testDir |> ignore

let testNunitDll = testDir @@ "nunit.framework.dll"

if File.Exists testNunitDll then
File.Delete testNunitDll

File.Copy (nunitDir @@ "nunit.framework.dll", testNunitDll)

let fromExampleDir filenames =
filenames
|> List.map (fun filename -> exampleDir @@ filename)

examples
|> List.iter (fun example ->
// Compile type provider
let output = testDir @@ example.Name + ".dll"
(List.concat [sources;fromExampleDir example.ProviderSourceFiles])
|> Compile [
Out output
FscHelper.Target TargetType.Library
]

// Compile test dll
(fromExampleDir example.TestSourceFiles)
|> Compile [
Out (testDir @@ example.Name + ".Tests.dll")
FscHelper.Target TargetType.Library
References [output;nunitDir @@ "nunit.framework.dll"]
]
)
)
#endif
//#if EXAMPLES
// { Name = "StaticProperty"; ProviderSourceFiles = ["StaticProperty.fsx"]; TestSourceFiles = ["StaticProperty.Tests.fsx"]}
// { Name = "ErasedWithConstructor"; ProviderSourceFiles = ["ErasedWithConstructor.fsx"]; TestSourceFiles = ["ErasedWithConstructor.Tests.fsx"]}
//#endif

Target "RunTests" (fun _ ->
!! ("tests/bin/Release/FSharp.TypeProviders.SDK.Tests.dll")
|> NUnit3 id

#if EXAMPLES
!! (testDir @@ "*.Tests.dll")
|> NUnit3 id
#if MONO
// We don't use dotnet test because of https://github.com/dotnet/sdk/issues/335
//exec "packages/xunit.runner.console/tools/net452/xunit.console.exe" ("/p:Configuration=" + config + " tests/bin/" + config + "/net461/FSharp.TypeProviders.SDK.Tests.dll -parallel none")
()
#else
exec "dotnet" ("test tests/FSharp.TypeProviders.SDK.Tests.fsproj -c " + config)
// This also gives console output:
//exec "packages/xunit.runner.console/tools/net452/xunit.console.exe" ("/p:Configuration=" + config + " tests/bin/" + config + "/net461/FSharp.TypeProviders.SDK.Tests.dll -parallel none")
#endif
()
)

// --------------------------------------------------------------------------------------
// Build a NuGet package

Target "NuGet" (fun _ ->
sources |> CopyTo (workingDir @@ "content")

NuGet (fun p ->
{ p with
Authors = authors
Project = project
Summary = summary
Description = description
Version = version
ReleaseNotes = releaseNotes
Tags = tags
OutputPath = outputPath
WorkingDir = workingDir
AccessKey = getBuildParamOrDefault "nugetkey" ""
Publish = hasBuildParam "nugetkey"
Files = [(workingDir, None, None)]
Dependencies = [] })
"nuget/FSharp.TypeProviders.SDK.nuspec"
#if !MONO
// We don't do this on Linux/OSX because of https://github.com/dotnet/sdk/issues/335
exec "dotnet" ("pack src/FSharp.TypeProviders.SDK.fsproj -c " + config)
#endif
()
)

// --------------------------------------------------------------------------------------
// Help

"Clean"
==> "NuGet"

"Compile"
#if EXAMPLES
==> "Examples"
#endif
"Restore"
==> "Compile"
//#if EXAMPLES
// ==> "Examples"
//#endif
==> "RunTests"
==> "NuGet"

Expand Down
5 changes: 4 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ then
else
# use mono

sudo apt-get -y install msbuild mono-complete mono-devel fsharp

which mono
find /usr/lib/mono
which dotnet
which msbuild

mono .paket/paket.exe restore
exit_code=$?
Expand Down
11 changes: 5 additions & 6 deletions examples/ErasedWithConstructor.Tests.fsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#if INTERACTIVE
#r @"../packages/NUnit/lib/net45/nunit.framework.dll"
#r @"../test/ErasedWithConstructor.dll"
#endif

open NUnit.Framework
open ErasedWithConstructor.Provided
open Xunit

[<Test>]
[<Fact>]
let ``Default constructor should create instance`` () =
Assert.AreEqual("My internal state", MyType().InnerState)
Assert.Equal("My internal state", MyType().InnerState)

[<Test>]
[<Fact>]
let ``Constructor with parameter should create instance`` () =
Assert.AreEqual("override", MyType("override").InnerState)
Assert.Equal("override", MyType("override").InnerState)

6 changes: 2 additions & 4 deletions examples/StaticProperty.Tests.fsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#if INTERACTIVE
#r @"../packages/NUnit/lib/net45/nunit.framework.dll"
#r @"../test/StaticProperty.dll"
#endif

open NUnit.Framework
open StaticProperty.Provided

[<Test>]
[<Fact>]
let ``Static property should have been created`` () =
Assert.AreEqual("Hello world", MyType.MyProperty)
Assert.Equal("Hello world", MyType.MyProperty)

4 changes: 1 addition & 3 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ source https://api.nuget.org/v3/index.json

nuget Nuget.CommandLine
nuget FAKE

nuget NUnit
nuget NUnit.ConsoleRunner
nuget xunit.runner.console

group fs31
source https://api.nuget.org/v3/index.json
Expand Down
5 changes: 2 additions & 3 deletions paket.lock
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
RESTRICTION: >= net45
NUGET
remote: https://api.nuget.org/v3/index.json
FAKE (4.63)
FAKE (4.63.2)
Nuget.CommandLine (4.3)
NUnit (3.7.1)
NUnit.ConsoleRunner (3.7)
xunit.runner.console (2.3)

GROUP fs31
NUGET
Expand Down
Loading