From 1e2d6c816ec873606e8527832d2945328690b6af Mon Sep 17 00:00:00 2001 From: Pavel Tcholakov Date: Mon, 22 Jul 2024 15:37:46 +0200 Subject: [PATCH 1/4] Add alternative JS runtimes CI tests --- .tools/run_node_tests.sh | 28 ++++++++++++++++++++++++++-- templates/bun/package.json | 1 + templates/deno/deno.jsonc | 5 +++-- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/.tools/run_node_tests.sh b/.tools/run_node_tests.sh index d962ad2a..8cb5ced8 100755 --- a/.tools/run_node_tests.sh +++ b/.tools/run_node_tests.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +set -eufx -o pipefail + SELF_PATH=${BASH_SOURCE[0]:-"$(command -v -- "$0")"} PROJECT_ROOT="$(dirname "$SELF_PATH")/.." @@ -7,12 +9,34 @@ function npm_install_check() { npm install --prefix $1 && npm --prefix $1 run build } +function bun_install_check() { + pushd $1 + bun install + bun run build + popd +} + +function deno_install_check() { + pushd $1 + deno task build + popd +} + +function wrangler_install_check() { + pushd $1 + npm install + npm run build + npx wrangler deploy --dry-run --outdir dist + popd +} + npm_install_check $PROJECT_ROOT/basics/basics-typescript npm_install_check $PROJECT_ROOT/templates/typescript npm_install_check $PROJECT_ROOT/templates/typescript-lambda-cdk -npm_install_check $PROJECT_ROOT/templates/cloudflare-worker -npm_install_check $PROJECT_ROOT/templates/bun +wrangler_install_check $PROJECT_ROOT/templates/cloudflare-worker +bun_install_check $PROJECT_ROOT/templates/bun +deno_install_check $PROJECT_ROOT/templates/deno npm_install_check $PROJECT_ROOT/tutorials/tour-of-restate-typescript diff --git a/templates/bun/package.json b/templates/bun/package.json index b63f44d0..fdf529dd 100644 --- a/templates/bun/package.json +++ b/templates/bun/package.json @@ -3,6 +3,7 @@ "type": "module", "version": "0.0.1", "scripts": { + "build": "bun build --target bun --outdir dist src/index.ts", "dev": "bun run --watch src/index.ts", "start": "bun run src/index.ts", "format": "prettier --write \"src/*.+(js|ts|json)\"" diff --git a/templates/deno/deno.jsonc b/templates/deno/deno.jsonc index 841d7663..1b6621e1 100644 --- a/templates/deno/deno.jsonc +++ b/templates/deno/deno.jsonc @@ -1,6 +1,7 @@ { "tasks": { + "build": "deno check main.ts", "dev": "deno run --allow-net --allow-env --watch main.ts", - "start": "deno run --allow-net --allow-env main.ts" - } + "start": "deno run --allow-net --allow-env main.ts", + }, } From 06362e2e75fe1940c2b585058ec6dd73b36183a3 Mon Sep 17 00:00:00 2001 From: Pavel Tcholakov Date: Mon, 22 Jul 2024 15:50:53 +0200 Subject: [PATCH 2/4] Add separate workflow for alternative JS runtimes --- .github/workflows/test.yml | 44 ++++++++++++++++++++++++++++++++------ .tools/run_altjs_tests.sh | 31 +++++++++++++++++++++++++++ .tools/run_node_tests.sh | 25 +--------------------- 3 files changed, 69 insertions(+), 31 deletions(-) create mode 100755 .tools/run_altjs_tests.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ade1b09f..59347097 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,9 +2,9 @@ name: Build and test on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] jobs: build-jvm: @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - jvm-version: [ 17 ] + jvm-version: [17, 21] steps: - uses: actions/checkout@v3 @@ -21,7 +21,7 @@ jobs: - name: Use JVM ${{ matrix.jvm-version }} uses: actions/setup-java@v4 with: - distribution: 'temurin' + distribution: "temurin" java-version: ${{ matrix.jvm-version }} - name: Setup Gradle @@ -30,13 +30,13 @@ jobs: - name: Run tests run: ./.tools/run_jvm_tests.sh - build-ts: + build-node: # prevent from running on forks if: github.repository_owner == 'restatedev' runs-on: ubuntu-latest strategy: matrix: - node-version: [19.x] + node-version: [20.x, 22.x] steps: - uses: actions/checkout@v3 @@ -45,7 +45,37 @@ jobs: uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - registry-url: 'https://registry.npmjs.org' + registry-url: "https://registry.npmjs.org" - name: Run tests run: ./.tools/run_node_tests.sh + + build-altjs: + # prevent from running on forks + if: github.repository_owner == 'restatedev' + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [20.x] + + steps: + - uses: actions/checkout@v3 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + registry-url: "https://registry.npmjs.org" + + - name: Setup Bun + uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + + - name: Setup Deno + uses: denoland/setup-deno@v1 + with: + deno-version: v1.x + + - name: Run tests + run: ./.tools/run_altjs_tests.sh diff --git a/.tools/run_altjs_tests.sh b/.tools/run_altjs_tests.sh new file mode 100755 index 00000000..c60e7494 --- /dev/null +++ b/.tools/run_altjs_tests.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +set -eufx -o pipefail + +SELF_PATH=${BASH_SOURCE[0]:-"$(command -v -- "$0")"} +PROJECT_ROOT="$(dirname "$SELF_PATH")/.." + +function bun_install_check() { + pushd $1 + bun install + bun run build + popd +} + +function deno_install_check() { + pushd $1 + deno task build + popd +} + +function wrangler_install_check() { + pushd $1 + npm install + npm run build + npx wrangler deploy --dry-run --outdir dist + popd +} + +wrangler_install_check $PROJECT_ROOT/templates/cloudflare-worker +bun_install_check $PROJECT_ROOT/templates/bun +deno_install_check $PROJECT_ROOT/templates/deno diff --git a/.tools/run_node_tests.sh b/.tools/run_node_tests.sh index 8cb5ced8..79b8abf7 100755 --- a/.tools/run_node_tests.sh +++ b/.tools/run_node_tests.sh @@ -9,34 +9,11 @@ function npm_install_check() { npm install --prefix $1 && npm --prefix $1 run build } -function bun_install_check() { - pushd $1 - bun install - bun run build - popd -} - -function deno_install_check() { - pushd $1 - deno task build - popd -} - -function wrangler_install_check() { - pushd $1 - npm install - npm run build - npx wrangler deploy --dry-run --outdir dist - popd -} - npm_install_check $PROJECT_ROOT/basics/basics-typescript npm_install_check $PROJECT_ROOT/templates/typescript npm_install_check $PROJECT_ROOT/templates/typescript-lambda-cdk -wrangler_install_check $PROJECT_ROOT/templates/cloudflare-worker -bun_install_check $PROJECT_ROOT/templates/bun -deno_install_check $PROJECT_ROOT/templates/deno +npm_install_check $PROJECT_ROOT/templates/cloudflare-worker npm_install_check $PROJECT_ROOT/tutorials/tour-of-restate-typescript From 7c9c8ef85cc54b2a8845ac9f31689e03cd219591 Mon Sep 17 00:00:00 2001 From: Pavel Tcholakov Date: Mon, 22 Jul 2024 15:55:26 +0200 Subject: [PATCH 3/4] Remove matrix strategy from altjs path --- .github/workflows/test.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 59347097..9179f66d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - jvm-version: [17, 21] + jvm-version: [17] steps: - uses: actions/checkout@v3 @@ -36,7 +36,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [20.x, 22.x] + node-version: [20.x] steps: - uses: actions/checkout@v3 @@ -51,21 +51,20 @@ jobs: run: ./.tools/run_node_tests.sh build-altjs: + name: Bun / Deno / Cloudflare alternative runtimes + # prevent from running on forks if: github.repository_owner == 'restatedev' runs-on: ubuntu-latest - strategy: - matrix: - node-version: [20.x] steps: - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} + # We just need npm from Node + - name: Setup Node uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node-version }} - registry-url: "https://registry.npmjs.org" + node-version: 20.x - name: Setup Bun uses: oven-sh/setup-bun@v1 From 48fbf168afab609acf4e3db431f24c4dca525695 Mon Sep 17 00:00:00 2001 From: Pavel Tcholakov Date: Tue, 23 Jul 2024 15:35:16 +0200 Subject: [PATCH 4/4] Remove explicit name for build-alt workflow --- .github/workflows/test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 74714c2d..93996800 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -51,8 +51,6 @@ jobs: run: ./.tools/run_node_tests.sh build-altjs: - name: Bun / Deno / Cloudflare alternative runtimes - # prevent from running on forks if: github.repository_owner == 'restatedev' runs-on: ubuntu-latest