Skip to content

Commit

Permalink
Merge pull request #216 from nhirschey/nh-si
Browse files Browse the repository at this point in the history
CI with github actions (windows and macOS)
  • Loading branch information
AndrewIOM authored Sep 20, 2021
2 parents 2835ff9 + 080284f commit c7804dd
Show file tree
Hide file tree
Showing 14 changed files with 123 additions and 146 deletions.
21 changes: 16 additions & 5 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,26 @@ name: .NET

on:
pull_request:
branches: [ master ]
branches: [ master ]

jobs:
build:

runs-on: ${{ matrix.os }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
os: [macos-latest]
os: [macos-latest,windows-latest]
env:
RPROVIDER_LOG: rlog.txt

steps:
- uses: actions/checkout@v2
- uses: r-lib/actions/setup-r@master
- uses: actions/checkout@master
- uses: r-lib/actions/setup-r@v1
name: Setup R environment
with:
r-version: '4.1.1'
r-version: '4.0.2'
- name: Set R_HOME environment variable
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
Expand All @@ -31,6 +35,10 @@ jobs:
exit 1
fi
shell: bash
- name: Verify R Home
run: |
Rscript -e 'R.home()'
echo "${{ env.R_HOME }}"
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
Expand All @@ -45,3 +53,6 @@ jobs:
run: dotnet restore RProvider.Tests.sln
- name: Build
run: dotnet fake build -t All
- name: Check R log
if: ${{ always() }}
run: cat rlog.txt
22 changes: 16 additions & 6 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@ name: .NET

on:
push:
branches: [ master, fix-ci ]
branches: [ master ]

jobs:
build:
runs-on: ${{ matrix.os }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
os: [macos-latest]
os: [macos-latest,windows-latest]

steps:
- uses: actions/checkout@v2
- uses: r-lib/actions/setup-r@master
- uses: actions/checkout@master
- uses: r-lib/actions/setup-r@v1
name: Setup R environment
with:
r-version: '4.1.1'
r-version: '4.0.2'
- name: Set R_HOME environment variable
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
Expand All @@ -30,6 +32,10 @@ jobs:
exit 1
fi
shell: bash
- name: Verify R Home
run: |
Rscript -e 'R.home()'
echo "${{ env.R_HOME }}"
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
Expand All @@ -43,11 +49,15 @@ jobs:
- name: Restore dependencies
run: dotnet restore RProvider.Tests.sln
- name: Build
run: dotnet fake build -t GenerateDocs
run: dotnet fake build -t All
- name: Deploy documentation from master
uses: peaceiris/actions-gh-pages@v3
with:
personal_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./output
publish_branch: gh-pages
force_orphan: true
- name: Examine bin
run: ls -r bin
- name: Publish NuGets (if this version not published before)
run: dotnet nuget push bin\*.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGETKEY }} --skip-duplicate
133 changes: 48 additions & 85 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ let projectDescription = """
The type provider automatically discovers available R packages and makes them
easily accessible from F#, so you can easily call powerful packages and
visualization libraries from code running on the .NET platform."""
let authors = ["BlueMountain Capital"; "FsLab"]
let authors = "BlueMountain Capital;FsLab"
let companyName = "BlueMountain Capital, FsLab"
let tags = "F# fsharp R TypeProvider visualization statistics"

let gitHome = "https://github.com/fslaborg"
let gitName = "RProvider"
let packageProjectUrl = "https://fslaborg.org/RProvider/"
let repositoryType = "git"
let repositoryUrl = "https://github.com/fslaborg/RProvider"

// --------------------------------------------------------------------------------------
// The rest of the code is standard F# build script
Expand Down Expand Up @@ -91,20 +92,21 @@ Target.create "Build" (fun _ ->

Target.create "BuildTests" (fun _ ->
Trace.log " --- Building tests --- "
Fake.DotNet.DotNet.build id (projectName + ".Tests.sln")
//Fake.DotNet.DotNet.build id (projectName + ".Tests.sln")
let result = Fake.DotNet.DotNet.exec (fun args ->
{ args with Verbosity = Some Fake.DotNet.DotNet.Verbosity.Normal}) "build" (projectName + ".Tests.sln")
if result.ExitCode <> 0 then failwith "Building tests failed"
)

// --------------------------------------------------------------------------------------
// Run the unit tests using test runner & kill test runner when complete


Target.create "RunTests" (fun _ ->
Target.activateFinal "CloseTestRunner"
Fake.DotNet.DotNet.test id (projectName + ".Tests.sln")
)

Target.createFinal "CloseTestRunner" (fun _ ->
Process.killAllByName "xunit.console.clr4.exe"
let rHome = Environment.environVarOrFail "R_HOME"
Trace.logf "R_HOME is set as %s" rHome
let result = Fake.DotNet.DotNet.exec (fun args ->
{ args with Verbosity = Some Fake.DotNet.DotNet.Verbosity.Normal}) "test" (projectName + ".Tests.sln")
if result.ExitCode <> 0 then failwith "Tests failed"
)

// --------------------------------------------------------------------------------------
Expand All @@ -114,25 +116,36 @@ Target.create "NuGet" (fun _ ->
// Format the description to fit on a single line (remove \r\n and double-spaces)
let specificVersion (name, version) = name, sprintf "[%s]" version
let projectDescription = projectDescription.Replace("\r", "").Replace("\n", "").Replace(" ", " ")
Fake.DotNet.NuGet.NuGet.NuGet (fun p ->

// Format the release notes
let releaseNotes = release.Notes |> String.concat "\n"

let properties = [
("Version", release.NugetVersion)
("Authors", authors)
("PackageProjectUrl", packageProjectUrl)
("PackageTags", tags)
("RepositoryType", repositoryType)
("RepositoryUrl", repositoryUrl)
//("PackageLicenseExpression", license) // TODO Enable license after stop packing PipeMethodCalls
("PackageReleaseNotes", releaseNotes)
("Summary", projectSummary)
("PackageDescription", projectDescription)
("EnableSourceLink", "true")
("PublishRepositoryUrl", "true")
("EmbedUntrackedSources", "true")
//("IncludeSymbols", "true") //TODO Enable symbols
("IncludeSymbols", "false")
("SymbolPackageFormat", "snupkg")
]

DotNet.pack (fun p ->
{ p with
Authors = authors
Project = projectName
Summary = projectSummary
Description = projectDescription
Version = release.NugetVersion
ReleaseNotes = String.concat " " release.Notes
Tags = tags
OutputPath = "bin"
Dependencies =
[ "R.NET.Community", Fake.DotNet.NuGet.NuGet.GetPackageVersion "packages" "R.NET.Community"
"DynamicInterop", Fake.DotNet.NuGet.NuGet.GetPackageVersion "packages" "DynamicInterop"
"R.NET.Community.FSharp", Fake.DotNet.NuGet.NuGet.GetPackageVersion "packages" "R.NET.Community.FSharp" ]
|> List.map specificVersion
AccessKey = Fake.Core.Environment.environVarOrDefault "nugetkey" ""
Publish = Fake.Core.Environment.hasEnvironVar "nugetkey" })
"nuget/RProvider.nuspec"
)
Configuration = DotNet.BuildConfiguration.Release
OutputPath = Some "bin"
MSBuildParams = { p.MSBuildParams with Properties = properties}
}
) "src/RProvider/RProvider.fsproj")

//--------------------------------------------------------------------------------------
//Generate the documentation
Expand All @@ -142,65 +155,15 @@ Target.create "GenerateDocs" (fun _ ->
DotNet.exec id "fsdocs" "build --clean" |> ignore
)

// --------------------------------------------------------------------------------------
// Release Scripts

Target.create "ReleaseDocs" (fun _ ->
Fake.Tools.Git.Repository.clone "" gitHome "temp/gh-pages"
Fake.Tools.Git.Branches.checkoutBranch "temp/gh-pages" "gh-pages"
Fake.IO.Shell.copyRecursive "output" "temp/gh-pages" true |> printfn "%A"
Fake.Tools.Git.CommandHelper.runSimpleGitCommand "temp/gh-pages" "add ." |> printfn "%s"
let cmd = sprintf """commit -a -m "Update generated documentation for version %s""" release.NugetVersion
Fake.Tools.Git.CommandHelper.runSimpleGitCommand "temp/gh-pages" cmd |> printfn "%s"
Fake.Tools.Git.Branches.push "temp/gh-pages"
)

Target.create "ReleaseBinaries" (fun _ ->
Fake.Tools.Git.Repository.clone "" (gitHome + "/" + gitName + ".git") "temp/release"
Fake.Tools.Git.Branches.checkoutBranch "temp/release" "release"
Fake.IO.Shell.copyRecursive "bin" "temp/release" true |> printfn "%A"
let cmd = sprintf """commit -a -m "Update binaries for version %s""" release.NugetVersion
Fake.Tools.Git.CommandHelper.runSimpleGitCommand "temp/release" cmd |> printfn "%s"
Fake.Tools.Git.Branches.push "temp/release"
)

Target.create "TagRelease" (fun _ ->
// Concatenate notes & create a tag in the local repository
let notes = (String.concat " " release.Notes).Replace("\n", ";").Replace("\r", "")
let tagName = "v" + release.NugetVersion
let cmd = sprintf """tag -a %s -m "%s" """ tagName notes
Fake.Tools.Git.CommandHelper.runSimpleGitCommand "." cmd |> printfn "%s"

// Find the main remote (fslaborg GitHub)
let _, remotes, _ = Fake.Tools.Git.CommandHelper.runGitCommand "." "remote -v"
let main = remotes |> Seq.find (fun s -> s.Contains("(push)") && s.Contains("fslaborg/RProvider"))
let remoteName = main.Split('\t').[0]
Fake.Tools.Git.Branches.pushTag "." remoteName tagName
)

Target.create "Release" ignore

// --------------------------------------------------------------------------------------
// Run all targets by default. Invoke 'build <Target>' to override

Target.create "All" ignore
Target.create "AllCore" ignore

"Clean"
==> "AssemblyInfo"
==> "Build"
==> "BuildTests"
==> "RunTests"
==> "All"

"All"
==> "CleanDocs"
==> "GenerateDocs"
==> "ReleaseDocs"
==> "ReleaseBinaries"
==> "Release"

"All" ==> "NuGet" ==> "Release"
"All" ==> "TagRelease" ==> "Release"

"Clean" ==> "AssemblyInfo" ==> "Build"
"Build" ==> "CleanDocs" ==> "GenerateDocs" ==> "All"
"Build" ==> "NuGet" ==> "All"
"Build" ==> "All"
"Build" ==> "BuildTests" ==> "RunTests" ==> "All"

Target.runOrDefault "All"
38 changes: 0 additions & 38 deletions nuget/RProvider.nuspec

This file was deleted.

1 change: 0 additions & 1 deletion nuget/publish.cmd

This file was deleted.

2 changes: 1 addition & 1 deletion paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ nuget R.NET.FSharp 1.9.0
nuget System.ComponentModel.Composition 5.0.0
nuget System.Configuration.ConfigurationManager 5.0.0
nuget System.Reflection.MetadataLoadContext 5.0.0
github andrewiom/PipeMethodCalls:69e5b6f7c1a130e20a2b8023638f6d6d65390b55
github andrewiom/PipeMethodCalls:7306482212444920ff07b0c5db5f2e71a4077bdf

github fsprojects/FSharp.TypeProviders.SDK:f4aca36af04aa84b16ec04df6f6bf55ac2f17a73 src/ProvidedTypes.fsi
github fsprojects/FSharp.TypeProviders.SDK:f4aca36af04aa84b16ec04df6f6bf55ac2f17a73 src/ProvidedTypes.fs
Expand Down
2 changes: 1 addition & 1 deletion paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ NUGET
xunit.runner.visualstudio (2.4.3)
GITHUB
remote: andrewiom/PipeMethodCalls
FULLPROJECT (69e5b6f7c1a130e20a2b8023638f6d6d65390b55)
FULLPROJECT (7306482212444920ff07b0c5db5f2e71a4077bdf)
remote: fsprojects/FSharp.TypeProviders.SDK
src/ProvidedTypes.fs (f4aca36af04aa84b16ec04df6f6bf55ac2f17a73)
src/ProvidedTypes.fsi (f4aca36af04aa84b16ec04df6f6bf55ac2f17a73)
Expand Down
17 changes: 13 additions & 4 deletions src/RProvider.DesignTime/RData.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ open System.Reflection
open ProviderImplementation.ProvidedTypes
open Microsoft.FSharp.Core.CompilerServices
open RProvider
open RProvider.Internal
open Microsoft.FSharp.Quotations
open PipeMethodCalls

Expand All @@ -20,7 +21,7 @@ type public RDataProvider(cfg:TypeProviderConfig) as this =

/// Given a file name, generate static type inherited from REnv
let generateTypes asm typeName (args:obj[]) =

Logging.logf $"Generating type for {typeName}"
// Load the environment and generate the type
let fileName = args.[0] :?> string
let longFileName =
Expand Down Expand Up @@ -50,6 +51,7 @@ type public RDataProvider(cfg:TypeProviderConfig) as this =

// For each key in the environment, provide a property..
for name, typ in RInteropClient.getServer().InvokeAsync(fun s -> s.GetRDataSymbols(longFileName)) |> Async.AwaitTask |> Async.RunSynchronously do
Logging.logf $"Adding member {name}"
match typ with
| null ->
// Generate property of type 'SymbolicExpression'
Expand All @@ -63,7 +65,8 @@ type public RDataProvider(cfg:TypeProviderConfig) as this =
ProvidedProperty(name, typ, getterCode = fun (Singleton self) ->
Expr.Coerce(<@@ ((%%self):REnv).Get(name).Value @@>, typ))
|> resTy.AddMember


Logging.logf $"Finished generating types for {longFileName}"
resTy

// Register the main (parameterized) type with F# compiler
Expand All @@ -77,5 +80,11 @@ type public RDataProvider(cfg:TypeProviderConfig) as this =

let rdata = ProvidedTypeDefinition(asm, "RProvider", "RData", Some(typeof<obj>))
let parameter = ProvidedStaticParameter("FileName", typeof<string>)
do rdata.DefineStaticParameters([parameter], generateTypes asm)
do this.AddNamespace("RProvider", [ rdata ])
do
rdata.DefineStaticParameters([parameter], generateTypes asm)
Logging.logf $"Defined static Parameters {parameter}"
do
this.AddNamespace("RProvider", [ rdata ])
Logging.logf $"RData added namespace {rdata.FullName}"


Loading

0 comments on commit c7804dd

Please sign in to comment.