Skip to content

Commit

Permalink
add buildkite settings
Browse files Browse the repository at this point in the history
  • Loading branch information
timsuchanek committed Jun 27, 2019
1 parent ad435ce commit 96e0c0c
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 81 deletions.
44 changes: 44 additions & 0 deletions .buildkite/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
version: '3.7'
services:
app:
image: node:10
volumes:
- ../:/app
working_dir: /app
command: /app/prisma2/scripts/test.sh
environment:
- TEST_POSTGRES_URI="postgres://prisma:prisma@postgres:5432/prisma-dev"
postgres:
image: postgres:10.3
restart: always
ports:
- '5432:5432'
environment:
POSTGRES_USER: prisma
POSTGRES_PASSWORD: prisma
volumes:
- postgres:/var/lib/postgresql/data
# mongo:
# image: mongo:3.6
# restart: always
# environment:
# MONGO_INITDB_ROOT_USERNAME: prisma
# MONGO_INITDB_ROOT_PASSWORD: prisma
# ports:
# - '27018:27017'
# volumes:
# - mongo:/var/lib/mongo
# mysql:
# image: mysql:5.7
# restart: always
# ports:
# - '3307:3306'
# environment:
# MYSQL_ROOT_PASSWORD: prisma
# volumes:
# - mysql:/var/lib/mysql

volumes:
postgres:
# ? mysql
# ? mongo
13 changes: 13 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
steps:
- label: ':coverage: Test'
plugins:
- docker-compose:
config: .buildkite/docker-compose.yml
run: app
- wait
- label: ':gun: Trigger publish'
trigger: 'lift-publish'
async: true
build:
env:
PUBLISH_PRISMA2: 'false'
93 changes: 12 additions & 81 deletions prisma2/src/__tests__/integrate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ import { generateClient } from '@prisma/photon'
import { isdlToDatamodel2 } from '@prisma/lift'
import { ISDL } from 'prisma-datamodel'
import { join, dirname } from 'path'
import { writeFile } from 'mz/fs'
import mkdir from 'make-dir'
import { Client } from 'pg'
import assert from 'assert'
import pkgup from 'pkg-up'
import exec from 'execa'
import del from 'del'

const host = process.env.TEST_POSTGRES_URI || 'postgres://localhost:5432/prisma-dev'

const db = new Client({
connectionString: 'postgres://localhost:5432/prisma-dev',
connectionString: host,
})

const pkg = pkgup.sync() || __dirname
Expand All @@ -39,90 +39,21 @@ tests().map(t => {
return
}

it(
name,
// async () => {
// await db.query(t.after)
// await db.query(t.before)
// const bin = join(process.cwd(), 'build', 'index.js')

// // $ prisma introspect
// const { stdout } = await exec(
// bin,
// [
// 'introspect',
// '--pg-host',
// 'localhost',
// '--pg-db',
// 'prisma-dev',
// '--pg-user',
// 'm',
// '--pg-schema',
// 'public',
// '--pg-password',
// '',
// '--sdl',
// ],
// { cwd: tmp },
// )

// // write a prisma file
// await writeFile(join(tmp, 'datamodel.prisma'), stdout)

// // $ prisma generate
// await exec(bin, ['generate'], { cwd: tmp })

// const { Photon } = await import(join(tmp, 'node_modules', '@generated', 'photon', 'index.js'))
// const client = new Photon()
// try {
// const result = await t.do(client)
// await db.query(t.after)
// assert.deepEqual(result, t.expect)
// } catch (err) {
// throw err
// } finally {
// await client.disconnect()
// }
// },
async () => {
try {
await runTest(t)
} catch (err) {
throw err
} finally {
await db.query(t.after)
}
},
)
it(name, async () => {
try {
await runTest(t)
} catch (err) {
throw err
} finally {
await db.query(t.after)
}
})
})

async function runTest(t) {
await db.query(t.after)
await db.query(t.before)
const isdl = await inspect(db, 'public')
// console.log(isdl)

// $ prisma introspect
// const bin = join(process.cwd(), 'build', 'index.js')
// const { stdout: datamodel } = await exec(
// bin,
// [
// 'introspect',
// '--pg-host',
// 'localhost',
// '--pg-db',
// 'prisma-dev',
// '--pg-user',
// 'm',
// '--pg-schema',
// 'public',
// '--pg-password',
// '',
// '--sdl',
// ],
// { cwd: tmp },
// )
// console.log(datamodel)

await generate(isdl)
const photonPath = join(tmp, 'index.js')
Expand Down
12 changes: 12 additions & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -ex

cd prisma2
yarn
yarn build
yarn test
cd ../introspection
yarn
yarn build
yarn test

0 comments on commit 96e0c0c

Please sign in to comment.