Add testing ci pipeline (#1)
All checks were successful
Build and Push Docker Image / tests (push) Successful in 35s
Build and Push Docker Image / build (push) Successful in 2m35s

Reviewed-on: #1
Co-authored-by: Lars Hampe <hello@hashdot.co>
Co-committed-by: Lars Hampe <hello@hashdot.co>
This commit is contained in:
Lars Hampe 2024-10-01 17:04:13 +00:00 committed by HashDot
parent 025900ccc6
commit d2ee997ac7
7 changed files with 39 additions and 6 deletions

View File

@ -0,0 +1,11 @@
name: Build and Push Docker Image
run-name: ${{ gitea.actor }}
on:
push:
branches:
- "!main"
- "**/*"
jobs:
tests:
uses: ./.gitea/workflows/test.yaml

View File

@ -6,7 +6,10 @@ on:
- main
jobs:
tests:
uses: ./.gitea/workflows/test.yaml
build:
needs: [tests]
runs-on: ubuntu-latest
steps:
- name: Checkout

View File

@ -1,8 +1,6 @@
name: Test
run-name: ${{ gitea.actor }}
on:
push:
branches:
on: [workflow_call]
jobs:
build:
@ -38,11 +36,12 @@ jobs:
run: bun install
- name: Push Database - Test
run: bun run db:push
run: bun db:push:force
env:
POSTGRES_URL: postgres://postgres:postgres@10.0.0.145:5432/postgres
POSTGRES_URL: postgres://postgres:postgres@postgres:5432/postgres
- name: Test API
run: bun test:api
env:
POSTGRES_URL: postgres://postgres:postgres@10.0.0.145:5432/postgres
NODE_ENV: test
POSTGRES_URL: postgres://postgres:postgres@postgres:5432/postgres

View File

@ -8,6 +8,13 @@ declare module 'bun' {
}
export const startup = () => {
if (import.meta.env.NODE_ENV === 'test') {
if (!import.meta.env.POSTGRES_URL) {
console.error('Env Var POSTGRES_URL is missing!')
process.exit(0)
}
return
}
const keys = [
'POSTGRES_URL',
'CLERK_WEBHOOK_SECRET',

View File

@ -10,6 +10,7 @@
"db:generate": "bun --filter '@boring.tools/database' db:generate",
"db:migrate": "bun --filter '@boring.tools/database' db:migrate",
"db:push": "bun --filter '@boring.tools/database' db:push",
"db:push:force": "bun --filter '@boring.tools/database' db:push:force",
"test:api": "bun --filter '@boring.tools/api' test",
"docker:website:build": "docker build -t git.hashdot.co/boring.tools/boring.tools/website -f ci/docker/website/Dockerfile .",
"docker:website:push": "docker push git.hashdot.co/boring.tools/boring.tools/website",

View File

@ -0,0 +1,11 @@
import { defineConfig } from 'drizzle-kit'
export default defineConfig({
schema: './src/schema/index.ts',
out: './src/migrations',
dialect: 'postgresql',
dbCredentials: {
url: process.env.POSTGRES_URL as string,
},
verbose: false,
strict: false,
})

View File

@ -4,6 +4,7 @@
"type": "module",
"scripts": {
"db:push": "drizzle-kit push",
"db:push:force": "drizzle-kit push --config=drizzle.ci.config.ts",
"db:studio": "drizzle-kit studio",
"db:generate": "drizzle-kit generate",
"db:migrate": "drizzle-kit migrate"