Skip to content

Commit a48baae

Browse files
authored
Add Bun / Deno / Wrangler alternative JS runtime tests (#172)
1 parent ece080e commit a48baae

File tree

5 files changed

+64
-5
lines changed

5 files changed

+64
-5
lines changed

.github/workflows/test.yml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ jobs:
3030
- name: Run tests
3131
run: ./.tools/run_jvm_tests.sh
3232

33-
build-ts:
33+
build-node:
3434
# prevent from running on forks
3535
if: github.repository_owner == 'restatedev'
3636
runs-on: ubuntu-latest
3737
strategy:
3838
matrix:
39-
node-version: [19.x]
39+
node-version: [20.x]
4040

4141
steps:
4242
- uses: actions/checkout@v3
@@ -50,6 +50,33 @@ jobs:
5050
- name: Run tests
5151
run: ./.tools/run_node_tests.sh
5252

53+
build-altjs:
54+
# prevent from running on forks
55+
if: github.repository_owner == 'restatedev'
56+
runs-on: ubuntu-latest
57+
58+
steps:
59+
- uses: actions/checkout@v3
60+
61+
# We just need npm from Node
62+
- name: Setup Node
63+
uses: actions/setup-node@v3
64+
with:
65+
node-version: 20.x
66+
67+
- name: Setup Bun
68+
uses: oven-sh/setup-bun@v1
69+
with:
70+
bun-version: latest
71+
72+
- name: Setup Deno
73+
uses: denoland/setup-deno@v1
74+
with:
75+
deno-version: v1.x
76+
77+
- name: Run tests
78+
run: ./.tools/run_altjs_tests.sh
79+
5380
build-go:
5481
# prevent from running on forks
5582
if: github.repository_owner == 'restatedev'

.tools/run_altjs_tests.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
set -eufx -o pipefail
4+
5+
SELF_PATH=${BASH_SOURCE[0]:-"$(command -v -- "$0")"}
6+
PROJECT_ROOT="$(dirname "$SELF_PATH")/.."
7+
8+
function bun_install_check() {
9+
pushd $1
10+
bun install
11+
bun run build
12+
popd
13+
}
14+
15+
function deno_install_check() {
16+
pushd $1
17+
deno task build
18+
popd
19+
}
20+
21+
function wrangler_install_check() {
22+
pushd $1
23+
npm install
24+
npm run build
25+
npx wrangler deploy --dry-run --outdir dist
26+
popd
27+
}
28+
29+
wrangler_install_check $PROJECT_ROOT/templates/cloudflare-worker
30+
bun_install_check $PROJECT_ROOT/templates/bun
31+
deno_install_check $PROJECT_ROOT/templates/deno

.tools/run_node_tests.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ npm_install_check $PROJECT_ROOT/basics/basics-typescript
1414
npm_install_check $PROJECT_ROOT/templates/typescript
1515
npm_install_check $PROJECT_ROOT/templates/typescript-lambda-cdk
1616
npm_install_check $PROJECT_ROOT/templates/cloudflare-worker
17-
#npm_install_check $PROJECT_ROOT/templates/bun
1817

1918
npm_install_check $PROJECT_ROOT/templates/typescript-testing
2019
npm --prefix $PROJECT_ROOT/templates/typescript-testing run test

templates/bun/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"type": "module",
44
"version": "0.0.1",
55
"scripts": {
6+
"build": "bun build --target bun --outdir dist src/index.ts",
67
"dev": "bun run --watch src/index.ts",
78
"start": "bun run src/index.ts",
89
"format": "prettier --write \"src/*.+(js|ts|json)\""

templates/deno/deno.jsonc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"tasks": {
3+
"build": "deno check main.ts",
34
"dev": "deno run --allow-net --allow-env --watch main.ts",
4-
"start": "deno run --allow-net --allow-env main.ts"
5-
}
5+
"start": "deno run --allow-net --allow-env main.ts",
6+
},
67
}

0 commit comments

Comments
 (0)