diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 30bf51ed..e4e221bc 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -5,6 +5,22 @@ name: Check on: pull_request: workflow_call: + inputs: + bun_e2e_mode: + description: 'Bun e2e suite scope: `compatible` (curated subset known to pass) or `full` (entire suite).' + type: string + default: compatible + required: false + workflow_dispatch: + inputs: + bun_e2e_mode: + description: 'Bun e2e suite scope' + type: choice + options: + - compatible + - full + default: compatible + required: true jobs: lint: @@ -53,7 +69,7 @@ jobs: run: npm run test:unit e2e: - name: E2E tests + name: E2E tests (Node.js 24) if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }} runs-on: ubuntu-24.04 @@ -74,3 +90,58 @@ jobs: - name: Run E2E tests run: npm run test:e2e + + bun_unit: + name: Unit tests (Bun) + if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }} + runs-on: ubuntu-24.04 + timeout-minutes: 15 + + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Use Node.js 24 + uses: actions/setup-node@v6 + with: + node-version: 24 + + - name: Install Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + - name: Install Dependencies + run: npm install + + - name: Run unit tests with Bun + run: npm run test:bun + + bun_e2e: + name: E2E tests (Bun, ${{ inputs.bun_e2e_mode || 'compatible' }}) + if: ${{ !contains(github.event.head_commit.message, '[skip ci]') }} + runs-on: ubuntu-24.04 + timeout-minutes: 30 + + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Use Node.js 24 + uses: actions/setup-node@v6 + with: + node-version: 24 + + - name: Install Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + - name: Install Dependencies + run: npm install + + - name: Add localhost-test to Linux hosts file + run: sudo echo "127.0.0.1 localhost-test" | sudo tee -a /etc/hosts + + - name: Run E2E tests (Bun, ${{ inputs.bun_e2e_mode || 'compatible' }}) + run: npm run test:bun:e2e:${{ inputs.bun_e2e_mode || 'compatible' }} diff --git a/package.json b/package.json index 472fe551..d5873ba0 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,9 @@ "test": "nyc cross-env NODE_OPTIONS=--insecure-http-parser mocha 'test/unit/**/*.js' 'test/e2e/**/*.js'", "test:unit": "mocha 'test/unit/**/*.js'", "test:e2e": "nyc cross-env NODE_OPTIONS=--insecure-http-parser mocha 'test/e2e/**/*.js'", + "test:bun": "bun --bun run mocha --no-config --exit 'test/unit/**/*.js'", + "test:bun:e2e:compatible": "bun --bun run mocha --no-config --exit --grep 'throws error' test/e2e/tcp_tunnel.js", + "test:bun:e2e:full": "bun --bun run mocha --no-config --exit 'test/e2e/**/*.js'", "test:docker": "docker build --tag proxy-chain-tests --file test/Dockerfile . && docker run --add-host localhost-test:127.0.0.1 proxy-chain-tests", "test:docker:all": "bash scripts/test-docker-all.sh", "lint": "eslint .", diff --git a/test/README.md b/test/README.md index b96f4b71..4b72a7c7 100644 --- a/test/README.md +++ b/test/README.md @@ -80,3 +80,33 @@ Note: for test in Docker no changes in `/etc/hosts` needed. ```bash npm test test/e2e/anonymize_proxy.js ``` + +### Run tests with Bun + +[Bun](https://bun.com) is supported as an alternative runtime. Install it from +https://bun.com, then run: + +```bash +# Unit tests (always green on Bun, gates every PR) +npm run test:bun + +# E2E tests — curated subset known to pass on Bun +npm run test:bun:e2e:compatible + +# E2E tests — entire suite (some tests rely on Node-only HTTP semantics +# such as HTTP/1.1 pipelining and stream.pipeline behaviour that current +# Bun releases don't fully emulate; expect failures) +npm run test:bun:e2e:full +``` + +In CI, `bun_unit` and `bun_e2e` (in `compatible` mode) run on every PR. +The full Bun e2e suite is opt-in: trigger the **Check** workflow via +**Actions → Check → Run workflow** and pick `full` for the +`bun_e2e_mode` input. + +The `compatible` subset is intentionally narrow today — it only runs the +URL-validation tests in `test/e2e/tcp_tunnel.js` (via `--grep 'throws +error'`), which exercise `createTunnel`'s error paths without touching +the network. As individual networked tests are confirmed to pass on +Bun, widen the `test:bun:e2e:compatible` script in `package.json` (drop +the `--grep`, add files, or list specific test names).