Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 72 additions & 1 deletion .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand All @@ -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' }}
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 .",
Expand Down
30 changes: 30 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Loading