Skip to content

Commit

Permalink
Merge pull request #128 from superfaceai/feat/nodejs_comlink_package
Browse files Browse the repository at this point in the history
Feat/nodejs comlink package
  • Loading branch information
TheEdward162 authored Feb 8, 2024
2 parents 6e3357f + c47b1f0 commit 46f1316
Show file tree
Hide file tree
Showing 38 changed files with 1,808 additions and 340 deletions.
106 changes: 106 additions & 0 deletions .github/actions/build_core/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: "Prepare core"
description: "Build core components"

inputs:
CARGO_PROFILE:
description: "Cargo profile name to use for cargo cache key"
required: false
default: 'release'
CORE_WASM:
description: "Whether to build core.wasm and core-async.wasm, oneOf `none, build, upload`"
required: false
default: 'none'
TEST_CORE_WASM:
description: "Whether to build test-core.wasm and test-core-async.wasm, oneOf `none, build, upload`"
required: false
default: 'none'
COMLINK_WASM:
description: "Whether to build comlink.wasm, oneOf `none, build, upload`"
required: false
default: 'none'

runs:
using: "composite"
steps:
- uses: actions/setup-node@v4
with:
registry-url: https://registry.npmjs.org/
node-version: "18"
cache: yarn
cache-dependency-path: core_js/yarn.lock
- name: Cache cargo registry and build directory
uses: actions/cache@v4
with:
path: |
~/.cargo/git
~/.cargo/registry/cache
~/.cargo/registry/index
core/target
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-${{ inputs.CARGO_PROFILE }}
restore-keys: |
cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-
cargo-${{ runner.os }}-
- name: Cache WASI SDK
uses: actions/cache@v4
with:
path: core/wasi-sdk-*
key: wasisdk-${{ runner.os }}-${{ runner.arch }}
- name: Install wasm-opt
shell: bash
run: |
sudo apt-get update
sudo apt-get install binaryen
- name: Install rust target
shell: bash
run: rustup target add wasm32-wasi
# build and store core.wasm, core-async.wasm
- name: Run make to build core.wasm
if: ${{ inputs.CORE_WASM != 'none' }}
env:
CARGO_INCREMENTAL: "0" # disable incremental to reduce load on the cache
shell: bash
run: make core/dist/core.wasm core/dist/core-async.wasm OS=${{ runner.os }} CARGO_PROFILE=${{ inputs.CARGO_PROFILE }}
- name: Upload artifact core-async.wasm
if: ${{ inputs.CORE_WASM == 'upload' }}
uses: actions/upload-artifact@v4
with:
name: core-async-wasm
path: core/dist/core-async.wasm
- name: Upload artifact core.wasm
if: ${{ inputs.CORE_WASM == 'upload' }}
uses: actions/upload-artifact@v4
with:
name: core-wasm
path: core/dist/core.wasm
# build and store test-core.wasm and test-core-async.wasm
- name: Run make to build test-core.wasm
if: ${{ inputs.TEST_CORE_WASM != 'none' }}
env:
CARGO_INCREMENTAL: "0" # disable incremental to reduce load on the cache
shell: bash
run: make core/dist/test-core.wasm core/dist/test-core-async.wasm OS=${{ runner.os }} CARGO_PROFILE=${{ inputs.CARGO_PROFILE }}
- name: Upload artifact test-core-async.wasm
if: ${{ inputs.TEST_CORE_WASM == 'upload' }}
uses: actions/upload-artifact@v4
with:
name: test-core-async-wasm
path: core/dist/test-core-async.wasm
- name: Upload artifact test-core.wasm
if: ${{ inputs.TEST_CORE_WASM == 'upload' }}
uses: actions/upload-artifact@v4
with:
name: test-core-wasm
path: core/dist/test-core.wasm
# build and store comlink.wasm
- name: Run make to build comlink.wasm
if: ${{ inputs.COMLINK_WASM != 'none' }}
env:
CARGO_INCREMENTAL: "0"
shell: bash
run: make core/dist/comlink.wasm OS=${{ runner.os }} CARGO_PROFILE=${{ inputs.CARGO_PROFILE }}
- name: Upload artifact comlink.wasm
if: ${{ inputs.COMLINK_WASM == 'upload' }}
uses: actions/upload-artifact@v4
with:
name: comlink-wasm
path: core/dist/comlink.wasm
89 changes: 19 additions & 70 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,80 +6,29 @@ jobs:
name: Core
runs-on: ubuntu-latest
steps:
# checkout
- uses: actions/checkout@v3
# setup
- uses: actions/setup-node@v3
with:
registry-url: https://registry.npmjs.org/
node-version: "18"
cache: yarn
cache-dependency-path: core_js/yarn.lock
- name: Cache cargo registry and build directory
uses: actions/cache@v3
- uses: actions/checkout@v4
- uses: ./.github/actions/build_core
with:
path: |
~/.cargo/git
~/.cargo/registry/cache
~/.cargo/registry/index
core/target
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-debug
restore-keys: |
cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.toml') }}-
cargo-${{ runner.os }}-
- name: Cache WASI SDK
uses: actions/cache@v3
with:
path: core/wasi-sdk-*
key: wasisdk-${{ runner.os }}-${{ runner.arch }}
- name: Install wasm-opt
run: |
sudo apt-get update
sudo apt-get install binaryen
- name: Install rust target
run: rustup target add wasm32-wasi
CARGO_PROFILE: 'debug'
CORE_WASM: 'upload'
TEST_CORE_WASM: 'upload'
- name: Install Wasmtime
run: |
curl https://wasmtime.dev/install.sh -sSf | bash
echo $HOME/.wasmtime/bin >> $GITHUB_PATH
# build and store
- name: Run make to build core
env:
CARGO_INCREMENTAL: "0" # disable incremental to reduce load on the cache
run: make build_core OS=${{ runner.os }}
- name: Upload artifact core-async.wasm
uses: actions/upload-artifact@v3
with:
name: core-async-wasm
path: core/dist/core-async.wasm
- name: Upload artifact core.wasm
uses: actions/upload-artifact@v3
with:
name: core-wasm
path: core/dist/core.wasm
# test
- name: Run tests
working-directory: core
run: cargo test
- name: Upload artifact test-core-async.wasm
uses: actions/upload-artifact@v3
with:
name: test-core-async-wasm
path: core/dist/test-core-async.wasm
- name: Upload artifact core.wasm
uses: actions/upload-artifact@v3
with:
name: test-core-wasm
path: core/dist/test-core.wasm

core_js:
name: Core JS (Map STD)
runs-on: ubuntu-latest
steps:
# checkout
- uses: actions/checkout@v3
- uses: actions/checkout@v4
# setup
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
registry-url: https://registry.npmjs.org/
node-version: "18"
Expand Down Expand Up @@ -112,19 +61,19 @@ jobs:
working-directory: packages/nodejs_host
steps:
# checkout
- uses: actions/checkout@v3
- uses: actions/checkout@v4
# setup
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
registry-url: https://registry.npmjs.org/
node-version: "18"
cache: yarn
cache-dependency-path: packages/nodejs_host/yarn.lock
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: core-async-wasm
path: packages/nodejs_host/assets
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: test-core-async-wasm
path: packages/nodejs_host/assets
Expand All @@ -145,19 +94,19 @@ jobs:
working-directory: packages/cloudflare_worker_host
steps:
# checkout
- uses: actions/checkout@v3
- uses: actions/checkout@v4
# setup
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
registry-url: https://registry.npmjs.org/
node-version: "18"
cache: yarn
cache-dependency-path: packages/cloudflare_worker_host/yarn.lock
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: core-async-wasm
path: packages/cloudflare_worker_host/assets
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: test-core-async-wasm
path: packages/cloudflare_worker_host/assets
Expand All @@ -178,17 +127,17 @@ jobs:
working-directory: packages/python_host
steps:
# checkout
- uses: actions/checkout@v3
- uses: actions/checkout@v4
# setup
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.8"
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: core-wasm
path: packages/python_host/src/one_sdk/assets
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: test-core-wasm
path: packages/python_host/src/one_sdk/assets
Expand Down
Loading

0 comments on commit 46f1316

Please sign in to comment.