From 575f4c2b8044a882c7b49c3ee5543d9f61680f7d Mon Sep 17 00:00:00 2001 From: Victor Adossi Date: Sat, 9 Nov 2024 02:37:15 +0900 Subject: [PATCH] chore(ci): install weval during CI Signed-off-by: Victor Adossi --- .github/workflows/main.yml | 44 +++++++++++++++++++++++++++++++++++++- .nvmrc | 1 - test/cli.js | 11 +++++++--- 3 files changed, 51 insertions(+), 5 deletions(-) delete mode 100644 .nvmrc diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f00022a70..e0e4e0843 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -45,6 +45,15 @@ jobs: macos-latest ] node: [18.x, 20.x, latest] + weval-version: + - 'v0.3.2' + 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 @@ -61,19 +70,52 @@ jobs: - uses: actions/setup-node@v3 with: node-version: ${{ matrix.node }} + + # 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-${{ matrix.weval-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/${{ matrix.weval-version }}/weval-${{ matrix.weval-version }}-x86_64-linux.tar.xz + tar -xvJf weval-${{ matrix.weval-version }}-x86_64-linux.tar.xz + mv weval-${{ matrix.weval-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/${{ matrix.weval-version }}/weval-${{ matrix.weval-version }}-x86_64-windows.zip + unzip weval-${{ matrix.weval-version }}-x86_64-windows.zip + mv weval-${{ matrix.weval-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/${{ matrix.weval-version }}/weval-${{ matrix.weval-version }}-aarch64-macos.tar.xz + tar -xvJf weval-${{ matrix.weval-version }}-aarch64-macos.tar.xz + mkdir .weval-bin + mv weval-${{ matrix.weval-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 diff --git a/.nvmrc b/.nvmrc deleted file mode 100644 index 67e145bf0..000000000 --- a/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -v20.18.0 diff --git a/test/cli.js b/test/cli.js index 923f051c4..de4632f92 100644 --- a/test/cli.js +++ b/test/cli.js @@ -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, @@ -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", @@ -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(