Skip to content

Commit

Permalink
merging from master
Browse files Browse the repository at this point in the history
  • Loading branch information
agracio committed May 8, 2024
1 parent 70521e9 commit b00548e
Show file tree
Hide file tree
Showing 9 changed files with 105 additions and 200 deletions.
64 changes: 37 additions & 27 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Main
name: CI

on:
push:
Expand All @@ -14,21 +14,30 @@ on:
- 'Dockerfile'
- '.gitconfig'
- '.gitignore'
- 'appveyor.*'
- 'appveyor*.*'
- 'LICENSE*'
- '.idea/**'
- '.vscode/**'
- '*.bat'
- '*.nuspec'
- 'tools/nuget/*'
- '.npmignore'
- 'test/config.json'
- 'test/config.json'
- 'test/double'

env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true # required to setup CSC

jobs:
main:
build-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-2019]
node: [21.x, 20.x, 18.x, 16.x]
# os: [macos-latest, ubuntu-latest, windows-2019]
# node: [21.x, 20.x, 18.x, 16.x]
os: [macos-14]
node: [20.x]
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -47,42 +56,43 @@ jobs:
with:
dotnet-version: '8.0.x' # SDK Version to use; x will use the latest version of the 8.0 channel

- if: runner.os == 'macOS'
name: Remove Mono from macOS # Mono interferes with Core CLR gyp compile
run: |
sudo rm -rf /Library/Frameworks/Mono.framework
sudo pkgutil --forget com.xamarin.mono-MDK.pkg
sudo rm /etc/paths.d/mono-commands
- name: Versions
run: node -v && npm -v && dotnet --version && node -p process.platform && node -p process.arch

# - if: runner.os == 'macOS'
# name: Mono
# run: |
# which mono
# export PKG_CONFIG_PATH="/Library/Frameworks/Mono.framework/Versions/Current/lib/pkgconfig":$PKG_CONFIG_PATH
# name: Remove Mono from macOS # Incomplete Mono install interferes with gyp compile
# run: |
# sudo rm -rf /Library/Frameworks/Mono.framework
# sudo pkgutil --forget com.xamarin.mono-MDK.pkg
# sudo rm /etc/paths.d/mono-commands

- if: runner.os == 'macOS' && matrix.node == '16.x'
name: Add missing packages for macOS NodeJs 16 # Mono interferes with Core CLR gyp compile
name: Add missing packages for macOS NodeJs 16
run: |
pip install setuptools
- name: npm install
run: npm i
run: npm ci

- if: runner.os == 'Windows'
name: Run .NET 4.x tests
run: npm test
- if: runner.os == 'Windows'
name: Create .NET 4.x tests report
run: node tools/coverage.js
run: node tools/test.js CI

- name: "Run .net core tests"
run: npm test
env:
EDGE_USE_CORECLR: 1

- name: "Create .net core tests report"
run: node tools/coverage.js
run: node tools/test.js CI
env:
EDGE_USE_CORECLR: 1

- name: Test Report
uses: dorny/test-reporter@v1
uses: phoenix-actions/test-reporting@v15
if: success()
with:
name: Test results (${{ matrix.os }}, ${{ matrix.node }}) # Name of the check run which will be created
path: test-results.xml # Path to test results
reporter: jest-junit # Format of test results
name: Tests (${{ matrix.os }}, ${{ matrix.node }}) # Name of the check run which will be created
path: mochawesome.json # Path to test results
reporter: mochawesome-json
fail-on-error: false

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ tools/*.nupkg
tools/*.zip
tools/nuget.exe

test-results*.*
*test-results*.*
TemporaryGeneratedFile*.*
/lib/native/win32/ia32/*/concrt140.dll
/lib/native/win32/ia32/*/msvcp140.dll
/lib/native/win32/ia32/*/vccorlib140.dll
Expand Down
30 changes: 12 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
### This library is based on https://github.com/tjanczuk/edge all credit for original work goes to Tomasz Janczuk.
------

## Introduction
## Overview

**Edge.js allows you to run Node.js and .NET code in one process on Windows, macOS, and Linux.**
**Edge.js allows you to run Node.js and .NET code in one process on Windows, macOS, and Linux**

You can call .NET functions from Node.js and Node.js functions from .NET.
Edge.js takes care of marshaling data between CLR and V8. Edge.js also reconciles threading models of single-threaded V8 and multi-threaded CLR.
Expand Down Expand Up @@ -47,19 +47,6 @@ For use with Electron refer to `electron-edge-js` https://github.com/agracio/ele
Sample app that shows how to work with .NET Core using inline code and compiled C# libraries.
https://github.com/agracio/edge-js-quick-start

## macOS

`edge-js` will fail to build on macOS if Visual Studio for Mac is installed.
VS installs incomplete Mono runtimes that `edge-js` fails to access during `npm install`.
Removing VS does not remove Mono fully and leaves behind an incomplete Mono install.
To remove Mono from macOS use this script

```bash
sudo rm -rf /Library/Frameworks/Mono.framework
sudo pkgutil --forget com.xamarin.mono-MDK.pkg
sudo rm /etc/paths.d/mono-commands
```

## Node.Js Versions

| Version | Status |
Expand Down Expand Up @@ -116,7 +103,7 @@ When packaging your application using Webpack make sure that `edge-js` is specif

| Framework | Platform | NPM Package | Language code | Documentation |
| ----------- | ------------ | ----------- |-------------- | ------------- |
| .NET 4.5 | Windows | `edge-fs` | `fs` | [Script F# in Node.js](#how-to-script-f-in-a-nodejs-application) |
| ~~.NET 4.5~~ | ~~Windows~~ | ~~`edge-fs`~~ | ~~`fs`~~ | ~~[Script F# in Node.js](#how-to-script-f-in-a-nodejs-application)~~ |
| CoreCLR | Any | In development | N/A| N/A |

### Python (IronPython) scripting
Expand Down Expand Up @@ -321,7 +308,14 @@ getPerson({name: 'John Smith', email: 'john.smith@myemailprovider', age: 35}, fu

```

### :exclamation: `edge.func()` only supports `public async Task<object> MyMethod(dynamic input)` C# methods.
### Edge.js C# method must have the following signature

```cs
public async Task<object> MyMethod(dynamic input)
{
//return results sync/async;
}
```

### Executing synchronously without function callback

Expand Down Expand Up @@ -2001,7 +1995,7 @@ The edge module is intended to remain a very small component with core functiona

## More

Issues? Feedback? You [know what to do](https://github.com/tjanczuk/edge/issues/new). Pull requests welcome.
Issues? Feedback? You [know what to do](https://github.com/agracio/edge-js/issues/new). Pull requests welcome.

[dependencies-url]: https://www.npmjs.com/package/edge-js?activeTab=dependencies
[dependencies-img]: https://img.shields.io/librariesio/release/npm/edge-js.svg?style=flat-square
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ environment:
- nodejs: "16"

install:
- sh: if [ "$APPVEYOR_BUILD_WORKER_IMAGE" = 'Ubuntu2204' ]; then sudo apt-get -qq update && sudo apt-get -y -qq install build-essential libgconf-2-4 python3 libglib2.0-dev; fi
# - sh: if [ "$APPVEYOR_BUILD_WORKER_IMAGE" = 'Ubuntu2204' ]; then sudo apt-get -qq update && sudo apt-get -y -qq install build-essential libgconf-2-4 python3 libglib2.0-dev; fi
# - cmd: powershell .\appveyor.ps1
- cmd: powershell Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs) x64
- sh: nvm ls
Expand Down
76 changes: 32 additions & 44 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -204,50 +204,38 @@
[
'"<!((which mono 2>/dev/null) || echo not_found)"!="not_found"',
{
'sources+': [
'src/mono/clractioncontext.cpp',
'src/mono/clrfunc.cpp',
'src/mono/clrfuncinvokecontext.cpp',
'src/mono/monoembedding.cpp',
'src/mono/task.cpp',
'src/mono/dictionary.cpp',
'src/mono/nodejsfunc.cpp',
'src/mono/nodejsfuncinvokecontext.cpp',
'src/mono/utils.cpp',
'src/common/utils.cpp',
'src/common/v8synchronizationcontext.cpp',
'src/common/callbackhelper.cpp',
'src/common/edge.cpp'
],
'conditions':
[
[
'"<!((pkg-config mono-2 --libs 2>/dev/null) || echo not_found)"!="not_found"',
{
'include_dirs': [
'<!@(pkg-config mono-2 --cflags-only-I | sed s/-I//g)',
'<!@(pkg-config glib-2.0 --cflags-only-I | sed s/-I//g)',
],
'link_settings': {
'libraries': [
'<!@(pkg-config mono-2 --libs)'
]
}
},
'"<!((pkg-config mono-2 --libs 2>/dev/null) || echo not_found)"=="not_found"',
{
'include_dirs': [
'<!@(<(DFLT_PKG_CONFIG_PATH) pkg-config mono-2 --cflags-only-I | sed s/-I//g)',
'<!@(pkg-config glib-2.0 --cflags-only-I | sed s/-I//g)',
],
'link_settings': {
'libraries': [
'<!@(<(DFLT_PKG_CONFIG_PATH) pkg-config mono-2 --libs)'
]
}
}
]
],
'conditions': [
[
'"<!((pkg-config mono-2 --libs 2>/dev/null) || echo not_found)"!="not_found"',
{
'sources+': [
'src/mono/clractioncontext.cpp',
'src/mono/clrfunc.cpp',
'src/mono/clrfuncinvokecontext.cpp',
'src/mono/monoembedding.cpp',
'src/mono/task.cpp',
'src/mono/dictionary.cpp',
'src/mono/nodejsfunc.cpp',
'src/mono/nodejsfuncinvokecontext.cpp',
'src/mono/utils.cpp',
'src/common/utils.cpp',
'src/common/v8synchronizationcontext.cpp',
'src/common/callbackhelper.cpp',
'src/common/edge.cpp'
],

'include_dirs': [
'<!@(pkg-config mono-2 --cflags-only-I | sed s/-I//g)',
'<!@(pkg-config glib-2.0 --cflags-only-I | sed s/-I//g)',
],
'link_settings': {
'libraries': [
'<!@(pkg-config mono-2 --libs)'
]
}
}
]
],
},
{
'type': 'none'
Expand Down
38 changes: 19 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"devDependencies": {
"follow-redirects": "^1.15.6",
"junit-report-merger": "6.0.3",
"junit-report-merger": "7.0.0",
"mocha": "10.4.0",
"mocha-junit-reporter": "^2.2.1",
"mocha-multi-reporters": "^1.5.1",
Expand Down
2 changes: 1 addition & 1 deletion src/common/clrfuncreflectionwrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static ClrFuncReflectionWrap Create(Assembly assembly, String typeName, S
if (wrap.invokeMethod == null)
{
throw new System.InvalidOperationException(
"Unable to access the CLR method to wrap through reflection. Make sure it is a public instance method.");
$"Unable to access the CLR method to wrap through reflection. Make sure it is a public instance method.\r\nType: {typeName}, Method: {methodName}, Assembly: {assembly.GetName().FullName}");
}

return wrap;
Expand Down
Loading

0 comments on commit b00548e

Please sign in to comment.