diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c3000c36..0634b70c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ concurrency: jobs: examples: runs-on: ubuntu-latest - name: Test ${{ matrix.project }} + name: Test ${{ matrix.project }} on Node.js strategy: fail-fast: false matrix: @@ -55,6 +55,32 @@ jobs: env: CI: true + bun: + runs-on: ubuntu-latest + name: Test ${{ matrix.project }} on bun + strategy: + fail-fast: false + matrix: + project: + - helia-101 + defaults: + run: + working-directory: examples/${{ matrix.project }} + steps: + - uses: actions/checkout@v3 + - uses: oven-sh/setup-bun@4bc047ad259df6fc24a6c9b0f9a0cb08cf17fbe5 # v2.0.1 + with: + bun-version: latest + - name: Install dependencies + run: bun install && bun pm trust protobufjs node-datachannel && bun install + - name: Install Playwright + run: bun add --global playwright && playwright install --with-deps + - name: Run tests + run: bun run test + env: + CI: true + NODE_EXEC: bun + monorepo: runs-on: ubuntu-latest name: Test monorepo diff --git a/.gitignore b/.gitignore index 60a1e1f6..a59eff00 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ playwright-report .parcel-cache .envrc .tool-versions +bun.lockb diff --git a/examples/helia-101/bun/loader-node-domexception.ts b/examples/helia-101/bun/loader-node-domexception.ts new file mode 100644 index 00000000..96b70604 --- /dev/null +++ b/examples/helia-101/bun/loader-node-domexception.ts @@ -0,0 +1,17 @@ +import { plugin } from 'bun' + +/** + * node-datachannel requires node-domexception, + * but bun fails with `no default export` error. + */ +await plugin({ + name: 'loader-node-domexception', + async setup(build) { + build.onLoad({ filter: /node-domexception\/index\.js/ }, async (args) => { + return { + contents: 'export default globalThis.DOMException', + loader: 'js', + } + }) + } +}) diff --git a/examples/helia-101/bunfig.toml b/examples/helia-101/bunfig.toml new file mode 100644 index 00000000..de612d1a --- /dev/null +++ b/examples/helia-101/bunfig.toml @@ -0,0 +1 @@ +preload = ["./bun/loader-node-domexception.ts"] diff --git a/examples/helia-101/package.json b/examples/helia-101/package.json index 1c4e64fb..4d2b479a 100644 --- a/examples/helia-101/package.json +++ b/examples/helia-101/package.json @@ -14,17 +14,17 @@ "dependencies": { "@chainsafe/libp2p-noise": "^16.0.0", "@chainsafe/libp2p-yamux": "^7.0.1", - "@helia/http": "^2.0.0", + "@helia/http": "^2.0.1", "@helia/unixfs": "^4.0.0", - "@libp2p/bootstrap": "^11.0.7", - "@libp2p/identify": "^3.0.7", - "@libp2p/tcp": "^10.0.8", + "@libp2p/bootstrap": "^11.0.9", + "@libp2p/identify": "^3.0.9", + "@libp2p/tcp": "^10.0.10", "blockstore-core": "^5.0.2", "datastore-core": "^10.0.2", - "helia": "^5.0.0", - "libp2p": "^2.1.6" + "helia": "^5.1.0", + "libp2p": "^2.1.10" }, "devDependencies": { - "test-ipfs-example": "^1.0.0" + "test-ipfs-example": "^1.3.3" } } diff --git a/examples/helia-101/test/index.spec.js b/examples/helia-101/test/index.spec.js index 4d337dbb..aa663f46 100644 --- a/examples/helia-101/test/index.spec.js +++ b/examples/helia-101/test/index.spec.js @@ -1,11 +1,11 @@ -import path from 'path' -import { fileURLToPath } from 'url' +import path from 'node:path' +import { fileURLToPath } from 'node:url' import { waitForOutput } from 'test-ipfs-example/node' const __dirname = path.dirname(fileURLToPath(import.meta.url)) -await waitForOutput('Added file contents: Hello World 101', 'node', [path.resolve(__dirname, '../101-basics.js')]) +await waitForOutput('Added file contents: Hello World 101', process.env.NODE_EXEC ?? 'node', [path.resolve(__dirname, '../101-basics.js')]) -await waitForOutput('Added file contents: Hello World 201', 'node', [path.resolve(__dirname, '../201-storage.js')]) +await waitForOutput('Added file contents: Hello World 201', process.env.NODE_EXEC ?? 'node', [path.resolve(__dirname, '../201-storage.js')]) -await waitForOutput('Fetched file contents: Hello World 301', 'node', [path.resolve(__dirname, '../301-networking.js')]) +await waitForOutput('Fetched file contents: Hello World 301', process.env.NODE_EXEC ?? 'node', [path.resolve(__dirname, '../301-networking.js')])