Skip to content

Commit

Permalink
Merge pull request #246 from agracio/macos
Browse files Browse the repository at this point in the history
Adding macOS pre-built binaries
  • Loading branch information
agracio authored Mar 8, 2025
2 parents ed6ee43 + 402ff6a commit 4ffb744
Show file tree
Hide file tree
Showing 30 changed files with 267 additions and 133 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,6 @@ workflows:
matrix:
parameters:
# os: ['linux', 'linux-arm', 'macos']
os: ['linux-arm']
os: ['linux', 'linux-arm']
node-version: ['14', '16' ,'18', '20', '22', '23']

63 changes: 47 additions & 16 deletions .github/actions/build-node/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ runs:
uses: ./.github/actions/setup-env
with:
node: 20
os: windows-2022
os: ${{ inputs.os }}

- name: Get latest Node.js version for v${{ inputs.node }}
id: node-test-version
Expand All @@ -37,12 +37,18 @@ runs:
script: |
try {
const fs = require('fs')
if(${{ inputs.node }} <23){
fs.mkdirSync('release/ia32/${{ inputs.node }}', { recursive: true });
if('${{ runner.os }}' == 'Windows'){
if(${{ inputs.node }} <23){
fs.mkdirSync('release/win32/ia32/${{ inputs.node }}', { recursive: true });
}
fs.mkdirSync('release/win32/x64/${{ inputs.node }}', { recursive: true });
if(${{ inputs.node }} >=20){
fs.mkdirSync('release/win32/arm64/${{ inputs.node }}', { recursive: true });
}
}
fs.mkdirSync('release/x64/${{ inputs.node }}', { recursive: true });
if(${{ inputs.node }} >=20){
fs.mkdirSync('release/arm64/${{ inputs.node }}', { recursive: true });
else if('${{ runner.os }}' == 'macOS'){
fs.mkdirSync(`release/${process.platform}/x64/${{ inputs.node }}`, { recursive: true });
fs.mkdirSync(`release/${process.platform}/arm64/${{ inputs.node }}`, { recursive: true });
}
} catch(err) {
core.error("Error creating release directory")
Expand All @@ -56,28 +62,44 @@ runs:
script: |
try {
const fs = require('fs')
if(${{ inputs.node }} <23){
fs.writeFileSync('release/ia32/${{ inputs.node }}/node.version', '${{ steps.node-test-version.outputs.node-version }}');
if('${{ runner.os }}' == 'Windows'){
if(${{ inputs.node }} <23){
fs.writeFileSync('release/win32/ia32/${{ inputs.node }}/node.version', '${{ steps.node-test-version.outputs.node-version }}');
}
fs.writeFileSync('release/win32/x64/${{ inputs.node }}/node.version', '${{ steps.node-test-version.outputs.node-version }}');
if(${{ inputs.node }} >=20){
fs.writeFileSync('release/win32/arm64/${{ inputs.node }}/node.version', '${{ steps.node-test-version.outputs.node-version }}');
}
}
fs.writeFileSync('release/x64/${{ inputs.node }}/node.version', '${{ steps.node-test-version.outputs.node-version }}');
if(${{ inputs.node }} >=20){
fs.writeFileSync('release/arm64/${{ inputs.node }}/node.version', '${{ steps.node-test-version.outputs.node-version }}');
else if('${{ runner.os }}' == 'macOS'){
fs.writeFileSync(`release/${process.platform}/x64/${{ inputs.node }}/node.version`, '${{ steps.node-test-version.outputs.node-version }}');
fs.writeFileSync(`release/${process.platform}/arm64/${{ inputs.node }}/node.version`, '${{ steps.node-test-version.outputs.node-version }}');
}
} catch(err) {
core.error("Error writing node.version file")
core.setFailed(err)
}
- name: Cache node-gyp
- name: Cache node-gyp Windows
if: runner.os == 'Windows'
uses: actions/cache@v4
env:
cache-name: cache-node-gyp
with:
path: ~\AppData\Local\node-gyp\Cache
key: ${{ steps.node-test-version.outputs.node-version }}

- name: Cache node-gyp macOS
if: runner.os == 'macOS'
uses: actions/cache@v4
env:
cache-name: cache-node-gyp
with:
path: ~/Library/Caches/node-gyp
key: '${{ inputs.os }}-${{ inputs.node}}'

- name: Build ia32
if: ${{ inputs.node <23 }}
if: (runner.os == 'Windows') && (inputs.node <23)
uses: ./.github/actions/build
with:
node: ${{ steps.node-test-version.outputs.node-version }}
Expand All @@ -92,7 +114,7 @@ runs:
arch: 'x64'

- name: Build arm64
if: ${{ inputs.node >=20 }}
if: (inputs.node >=20) || (runner.os == 'macOS')
uses: ./.github/actions/build
with:
node: ${{ steps.node-test-version.outputs.node-version }}
Expand All @@ -101,8 +123,17 @@ runs:

- name: Upload artifacts
uses: actions/upload-artifact@v4
if: success()
if: runner.os == 'Windows' && success()
with:
name: win32-edge-js-${{ inputs.node }}
path: |
release
- name: Upload artifacts
uses: actions/upload-artifact@v4
if: runner.os == 'macOS' && success()
with:
name: edge-js-${{ inputs.node }}
name: darwin-edge-js-${{ inputs.node }}
path: |
release
13 changes: 10 additions & 3 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,19 @@ runs:
run: |
node-gyp configure --target=${{ inputs.node }} --runtime=node --release --arch=${{ inputs.arch }}
if ( '${{ inputs.arch }}' -eq 'arm64'){
if ( '${{ inputs.arch }}' -eq 'arm64' -And '${{ runner.os }}' -eq 'Windows'){
(Get-Content -Raw build/build_managed.vcxproj) -replace '<FloatingPointModel>Strict</FloatingPointModel>', '<!-- <FloatingPointModel>Strict</FloatingPointModel> -->' | Out-File -Encoding Utf8 build/build_managed.vcxproj
(Get-Content -Raw build/edge_coreclr.vcxproj) -replace '<FloatingPointModel>Strict</FloatingPointModel>', '<!-- <FloatingPointModel>Strict</FloatingPointModel> -->' | Out-File -Encoding Utf8 build/edge_coreclr.vcxproj
(Get-Content -Raw build/edge_nativeclr.vcxproj) -replace '<FloatingPointModel>Strict</FloatingPointModel>', '<!-- <FloatingPointModel>Strict</FloatingPointModel> -->' | Out-File -Encoding Utf8 build/edge_nativeclr.vcxproj
}
node-gyp build
cmd /c copy /y build\Release\edge_*.node release\${{ inputs.arch }}\${{ inputs.node-major }}
cmd /c rmdir /S /Q build
if ( '${{ runner.os }}' -eq 'Windows'){
cmd /c copy /y build\Release\edge_*.node release\win32\${{ inputs.arch }}\${{ inputs.node-major }}
cmd /c rmdir /S /Q build
}
if ( '${{ runner.os }}' -eq 'macOS'){
Copy-Item "build/Release/edge_coreclr.node" -Destination "release/darwin/${{ inputs.arch }}/${{ inputs.node-major }}"
node-gyp clean
}
24 changes: 15 additions & 9 deletions .github/actions/setup-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ runs:
path: ~/.cache/node-gyp
key: '${{ inputs.os }}-${{ inputs.node}}'

- name: Cache node-gyp macOs
if: runner.os == 'macOS'
uses: actions/cache@v4
env:
cache-name: cache-node-gyp
with:
path: ~/Library/Caches/node-gyp
key: '${{ inputs.os }}-${{ inputs.node}}'
# - name: Cache node-gyp macOs
# if: runner.os == 'macOS'
# uses: actions/cache@v4
# env:
# cache-name: cache-node-gyp
# with:
# path: ~/Library/Caches/node-gyp
# key: '${{ inputs.os }}-${{ inputs.node}}'



- name: Cache node modules
id: cache-nodemodules
uses: actions/cache@v4
Expand All @@ -57,6 +57,12 @@ runs:
run: |
node -v && npm -v && dotnet --version && node -p process.platform && node -p process.arch
- if: runner.os == 'macOS' && inputs.node <= 16
shell: bash
name: Add missing packages for macOS NodeJs 16
run: |
pip install setuptools
- name: npm install
shell: bash
run: npm i
101 changes: 89 additions & 12 deletions .github/actions/test-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,120 @@ runs:
using: "composite"
steps:

- name: Setup env
uses: ./.github/actions/setup-env
with:
node: ${{ inputs.node }}
os: ${{ inputs.os }}

- name: Create release folder
if: runner.os == 'Windows'
shell: pwsh
run: |
cmd /c if not exist "lib\native\win32\ia32\${{ inputs.node }}" mkdir "lib\native\win32\ia32\${{ inputs.node }}"
cmd /c if not exist "lib\native\win32\x64\${{ inputs.node }}" mkdir "lib\native\win32\x64\${{ inputs.node }}"
cmd /c if not exist "lib\native\win32\arm64\${{ inputs.node }}" mkdir "lib\native\win32\arm64\${{ inputs.node }}"
- name: Create release folder
if: runner.os == 'macOS'
uses: actions/github-script@v7
with:
result-encoding: string
script: |
try {
const fs = require('fs')
fs.mkdirSync('lib/native/darwin/x64/${{ inputs.node }}', { recursive: true });
fs.mkdirSync('lib/native/darwin/arm64/${{ inputs.node }}', { recursive: true });
} catch(err) {
core.error("Error creating release directory")
core.setFailed(err)
}
- name: Download artifacts
if: runner.os == 'Windows'
uses: actions/download-artifact@v4
with:
path: release
pattern: win32-edge-js-${{ inputs.node }}*

- name: Download artifacts
if: runner.os == 'macOS'
uses: actions/download-artifact@v4
with:
path: release
pattern: edge-js-${{ inputs.node }}*
pattern: darwin-edge-js-${{ inputs.node }}*

- name: List artifacts
shell: bash
run: ls -R release

- name: Copy artifacts
if: runner.os == 'Windows'
shell: pwsh
run: |
cmd /c copy /y release\edge-js-${{ inputs.node }}\x64\${{ inputs.node }}\edge_*.node lib\native\win32\x64\${{ inputs.node }}
cmd /c copy /y release\win32-edge-js-${{ inputs.node }}\win32\x64\${{ inputs.node }}\edge_*.node lib\native\win32\x64\${{ inputs.node }}
- name: Copy artifacts
if: runner.os == 'macOS'
uses: actions/github-script@v7
with:
result-encoding: string
script: |
try {
const fs = require('fs')
fs.copyFileSync('release/darwin-edge-js-${{ inputs.node }}/darwin/x64/${{ inputs.node }}/edge_coreclr.node', 'lib/native/darwin/x64/${{ inputs.node }}/edge_coreclr.node');
fs.copyFileSync('release/darwin-edge-js-${{ inputs.node }}/darwin/arm64/${{ inputs.node }}/edge_coreclr.node', 'lib/native/darwin/arm64/${{ inputs.node }}/edge_coreclr.node');
} catch(err) {
core.error("Error creating release directory")
core.setFailed(err)
}
- name: Test
uses: ./.github/actions/test-windows
- name: Setup env
uses: ./.github/actions/setup-env
with:
node: ${{ inputs.node }}

os: ${{ inputs.os }}

- name: Check edge-js Windows pre-built files
if: runner.os == 'Windows'
uses: andstor/file-existence-action@v3
with:
files: "lib/native/win32/${{ runner.arch }}/${{ inputs.node }}/edge_coreclr.node, lib/native/win32/${{ runner.arch }}/${{ inputs.node }}/edge_nativeclr.node"
fail: true
ignore_case: true

- name: Check edge-js macOS pre-built files
if: runner.os == 'macOS'
uses: andstor/file-existence-action@v3
with:
files: "lib/native/darwin/${{ runner.arch }}/${{ inputs.node }}/edge_coreclr.node"
fail: true
ignore_case: true

- name: Run .NET 4.5 tests
if: runner.os == 'Windows'
shell: bash
run: node tools/test.js CI

- name: "Run .net core tests"
shell: bash
run: node tools/test.js CI
env:
EDGE_USE_CORECLR: 1

- name: Test report
uses: ./.github/actions/create-test-report
with:
node: ${{ inputs.node }}
os: ${{ inputs.os }}
name: 'build-tests'


- name: publish test-summary nacOS
if: runner.os == 'macOS'
uses: EnricoMi/publish-unit-test-result-action/macos@v2
with:
check_run_annotations: 'none'
check_name: 'test-summary node-${{ inputs.node }} ${{ inputs.os }}'
files: "test-results.xml"

- name: publish test-summary Windows
if: runner.os == 'Windows'
uses: EnricoMi/publish-unit-test-result-action/windows@v2
with:
check_run_annotations: 'none'
check_name: 'test-summary node-${{ inputs.node }} ${{ inputs.os }}'
files: "test-results.xml"
33 changes: 0 additions & 33 deletions .github/actions/test-windows/action.yml

This file was deleted.

Loading

0 comments on commit 4ffb744

Please sign in to comment.