-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Joël Galeran <[email protected]>
- Loading branch information
Showing
14 changed files
with
299 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,6 +105,7 @@ jobs: | |
- databases | ||
- databases-macos | ||
- test-runners | ||
- runtimes | ||
if: always() | ||
steps: | ||
- run: echo "Ok" | ||
|
@@ -137,6 +138,7 @@ jobs: | |
- databases | ||
- databases-macos | ||
- test-runners | ||
- runtimes | ||
if: success() && (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/integration' || github.ref == 'refs/heads/patch-dev' || github.ref == 'refs/heads/latest') | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
@@ -179,6 +181,7 @@ jobs: | |
- databases | ||
- databases-macos | ||
- test-runners | ||
- runtimes | ||
if: failure() && (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/integration' || github.ref == 'refs/heads/patch-dev' || github.ref == 'refs/heads/latest') | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
@@ -1682,6 +1685,57 @@ jobs: | |
if: failure() | ||
run: bash .github/slack/notify-failure.sh ${{ github.job }} ${{ matrix.test-runner }} | ||
|
||
|
||
runtimes: | ||
needs: [detect_jobs_to_run] | ||
if: contains(fromJSON(needs.detect_jobs_to_run.outputs.jobs), 'runtimes') | ||
|
||
timeout-minutes: 10 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
runtime: | ||
- 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 }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: pnpm/[email protected] | ||
with: | ||
version: 8 | ||
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 16 | ||
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.44.2 | ||
|
||
- name: Define Client Engine Type to test | ||
run: echo "PRISMA_CLIENT_ENGINE_TYPE=${{ matrix.clientEngine }}" >> $GITHUB_ENV | ||
|
||
- name: Install Dependencies | ||
run: pnpm install | ||
|
||
- name: test ${{ matrix.runtime }} | ||
run: bash .github/scripts/test-project.sh ${{ github.job }} ${{ matrix.runtime }} | ||
|
||
- name: notify-slack | ||
if: failure() | ||
run: bash .github/slack/notify-failure.sh ${{ github.job }} ${{ matrix.runtime }} | ||
|
||
|
||
process-managers: | ||
needs: [detect_jobs_to_run] | ||
if: contains(fromJSON(needs.detect_jobs_to_run.outputs.jobs), 'process-managers') | ||
|
@@ -1696,7 +1750,6 @@ jobs: | |
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Define Client Engine Type to test | ||
run: echo "PRISMA_CLIENT_ENGINE_TYPE=${{ matrix.clientEngine }}" >> $GITHUB_ENV | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.vscode | ||
generated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Deno | ||
|
||
Runs Prisma Client with Deno. | ||
|
||
## How to run this | ||
|
||
```sh | ||
source ./prepare.sh && ./run.sh && ./test.sh | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "deno", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@prisma/client": "5.15.0-dev.16" | ||
}, | ||
"devDependencies": { | ||
"prisma": "5.15.0-dev.16" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 deno build' | ||
|
||
# Install Deno CLI (not needed on GH Actions, only here for reference for local testing) | ||
# curl -fsSL https://deno.land/x/install/install.sh | sh | ||
# alias deno='/home/gitpod/.deno/bin/deno' | ||
|
||
deno --version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_DENO_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[] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu | ||
|
||
version=$( jq -r '.devDependencies.prisma' package.json ) | ||
|
||
deno run -A npm:prisma@$version generate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { type PrismaClient } from '../generated/client/index.d.ts' | ||
import { createRequire } from 'node:module' | ||
const require = createRequire(import.meta.url) | ||
const Prisma = require('../generated/client/index.js') | ||
|
||
// const prisma = new PrismaClient(); | ||
export const prisma: PrismaClient = new Prisma.PrismaClient({ log: ['query', 'info', 'warn', 'error'] }) | ||
|
||
export async function getUsers() { | ||
// Do a query and disconnect | ||
// So we also test that connection is re-established in next query below | ||
await prisma.user.findFirst(); | ||
await prisma.$disconnect(); | ||
|
||
// query should re-connect automatically | ||
return await prisma.$transaction([ | ||
prisma.user.findFirst(), | ||
prisma.user.findMany(), | ||
]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { type PrismaClient } from '../generated/client/index.d.ts' | ||
import { createRequire } from 'node:module' | ||
const require = createRequire(import.meta.url) | ||
const Prisma = require('../generated/client/index.js') | ||
|
||
// const prisma = new PrismaClient(); | ||
const prisma: PrismaClient = new Prisma.PrismaClient({ log: ['query', 'info', 'warn', 'error'] }) | ||
|
||
const users = await prisma.user.findFirst(); | ||
console.log(users) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
|
||
set -eu | ||
|
||
deno test -A --no-check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts"; | ||
import { getUsers } from "./src/index.ts"; | ||
|
||
Deno.test( | ||
"can run query", | ||
{ sanitizeOps: false, sanitizeResources: false }, | ||
async () => { | ||
const users = await getUsers(); | ||
assertEquals(users, [ | ||
{ | ||
"email": "[email protected]", | ||
"name": "Autumn", | ||
"user_id": 1, | ||
}, | ||
[ | ||
{ | ||
"email": "[email protected]", | ||
"name": "Autumn", | ||
"user_id": 1, | ||
}, | ||
{ | ||
"email": "[email protected]", | ||
"name": "Marguerite", | ||
"user_id": 2, | ||
}, | ||
{ | ||
"email": "[email protected]", | ||
"name": "Jana", | ||
"user_id": 3, | ||
}, | ||
{ | ||
"email": "[email protected]", | ||
"name": "Pink", | ||
"user_id": 4, | ||
}, | ||
{ | ||
"email": "[email protected]", | ||
"name": "Oren", | ||
"user_id": 5, | ||
}, | ||
{ | ||
"email": "[email protected]", | ||
"name": "Sigmund", | ||
"user_id": 6, | ||
}, | ||
{ | ||
"email": "[email protected]", | ||
"name": "Toy", | ||
"user_id": 7, | ||
}, | ||
{ | ||
"email": "[email protected]", | ||
"name": "Brooklyn", | ||
"user_id": 8, | ||
}, | ||
{ | ||
"email": "[email protected]", | ||
"name": "Cassandre", | ||
"user_id": 9, | ||
}, | ||
{ | ||
"email": "[email protected]", | ||
"name": "Jazmyne", | ||
"user_id": 10, | ||
}, | ||
], | ||
]); | ||
}, | ||
); |