From a79565b5fd99788d4ae2de4c5e65231a96e2fd94 Mon Sep 17 00:00:00 2001 From: Dylan Staley <88163+dstaley@users.noreply.github.com> Date: Sun, 17 May 2026 11:01:31 -0500 Subject: [PATCH] update to zig 0.16 and switch to node --- .github/workflows/ci.yml | 12 ++++++------ build.zig | 6 +++--- bun.lock | 20 -------------------- package.json | 2 +- pnpm-lock.yaml | 29 +++++++++++++++++++++++++++++ wasm.test.mts | 13 ++++++------- 6 files changed, 45 insertions(+), 37 deletions(-) delete mode 100644 bun.lock create mode 100644 pnpm-lock.yaml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c2be708..6f2131c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: - uses: mlugg/setup-zig@v2 with: - version: 0.15.2 + version: 0.16.0 - name: Check C code formatting run: find . \( -name "*.c" -o -name "*.h" \) -print0 | xargs -0 clang-format --dry-run --Werror @@ -28,7 +28,7 @@ jobs: - uses: mlugg/setup-zig@v2 with: - version: 0.15.2 + version: 0.16.0 - name: Run tests (data) run: zig build test-data --summary all @@ -50,14 +50,14 @@ jobs: - uses: mlugg/setup-zig@v2 with: - version: 0.15.2 + version: 0.16.0 - - uses: oven-sh/setup-bun@v2 + - uses: actions/setup-node@v6 with: - bun-version: 1.3.5 + node-version: 26.x - name: Build wasm run: zig build wasm - name: Run tests (wasm) - run: bun test + run: node --test diff --git a/build.zig b/build.zig index 25c29bc..9c07fa4 100644 --- a/build.zig +++ b/build.zig @@ -27,7 +27,7 @@ pub fn build(b: *std.Build) void { .link_libc = true, }), }); - test_data.addCSourceFiles(.{ .files = c_sources, .flags = c_flags }); + test_data.root_module.addCSourceFiles(.{ .files = c_sources, .flags = c_flags }); test_data.root_module.addIncludePath(b.path("src")); const run_test_data = b.addRunArtifact(test_data); @@ -44,7 +44,7 @@ pub fn build(b: *std.Build) void { .link_libc = true, }), }); - test_lib.addCSourceFiles(.{ .files = c_sources, .flags = c_flags }); + test_lib.root_module.addCSourceFiles(.{ .files = c_sources, .flags = c_flags }); test_lib.root_module.addIncludePath(b.path("src")); const run_test_lib = b.addRunArtifact(test_lib); @@ -69,7 +69,7 @@ pub fn build(b: *std.Build) void { .optimize = .ReleaseSmall, }), }); - wasm.addCSourceFiles(.{ .files = c_sources, .flags = c_flags }); + wasm.root_module.addCSourceFiles(.{ .files = c_sources, .flags = c_flags }); wasm.root_module.addIncludePath(b.path("src")); wasm.entry = .disabled; wasm.rdynamic = true; diff --git a/bun.lock b/bun.lock deleted file mode 100644 index e959b31..0000000 --- a/bun.lock +++ /dev/null @@ -1,20 +0,0 @@ -{ - "lockfileVersion": 1, - "configVersion": 1, - "workspaces": { - "": { - "devDependencies": { - "@types/bun": "^1.3.5", - }, - }, - }, - "packages": { - "@types/bun": ["@types/bun@1.3.5", "", { "dependencies": { "bun-types": "1.3.5" } }, "sha512-RnygCqNrd3srIPEWBd5LFeUYG7plCoH2Yw9WaZGyNmdTEei+gWaHqydbaIRkIkcbXwhBT94q78QljxN0Sk838w=="], - - "@types/node": ["@types/node@24.10.4", "", { "dependencies": { "undici-types": "7.16.0" } }, "sha512-vnDVpYPMzs4wunl27jHrfmwojOGKya0xyM3sH+UE5iv5uPS6vX7UIoh6m+vQc5LGBq52HBKPIn/zcSZVzeDEZg=="], - - "bun-types": ["bun-types@1.3.5", "", { "dependencies": { "@types/node": "24.10.4" } }, "sha512-inmAYe2PFLs0SUbFOWSVD24sg1jFlMPxOjOSSCYqUgn4Hsc3rDc7dFvfVYjFPNHtov6kgUeulV4SxbuIV/stPw=="], - - "undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="], - } -} diff --git a/package.json b/package.json index 4fcb3b6..8f54b12 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { "devDependencies": { - "@types/bun": "^1.3.5" + "@types/node": "^25.8.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..03dda35 --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,29 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + devDependencies: + '@types/node': + specifier: ^25.8.0 + version: 25.8.0 + +packages: + + '@types/node@25.8.0': + resolution: {integrity: sha512-TCFSk8IZh+iLX1xtksoBVtdmgL+1IX0fC9BeU4QqFSuNdN/K+HUlhqOzEmSYYpZUVsLYcPqc9KX+60iDuninSQ==} + + undici-types@7.24.6: + resolution: {integrity: sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==} + +snapshots: + + '@types/node@25.8.0': + dependencies: + undici-types: 7.24.6 + + undici-types@7.24.6: {} diff --git a/wasm.test.mts b/wasm.test.mts index b495d2a..626fba2 100644 --- a/wasm.test.mts +++ b/wasm.test.mts @@ -1,6 +1,7 @@ -import { expect, test } from "bun:test"; -import wasmUrl from "./zig-out/calcHashAB.wasm"; -import testData from "./test-data.json"; +import test from "node:test"; +import assert from "node:assert/strict"; +import source wasmModule from "./zig-out/calcHashAB.wasm"; +import testData from "./test-data.json" with { type: "json" }; function hexToBytes(hex: string): Uint8Array { const bytes = new Uint8Array(hex.length / 2); @@ -16,9 +17,7 @@ function bytesToHex(bytes: Uint8Array): string { .join(""); } -const wasmBuffer = await Bun.file(wasmUrl).arrayBuffer(); - -const { instance } = await WebAssembly.instantiate(wasmBuffer, {}); +const instance = await WebAssembly.instantiate(wasmModule, {}); const { getInputSha1, getInputUuid, getOutput, calculateHash, memory } = instance.exports as { @@ -48,6 +47,6 @@ for (const testCase of testData) { const result = mem.slice(outputPtr, outputPtr + 57); const resultHex = bytesToHex(result); - expect(resultHex).toBe(testCase.target); + assert.strictEqual(resultHex, testCase.target); }); }