diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 566898c..20a9367 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -6,25 +6,17 @@ on: branches: [main, master] jobs: all: - timeout-minutes: 60 + timeout-minutes: 15 runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: lts/* - - name: Install dependencies - run: npm i - - name: Lint - run: npm run lint - - name: Typecheck - run: npm run typecheck - - name: Unit Test - run: npm run test:unit - - name: Install Playwright Browsers - run: npx playwright install --with-deps - - name: Run Playwright tests - run: npm run test:e2e + - name: Run docker compose + run: docker compose up postgres mgmnt-app --wait --detach --wait-timeout 60 + - name: Run Specs + run: docker compose exec mgmnt-app npm run ci env: NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: ${{ vars.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY }} CLERK_SECRET_KEY: ${{ secrets.CLERK_SECRET_KEY }} diff --git a/.gitignore b/.gitignore index eedf4ad..482314a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ .idea *.log tmp/ - .next/ test-results/ *.tern-port @@ -15,14 +14,5 @@ yarn-error.log* .eslintcache coverage/ playwright-report/ -.open-next/ -<<<<<<< ours -<<<<<<< Updated upstream -======= .env .parcel-cache ->>>>>>> Stashed changes -======= -.env -.parcel-cache ->>>>>>> theirs diff --git a/Dockerfile.dev b/Dockerfile.dev index 435a3f3..a8d5d33 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -7,7 +7,7 @@ COPY package.json package-lock.json ./ RUN npm install -COPY .editorconfig next.config.mjs tsconfig.json kysely.config.ts .eslintrc.json .prettierrc.json . +COPY .gitignore .editorconfig next.config.mjs tsconfig.json kysely.config.ts .eslintrc.json .prettierrc.json . # Next.js collects completely anonymous telemetry data about general usage. Learn more here: https://nextjs.org/telemetry # Uncomment the following line to disable telemetry at run time diff --git a/bin/docker-dev-init b/bin/docker-dev-init new file mode 100755 index 0000000..40af1f0 --- /dev/null +++ b/bin/docker-dev-init @@ -0,0 +1,14 @@ +#!/bin/bash + +# this file is the entrypoint for the Dockerfile.dev +# and is used for local development + +set -e + +npm install + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + +$SCRIPT_DIR/migrate-dev-db + +npm run dev diff --git a/bin/migrate-dev-db b/bin/migrate-dev-db new file mode 100755 index 0000000..05c86d4 --- /dev/null +++ b/bin/migrate-dev-db @@ -0,0 +1,11 @@ +#!/bin/bash + +set -e + +TYPES=src/database/types.ts + +npx kysely migrate:up + +npx kysely-codegen --camel-case --dialect postgres --out-file $TYPES +npx prettier --write $TYPES +npx eslint --fix $TYPES diff --git a/docker-compose.yml b/docker-compose.yml index 91fe0b2..4170e07 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,13 +9,27 @@ services: - POSTGRES_USER=mgmnt - POSTGRES_PASSWORD=mgmntpass - POSTGRES_DB=mgmnt_dev + healthcheck: + test: ['CMD-SHELL', 'pg_isready -U mgmnt -d mgmnt_dev'] + interval: 10s + retries: 5 + start_period: 30s + timeout: 10s mgmnt-app: container_name: mgmnt-app + depends_on: + postgres: + condition: service_healthy + restart: true + environment: + NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: $NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY + CLERK_SECRET_KEY: $CLERK_SECRET_KEY + E2E_CLERK_USER_USERNAME: $E2E_CLERK_USER_USERNAME + E2E_CLERK_USER_PASSWORD: $E2E_CLERK_USER_PASSWORD + DATABASE_URL: postgres://mgmnt:mgmntpass@postgres:5432/mgmnt_dev build: context: . dockerfile: ./Dockerfile.dev - environment: - DATABASE_URL: postgres://mgmnt:mgmntpass@postgres:5432/mgmnt_dev volumes: - node_modules:/app/node_modules - ./src:/app/src @@ -26,6 +40,12 @@ services: - mgmnt-app ports: - 3000:3000 + healthcheck: + test: ['CMD-SHELL', 'curl -s http://localhost:3000/'] + interval: 10s + retries: 5 + start_period: 30s + timeout: 10s networks: mgmnt-app: volumes: diff --git a/package.json b/package.json index 53af516..7b890c1 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "build": "next build", "start": "next start", "deploy": "tsx bin/deploy.ts", + "ci": "run-p checks test:e2e test:unit", "lint": "next lint && prettier --check .", "lint:fix": "next lint --fix && prettier --write .", "typecheck": "tsc --noEmit", diff --git a/src/database/migrations/1727379622502_study.ts b/src/database/migrations/1727379622502_study.ts new file mode 100644 index 0000000..28bf358 --- /dev/null +++ b/src/database/migrations/1727379622502_study.ts @@ -0,0 +1,28 @@ +import { type Kysely, sql } from 'kysely' + +export async function up(db: Kysely): Promise { + // await db.schema + // .createType('study_status') + // .asEnum(['']) + + await db.schema + .createTable('study') + .addColumn('id', 'uuid', (col) => col.primaryKey()) + .addColumn('researcher_id', 'uuid', (col) => col.notNull()) + .addColumn('member_id', 'uuid', (col) => col.notNull()) + .addColumn('name', 'text', (col) => col.notNull()) + .addColumn('data_sources', 'text', (col) => col.notNull()) + .addColumn('output_formats', 'text', (col) => col.notNull()) + .addColumn('container_location', 'text', (col) => col.notNull()) + .addColumn('irb_protocols', 'text') + + .addColumn('approved_at', 'timestamp') + .addColumn('approved_by_member_id', 'uuid') + .addColumn('created_at', 'timestamp', (col) => col.defaultTo(sql`now()`).notNull()) + .addColumn('updated_at', 'timestamp', (col) => col.defaultTo(sql`now()`).notNull()) + .execute() +} + +export async function down(db: Kysely): Promise { + await db.schema.dropTable('study').execute() +}