Skip to content

Add a reuseable workflow #1

Add a reuseable workflow

Add a reuseable workflow #1

name: Run and compare benchmarks on different JS runtimes
on:
workflow_call:
inputs:
setup:
type: string
description: Command to bootstrap or setup the repo
required: false
command:
type: string
description: Benchmark command to use in your repo
required: true
node-version:
type: string
description: Nodejs version
required: true
bun-version:
type: string
description: Bun version, if specified will be used in comparison
required: false
deno-version:
type: string
description: Deno version, if specified will be used in comparison
required: false
secrets:
github_token:

Check failure on line 27 in .github/workflows/compare-js-runtimes.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/compare-js-runtimes.yml

Invalid workflow file

secret name `github_token` within `workflow_call` can not be used since it would collide with system reserved name
required: true
description: Github Token used to post the comparison report
jobs:
run-benchmark-nodejs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
- name: Run setup command
if: inputs.setup != ''
run: ${{ inputs.setup }}
- name: Run performance tests on node
run: ${{ inputs.command }} --local ./nodejs-benchmark --persist --noThrow ${{ github.event_name == 'push' }}
- name: Archive nodejs benchmark artifacts
uses: actions/upload-artifact@v4
with:
name: nodejs-benchmark
path: ./nodejs-benchmark
run-benchmark-bun:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- uses: oven-sh/setup-bun@v2
with:
bun-version: ${{ inputs.bun-version }}
- name: Install Dependencies
run: bun install
- name: Run performance tests on bun
run: bun run --bun ${{ inputs.command }} --local ./bun-benchmark --persist --noThrow ${{ github.event_name == 'push' }}
- name: Archive bun benchmark artifacts
uses: actions/upload-artifact@v4
with:
name: bun-benchmark
path: bun-benchmark
run-benchmark-deno:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- uses: denoland/setup-deno@v2
with:
deno-version: ${{ inputs.deno-version }}
- name: Install Dependencies
run: deno install
- name: Run performance tests on bun
run: deno run --unstable-sloppy-imports -A ${{ inputs.command }} --local ./deno-benchmark --persist --noThrow ${{ github.event_name == 'push' }}
- name: Archive deno benchmark artifacts
uses: actions/upload-artifact@v4
with:
name: deno-benchmark
path: deno-benchmark
benchmark-compare:
runs-on: ubuntu-latest
needs: [run-benchmark-deno, run-benchmark-bun, run-benchmark-nodejs]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-node@v4
with:
node-version: "18"
- name: Install
run: yarn install --frozen-lockfile
- name: Download all benchmark artifacts
uses: actions/download-artifact@v4
- name: Run comparison
run: node --loader ts-node/esm ./src/cli/cli.ts cmp nodejs-benchmark deno-benchmark bun-benchmark
env:
GITHUB_TOKEN: ${{ secrets.github_token }}