support nodejs (#438)
This commit is contained in:
1
.github/workflows/dot-net.yaml
vendored
1
.github/workflows/dot-net.yaml
vendored
@@ -4,6 +4,7 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- dot-net
|
||||
- fix-dot-net
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
|
||||
58
.github/workflows/npm.yaml
vendored
Normal file
58
.github/workflows/npm.yaml
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
name: npm
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: npm-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
nodejs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
python-version: ["3.8"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 13
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Display node version
|
||||
shell: bash
|
||||
run: |
|
||||
node --version
|
||||
npm --version
|
||||
cd nodejs-examples
|
||||
|
||||
npm install npm@6.14.4 -g
|
||||
npm install npm@6.14.4
|
||||
npm --version
|
||||
|
||||
- name: Build nodejs package
|
||||
shell: bash
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
run: |
|
||||
cd scripts/nodejs
|
||||
./run.sh
|
||||
npm install
|
||||
rm run.sh
|
||||
npm ci
|
||||
npm publish --provenance --access public
|
||||
59
.github/workflows/test-nodejs-npm.yaml
vendored
Normal file
59
.github/workflows/test-nodejs-npm.yaml
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
name: test-nodejs-npm
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
schedule:
|
||||
# minute (0-59)
|
||||
# hour (0-23)
|
||||
# day of the month (1-31)
|
||||
# month (1-12)
|
||||
# day of the week (0-6)
|
||||
# nightly build at 23:50 UTC time every day
|
||||
- cron: "50 23 * * *"
|
||||
|
||||
concurrency:
|
||||
group: test-nodejs-npm-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
test-nodejs-npm:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest] #, windows-latest]
|
||||
python-version: ["3.8"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 13
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Display node version
|
||||
shell: bash
|
||||
run: |
|
||||
node --version
|
||||
npm --version
|
||||
|
||||
- name: Run tests
|
||||
shell: bash
|
||||
run: |
|
||||
node --version
|
||||
npm --version
|
||||
|
||||
export d=nodejs-examples
|
||||
./.github/scripts/test-nodejs-npm.sh
|
||||
108
.github/workflows/test-nodejs.yaml
vendored
Normal file
108
.github/workflows/test-nodejs.yaml
vendored
Normal file
@@ -0,0 +1,108 @@
|
||||
name: test-nodejs
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: test-nodejs-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
test-nodejs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest] #, windows-latest]
|
||||
python-version: ["3.8"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
with:
|
||||
key: ${{ matrix.os }}-Release-ON
|
||||
|
||||
- name: Configure CMake
|
||||
shell: bash
|
||||
run: |
|
||||
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
|
||||
cmake --version
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=./install ..
|
||||
make -j2
|
||||
make install
|
||||
ls -lh install/lib
|
||||
|
||||
- name: Setup Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Copy files
|
||||
shell: bash
|
||||
run: |
|
||||
os=${{ matrix.os }}
|
||||
if [[ $os == 'ubuntu-latest' ]]; then
|
||||
mkdir -p scripts/nodejs/lib/linux-x64
|
||||
dst=scripts/nodejs/lib/linux-x64
|
||||
elif [[ $os == 'macos-latest' ]]; then
|
||||
mkdir -p scripts/nodejs/lib/osx-x64
|
||||
dst=scripts/nodejs/lib/osx-x64
|
||||
fi
|
||||
cp -v build/install/lib/* $dst/
|
||||
|
||||
- name: replace files
|
||||
shell: bash
|
||||
run: |
|
||||
cd nodejs-examples
|
||||
files=$(ls -1 *.js)
|
||||
for f in ${files[@]}; do
|
||||
echo $f
|
||||
sed -i.bak s%\'sherpa-onnx\'%\'./index.js\'% $f
|
||||
git status
|
||||
done
|
||||
git diff
|
||||
cp *.js ../scripts/nodejs
|
||||
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 13
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Display node version
|
||||
shell: bash
|
||||
run: |
|
||||
node --version
|
||||
npm --version
|
||||
|
||||
- name: Run tests
|
||||
shell: bash
|
||||
run: |
|
||||
node --version
|
||||
npm --version
|
||||
export d=scripts/nodejs
|
||||
|
||||
pushd $d
|
||||
npm install
|
||||
npm install wav
|
||||
popd
|
||||
|
||||
./.github/scripts/test-nodejs-npm.sh
|
||||
Reference in New Issue
Block a user