Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(runtimes): Bun #4967

Draft
wants to merge 5 commits into
base: janpio/deno-with-patch
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .github/scripts/test-project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ bash .github/scripts/print-version.sh "$pjson_path"
# Install deps for Slack scripts
echo "cd .github/slack/"
cd .github/slack/
pnpm install
# pnpm install
echo "cd ../.."
cd ../..

Expand Down
24 changes: 15 additions & 9 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1872,38 +1872,44 @@ jobs:
fail-fast: false
matrix:
runtime:
- deno
#- bun
#- deno
- bun
clientEngine: ['library', 'binary']
os: [ubuntu-20.04]
runs-on: ${{ matrix.os }}
concurrency: ${{ github.job }}-${{ matrix.runtime }}-${{ matrix.clientEngine }}
env:
RUNTIMES_DENO_DATABASE_URL: ${{ secrets.DATAPROXY_COMMON_URL_SOURCE }}
RUNTIMES_BUN_DATABASE_URL: ${{ secrets.DATAPROXY_COMMON_URL_SOURCE }}

steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v3.0.0
with:
version: 8
# - uses: pnpm/action-setup@v3.0.0
# with:
# version: 8

- uses: actions/setup-node@v4
with:
node-version: 16
cache: 'pnpm'
cache-dependency-path: ${{ github.job }}/${{ matrix.runtime }}/pnpm-lock.yaml
# cache: 'pnpm'
# cache-dependency-path: ${{ github.job }}/${{ matrix.runtime }}/pnpm-lock.yaml

- name: use deno v1.x
uses: denoland/setup-deno@v1
with:
deno-version: v1.38.2

- uses: oven-sh/setup-bun@v1
with:
bun-version: 1.1.8

- name: Define Client Engine Type to test
run: echo "PRISMA_CLIENT_ENGINE_TYPE=${{ matrix.clientEngine }}" >> $GITHUB_ENV

- name: Install Dependencies
run: pnpm install
- name: Install Dependencies via bun
working-directory: ${{ github.job }}/${{ matrix.runtime }}
run: bun install

- name: test ${{ matrix.runtime }}
run: bash .github/scripts/test-project.sh ${{ github.job }} ${{ matrix.runtime }}
Expand Down
1 change: 1 addition & 0 deletions runtimes/bun/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vscode
10 changes: 10 additions & 0 deletions runtimes/bun/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Deno

Runs Prisma Client with Bun.

## How to run this

```sh
source ./prepare.sh && ./run.sh && ./test.sh
```

Binary file added runtimes/bun/bun.lockb
Binary file not shown.
10 changes: 10 additions & 0 deletions runtimes/bun/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "bun",
"license": "MIT",
"dependencies": {
"@prisma/client": "5.15.0-dev.16"
},
"devDependencies": {
"prisma": "5.15.0-dev.16"
}
}
9 changes: 9 additions & 0 deletions runtimes/bun/prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

export PRISMA_TELEMETRY_INFORMATION='ecosystem-tests runtimes bun build'

# Install Bun (not needed on GH Actions, only here for reference for local testing)
# curl -fsSL https://bun.sh/install | bash
# source /home/gitpod/.bashrc

bun -v
33 changes: 33 additions & 0 deletions runtimes/bun/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
generator client {
provider = "prisma-client-js"
// output = "../generated/client"
// engineType = "binary" // overwritten when run in CI via env var
}

datasource db {
provider = "postgresql"
url = env("RUNTIMES_BUN_DATABASE_URL")
}

model Post {
post_id Int @id @default(autoincrement())
content String?
title String
author_id Int?
author User? @relation(fields: [author_id], references: [user_id])
}

model Profile {
bio String?
profile_id Int @id @default(autoincrement())
user_id Int
user User @relation(fields: [user_id], references: [user_id])
}

model User {
email String @unique
name String?
user_id Int @id @default(autoincrement())
posts Post[]
profiles Profile[]
}
5 changes: 5 additions & 0 deletions runtimes/bun/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -eu

bun prisma generate
8 changes: 8 additions & 0 deletions runtimes/bun/src/run.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const { PrismaClient } = require('@prisma/client')

const prisma = new PrismaClient({ log: ['query', 'info', 'warn', 'error'] })

console.log("foo")
const users = await prisma.user.findFirst();
console.log(users)
await prisma.$disconnect()
5 changes: 5 additions & 0 deletions runtimes/bun/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

set -eu

bun src/run.ts
Loading