From 32f7075b1b7f99a271172b8df60ea43191d14c15 Mon Sep 17 00:00:00 2001 From: Hexagon Date: Mon, 11 Mar 2024 20:09:39 +0100 Subject: [PATCH] Fix bun CI --- .github/workflows/bun.yml | 7 ++- .github/workflows/node.yml | 2 - README.md | 94 +++++++++++++++++++++++--------------- deno.json | 2 +- 4 files changed, 65 insertions(+), 40 deletions(-) diff --git a/.github/workflows/bun.yml b/.github/workflows/bun.yml index 486ed26..246d475 100644 --- a/.github/workflows/bun.yml +++ b/.github/workflows/bun.yml @@ -17,7 +17,12 @@ jobs: steps: - name: Git Checkout uses: actions/checkout@v3 + - name: Use Bun Version ${{ matrix.bun-version }} + uses: antongolub/action-setup-bun@v1.12.8 + with: + bun-version: ${{ matrix.bun-version }} + bun-repo: 'oven-sh/bun' - name: Install Dependencies - run: bunx jsr add @cross/test @std/assert + run: bun x jsr add @cross/runtime @cross/test @std/assert - name: Test Bun Module run: bun test \ No newline at end of file diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml index a27db1b..a9fa728 100644 --- a/.github/workflows/node.yml +++ b/.github/workflows/node.yml @@ -3,8 +3,6 @@ name: Node.js CI -disabled: true - on: push: branches: [ main ] diff --git a/README.md b/README.md index ac6ccc3..b2c89d9 100644 --- a/README.md +++ b/README.md @@ -1,68 +1,90 @@ -## Cross-runtime testing framework for Deno, Bun, and Node.js +## Cross-runtime Testing for Deno, Bun, and Node.js [![JSR Version](https://jsr.io/badges/@cross/test)](https://jsr.io/@cross/test) [![JSR Score](https://jsr.io/badges/@cross/test/score)](https://jsr.io/@cross/test/score) -**Work in progress** +**A minimal testing framework designed for seamless use across Deno, Bun, and Node.js. Works great with @std/assert and @std/expect for assertions.** -Truly cross runtime minimal testing framework working in collaboration with @std/assert, for Node, Deno and Bun. +**Installation** -## Install +1. **Install `@cross/test` and `@std/assert`:** -Node: + ```bash + # Pick your runtime and package manager: + npx jsr add @cross/test @std/assert # Node.js + deno add @cross/test @std/assert # Deno + bunx jsr add @cross/test @std/assert # Bun + ``` -``` -npx jsr add @cross/test @std/assert -``` - -Deno: - -``` -deno add @cross/test @std/assert -``` - -Bun: - -``` -bunx jsr add @cross/test @std/assert -``` +**Example** -## Example - -my.test.js - -```js +```javascript import { test } from "@cross/test"; import { assertEquals, assertNotEquals } from "@std/assert"; -// Simple test test("Multiplication", () => { assertEquals(5 * 4, 20); }); -// Simple test with timeout test("Multiplication with timeout", () => { assertEquals(5 * 4, 20); }, { timeout: 1000 }); -// Test with completion callback test("Async test", (_context, done) => { setTimeout(() => { assertNotEquals(5, 4); - done(); // Signal test completion + done(); }, 500); }, { waitForCallback: true }); ``` -## Running the tests +**Running Tests** + +- **Directly in your runtime:** + - **Node.js:** `node --test` + - **Deno:** `deno test` + - **Bun:** `bun test` + +**CI Integration** + +To avoid cluttering with unnessecary files, use CI to test Node and Bun if you develop using Deno, and vice versa. Below is some example on `.github/workflows/runtime.yml` for automated testing on +GitHub. -Node: +**Example CI Configurations** -`node --test` +- **Bun (GitHub Actions):** -Deno: +```yaml +name: Bun CI -`deno test` +on: [push, pull_request] -Bun: +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: antongolub/action-setup-bun@v1.12.8 + with: + bun-version: v1.x # Uses latest bun 1 + - run: bun x jsr add @cross/test @std/assert # Installs dependencies + - run: bun test # Runs the tests +``` + +- **Deno (GitHub Actions):** + +```yaml +name: Deno CI -`bun test` +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: denoland/setup-deno@v1 + with: + deno-version: v1.x # Uses latest deno version 1 + - run: deno add @cross/test @std/assert # Installs dependencies from jsr.io + - run: deno test # Runs tests +``` diff --git a/deno.json b/deno.json index 9306e46..e8b8431 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@cross/test", - "version": "0.0.7", + "version": "0.0.6", "exports": "./mod.ts", "fmt": { "lineWidth": 200