Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow custom weval bin #522

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 50 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ jobs:
macos-latest
]
node: [18.x, 20.x, latest]
include:
- os: windows-latest
weval-bin-path: .weval-bin/weval.exe
- os: ubuntu-latest
weval-bin-path: .weval-bin/weval
- os: macos-latest
weval-bin-path: .weval-bin/weval
exclude:
- os: macos-latest
node: 20.x
Expand All @@ -61,19 +68,61 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}

# Determine weval version
- name: Determine weval version
id: weval-meta
shell: bash
run: |
export WEVAL_LATEST_URL=`curl -Ls -o /dev/null -w %{url_effective} https://github.com/bytecodealliance/weval/releases/latest`
export WEVAL_VERSION=${WEVAL_LATEST_URL#https://github.com/bytecodealliance/weval/releases/tag/}
echo -e "version=$WEVAL_VERSION" >> $GITHUB_OUTPUT

# Use cached weval bin if present
- name: Cache weval bin
id: cache-weval-bin
uses: actions/cache@v4
with:
path: .weval-bin
key: weval-bin-${{ steps.weval-meta.outputs.version }}-${{ matrix.os }}

# (no cached weval bin) download weval release
- if: ${{ steps.cache-weval-bin.outputs.cache-hit != 'true' && matrix.os == 'ubuntu-latest' }}
run: |
curl -LO https://github.com/bytecodealliance/weval/releases/download/${{ steps.weval-meta.outputs.version }}/weval-${{ steps.weval-meta.outputs.version }}-x86_64-linux.tar.xz
tar -xvJf weval-${{ steps.weval-meta.outputs.version }}-x86_64-linux.tar.xz
mv weval-${{ steps.weval-meta.outputs.version }}-x86_64-linux/weval .weval-bin
- if: ${{ steps.cache-weval-bin.outputs.cache-hit != 'true' && matrix.os == 'windows-latest' }}
run: |
curl -LO https://github.com/bytecodealliance/weval/releases/download/${{ steps.weval-meta.outputs.version }}/weval-${{ steps.weval-meta.outputs.version }}-x86_64-windows.zip
unzip weval-${{ steps.weval-meta.outputs.version }}-x86_64-windows.zip
mv weval-${{ steps.weval-meta.outputs.version }}-x86_64-windows .weval-bin
- if: ${{ steps.cache-weval-bin.outputs.cache-hit != 'true' && matrix.os == 'macos-latest' }}
run: |
curl -LO https://github.com/bytecodealliance/weval/releases/download/${{ steps.weval-meta.outputs.version }}/weval-${{ steps.weval-meta.outputs.version }}-aarch64-macos.tar.xz
tar -xvJf weval-${{ steps.weval-meta.outputs.version }}-aarch64-macos.tar.xz
mkdir .weval-bin
mv weval-${{ steps.weval-meta.outputs.version }}-aarch64-macos/weval .weval-bin/

# Perform NPM install
- name: Install NPM packages
run: npm ci

- name: Download Build
uses: actions/download-artifact@v4
with:
name: jco-build
path: obj

- name: Test LTS Node.js
run: npm run test:lts
if: matrix.node == '18.x' || matrix.node == '20.x'

- name: Test Latest Node.js
run: npm run test
if: matrix.node == 'latest'
env:
WEVAL_BIN_PATH: ${{ matrix.weval-bin-path }}
run: npm run test

build-wasi-tests:
name: WASI Test Generation
Expand Down
1 change: 1 addition & 0 deletions src/cmd/componentize.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export async function componentize (jsSource, opts) {
const source = await readFile(jsSource, 'utf8');
const { component } = await componentizeFn(source, {
enableAot: opts.aot,
wevalBin: opts.wevalBin,
sourceName: basename(jsSource),
witPath: resolve(opts.wit),
worldName: opts.worldName,
Expand Down
1 change: 1 addition & 0 deletions src/jco.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ program.command('componentize')
.requiredOption('-w, --wit <path>', 'WIT path to build with')
.option('-n, --world-name <name>', 'WIT world to build')
.option('--aot', 'Enable Weval AOT compilation of JS')
.option('--weval-bin <path>', 'Specify a custom weval binary to use')
vados-cosmonic marked this conversation as resolved.
Show resolved Hide resolved
.addOption(new Option('-d, --disable <feature...>', 'disable WASI features').choices(['clocks', 'http', 'random', 'stdio', 'all']))
// .addOption(new Option('-e, --enable <feature...>', 'enable WASI features').choices(['http']))
.option('--preview2-adapter <adapter>', 'provide a custom preview2 adapter path')
Expand Down
11 changes: 8 additions & 3 deletions test/cli.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { resolve } from "node:path";
import { execArgv } from "node:process";
import { execArgv, env } from "node:process";
import { deepStrictEqual, ok, strictEqual } from "node:assert";
import {
mkdir,
Expand Down Expand Up @@ -504,7 +504,7 @@ export async function cliTest(_fixtures) {
});

test("Componentize", async () => {
const { stdout, stderr } = await exec(
const args = [
jcoPath,
"componentize",
"test/fixtures/componentize/source.js",
Expand All @@ -515,7 +515,12 @@ export async function cliTest(_fixtures) {
"test/fixtures/componentize/source.wit",
"-o",
outFile
);
];
if (env.WEVAL_BIN_PATH) {
args.push("--weval-bin", env.WEVAL_BIN_PATH);
}

const { stdout, stderr } = await exec(...args);
strictEqual(stderr, "");
{
const { stderr } = await exec(
Expand Down
Loading