Skip to content

Commit

Permalink
Merge pull request #215 from fslaborg/dsyme-patch-4
Browse files Browse the repository at this point in the history
Check CI for "build -t All" for mac (linux and windows outstanding)
  • Loading branch information
AndrewIOM authored Sep 16, 2021
2 parents 591ca8d + 91e420a commit c85cf6f
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 14 deletions.
21 changes: 19 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,27 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
os: [macos-latest]

steps:
- uses: actions/checkout@v2
- uses: r-lib/actions/setup-r@master
name: Setup R environment
with:
r-version: '4.1.1'
- name: Set R_HOME environment variable
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
echo "R_HOME=$(R RHOME)" >> "$GITHUB_ENV"
elif [ "$RUNNER_OS" == "macOS" ]; then
echo "R_HOME=$(R RHOME)" >> "$GITHUB_ENV"
elif [ "$RUNNER_OS" == "Windows" ]; then
echo "R_HOME=$(R RHOME)" >> "$GITHUB_ENV"
else
echo "$RUNNER_OS not supported"
exit 1
fi
shell: bash
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
Expand All @@ -27,4 +44,4 @@ jobs:
- name: Restore dependencies
run: dotnet restore RProvider.Tests.sln
- name: Build
run: dotnet fake build -t Build
run: dotnet fake build -t All
23 changes: 20 additions & 3 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,34 @@ name: .NET

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

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
os: [macos-latest]

steps:
- uses: actions/checkout@v2
- uses: r-lib/actions/setup-r@master
name: Setup R environment
with:
r-version: '4.1.1'
- name: Set R_HOME environment variable
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
echo "R_HOME=$(R RHOME)" >> "$GITHUB_ENV"
elif [ "$RUNNER_OS" == "macOS" ]; then
echo "R_HOME=$(R RHOME)" >> "$GITHUB_ENV"
elif [ "$RUNNER_OS" == "Windows" ]; then
echo "R_HOME=$(R RHOME)" >> "$GITHUB_ENV"
else
echo "$RUNNER_OS not supported"
exit 1
fi
shell: bash
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
Expand All @@ -26,7 +43,7 @@ jobs:
- name: Restore dependencies
run: dotnet restore RProvider.Tests.sln
- name: Build
run: dotnet fake build -t Build
run: dotnet fake build -t GenerateDocs
- name: Deploy documentation from master
uses: peaceiris/actions-gh-pages@v3
with:
Expand Down
13 changes: 11 additions & 2 deletions src/RProvider.DesignTime/RInteropClient.fs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,18 @@ let startNewServerAsync() : Async<PipeClient<IRInteropServer>> =
Arguments = $"\"%s{exePath}\" %s{arguments}", WindowStyle = ProcessWindowStyle.Hidden,
WorkingDirectory = Path.GetDirectoryName(assemblyLocation) )

// TODO Dynamically get
if startInfo.EnvironmentVariables.ContainsKey("R_HOME") |> not
then startInfo.EnvironmentVariables.Add("R_HOME", "/Library/Frameworks/R.framework/Resources")
then
Logging.logf "R_HOME not set"
match RProvider.Internal.RInit.rHomePath.Force() with
| RInit.RInitResult config ->
Logging.logf $"Setting R_HOME as %s{config.RHome}"
startInfo.EnvironmentVariables.Add("R_HOME", config.RHome)
| RInit.RInitError err ->
Logging.logf $"Starting server process: Unexpected - error not reported: %s{err}"
()

Logging.logf "R_HOME set as %O" startInfo.EnvironmentVariables.["R_HOME"]

// Start the process and wait until it is initialized
// (after initialization, the process deletes the temp file)
Expand Down
26 changes: 19 additions & 7 deletions src/RProvider.Runtime/RInit.fs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,17 @@ let private getRLocation () =
else locateRfromRegistry()
| rPath -> RInitResult rPath

type RLocation = {
DllFile: string
RPath: string
RHome: string
}

/// Find the R installation using 'getRLocation' and add the directory to the
/// current environment varibale PATH (so that later loading can find 'R.dll')
let private findRHomePath () =
let private findRLocation () =
try
Logging.logf "findRHomePath"
Logging.logf "findRLocation"
match getRLocation() with
| RInitError error -> RInitError error
| RInitResult location ->
Expand All @@ -115,17 +121,21 @@ let private findRHomePath () =
| None ->
RInitError (sprintf "No R engine at %s" binPath)
| Some libraryFile ->
Logging.logf "findRHomePath: file='%s'" libraryFile
RInitResult(libraryFile)
Logging.logf "findRLocation: file='%s'" libraryFile
RInitResult({
DllFile = libraryFile
RPath = binPath
RHome = location
})
with e ->
Logging.logf "findRHomePath failed: %O" e
Logging.logf "findRLocation failed: %O" e
reraise()

/// Global interceptor that captures R console output
let internal characterDevice = CharacterDeviceInterceptor()

/// Lazily initialized value that, find the R location or fails and returns RInitError
let rHomePath = lazy(findRHomePath())
let rHomePath = lazy(findRLocation())

/// Lazily initialized R engine.
let internal engine = lazy(
Expand All @@ -135,7 +145,9 @@ let internal engine = lazy(
// If the value was `RInitError`, the error has already been reported by
// `RInteropServer.InitializationErrorMessage` and so we never even get here
match rHomePath.Force() with
| RInitResult res -> res
| RInitResult res ->
REngine.SetEnvironmentVariables(rPath = res.RPath, rHome = res.RHome)
res.DllFile
| RInitError err ->
Logging.logf $"engine: Unexpected - error not reported: %s{err}"
null
Expand Down

0 comments on commit c85cf6f

Please sign in to comment.