Skip to content
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
15 changes: 0 additions & 15 deletions .buildkite/pipeline.yml

This file was deleted.

1 change: 0 additions & 1 deletion .dockerignore

This file was deleted.

29 changes: 15 additions & 14 deletions .env.test
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
NEXT_PUBLIC_BASE_URL=http://localhost:3000
PGHOST=
PGPORT=5432
PGUSER=
PGHOST=127.0.0.1
PGPORT=54322
PGUSER=postgres
PGDATABASE=postgres
PGPASSWORD=
PGPASSWORD=postgres
SENTRY_DSN=sentryDsn
SENTRY_ENV=sentryEnv
PUBLIC_S3_BASE_URL=https://test.example.com
S3_ENDPOINT=
S3_ENDPOINT=http://127.0.0.1:54321/storage/v1/s3
S3_REGION=local
S3_ACCESS_KEY_ID=accesskeyneedstobeexactly32chars
S3_ACCESS_KEY_SECRET=12345678
S3_MAPS_BUCKET=paradb-maps-test
MEILISEARCH_HOST=https://
MEILISEARCH_KEY=123
SEARCH_IMPLEMENTATION=postgres
MEILISEARCH_HOST=unused
MEILISEARCH_KEY=unused
FLAGS_IMPLEMENTATION=local
FLAGS_EDGE_CONFIG=
FLAGS_EDGE_CONFIG_KEY=
NEXT_PUBLIC_SUPABASE_URL=
FLAGS_EDGE_CONFIG=unused
FLAGS_EDGE_CONFIG_KEY=unused
NEXT_PUBLIC_SUPABASE_URL=http://127.0.0.1:54321
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=
SUPABASE_SECRET_KEY=
AXIOM_API_TOKEN=
AXIOM_DATASET=
NEXT_PUBLIC_AXIOM_API_TOKEN=
NEXT_PUBLIC_AXIOM_DATASET=
AXIOM_API_TOKEN=unused
AXIOM_DATASET=unused
NEXT_PUBLIC_AXIOM_API_TOKEN=unused
NEXT_PUBLIC_AXIOM_DATASET=unused
75 changes: 75 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Tests

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Bun
uses: oven-sh/setup-bun@v2

- name: Install dependencies
run: bun install

- name: Setup Supabase CLI
uses: supabase/setup-cli@v1
with:
version: latest

- name: Start Supabase
run: supabase start

- name: Set Supabase env vars
run: |
supabase status -o env > /tmp/supabase_env
source /tmp/supabase_env
echo "NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=$ANON_KEY" >> $GITHUB_ENV
echo "SUPABASE_SECRET_KEY=$SERVICE_ROLE_KEY" >> $GITHUB_ENV

- name: Load test env vars
run: |
# Load .env.test into GITHUB_ENV, skipping comments and blank lines
while IFS= read -r line; do
# Skip comments and empty lines
[[ -z "$line" || "$line" =~ ^# ]] && continue
key="${line%%=*}"
value="${line#*=}"
# Only set if not already defined (Supabase keys from previous step take precedence)
if [[ -z "${!key}" ]]; then
echo "$key=$value" >> $GITHUB_ENV
fi
done < .env.test

- name: Typecheck and lint
run: bun check

- name: Start dev server
run: |
bun next dev &
# Wait for the server to be ready
for i in $(seq 1 30); do
if curl -s http://localhost:3000 > /dev/null 2>&1; then
echo "Server is ready"
break
fi
echo "Waiting for server to start... ($i/30)"
sleep 2
done

- name: Run tests
run: bun test

- name: Stop Supabase
if: always()
run: supabase stop
6 changes: 3 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Although you are taking on the persona of an intern developer, your skills are t

This is a website that allows users to host custom maps and songs for a rhythm drumming game called "Paradiddle".
Custom maps consist of a zip file, which contains a .rlrr metadata file along with the audio tracks for the song. The audio tracks can either be the song itself, or the audio stems of the song that can allow the game to play the song without any drum track (as the player will be drumming along themselves).
The codebase uses Docker to run third-party services locally (Meilisearch for search, Minio for a local S3 instance), the local Supabase CLI for running the Supabase database locally, and the standad Next.js dev mode to run the backend and frontend locally.
The codebase uses the local Supabase CLI for running the Supabase database locally (which includes Postgres and Auth), and the standard Next.js dev mode to run the backend and frontend locally. S3 is used for blob storage (locally provided by Supabase Storage's S3-compatible API).

# Tech stack

Expand Down Expand Up @@ -36,9 +36,9 @@ The codebase uses Docker to run third-party services locally (Meilisearch for se

# Commands

- `bun dev` will start local services on Docker
- `bun dev:local` will start Next.js in dev mode with local env
- `bun supabase start` will start Supabase locally
- `bun next dev` will run Next.js in dev mode
- `bun test` will run the test suite
- `bun format` will format the codebase with Prettier
- `bun check` will typecheck and lint

Expand Down
14 changes: 0 additions & 14 deletions Dockerfile

This file was deleted.

20 changes: 0 additions & 20 deletions Dockerfile.dev

This file was deleted.

25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@ git clone https://github.com/bitnimble/paradb.git
cd paradb
bun install

# Install and start postgres
sudo apt install postgresql
sudo service postgresql start
# Start local Supabase (requires Supabase CLI)
bun supabase start

# Create postgres user for yourself
sudo -u postgres createuser --interactive --pwprompt
# Copy the example env file and fill in any missing values
cp .env.test .env.localdev

# Edit .env to fill out your username and password!
# Start the dev server
bun dev:local
```

## Running tests

# Create db and instantiate schema
createdb paradb
db/init.sh
```
# Ensure local Supabase is running
bun supabase start

# Start server
bun dev
# Run tests
bun test
```
47 changes: 0 additions & 47 deletions docker/docker-compose.dev.yml

This file was deleted.

17 changes: 0 additions & 17 deletions docker/docker-compose.test.yml

This file was deleted.

35 changes: 0 additions & 35 deletions docker/docker-compose.yml

This file was deleted.

1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const createJestConfig = nextJest({ dir: './' });

const config = {
testMatch: ['**/tests/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
globalSetup: '<rootDir>/src/services/jest_global_setup.ts',
setupFilesAfterEnv: ['<rootDir>/src/services/jest_setup.ts'],
modulePaths: ['<rootDir>/src'],
};
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
"dev:local": "dotenv -e .env.localdev -- bun next dev",
"dev:dev": "dotenv -e .env.dev -- bun next dev",
"dev:prod": "dotenv -e .env.prod -- bun next dev",
"build": "sudo docker compose -f docker/docker-compose.yml --env-file .env build",
"start": "sudo docker compose -f docker/docker-compose.yml --env-file .env up --build",
"check": "bun tsc && bun eslint .",
"lint": "eslint .",
"format": "prettier . --write",
"schema": "tools/update_schema.sh",
"test": "sudo docker compose -f docker/docker-compose.test.yml --env-file .env.test up --build --abort-on-container-exit"
"test": "dotenv -e .env.test -- bun jest --runInBand"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.958.0",
Expand Down
17 changes: 17 additions & 0 deletions src/services/jest_global_setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { execSync } from 'child_process';
import { loadEnvConfig } from '@next/env';

const projectDir = process.cwd();
loadEnvConfig(projectDir);

/**
* Resets the local Supabase database before the test suite runs.
* Uses `supabase db reset` which applies migrations, schemas, and seeds.
*/
export default async function globalSetup() {
console.log('Resetting Supabase database for tests...');
execSync('bun supabase db reset --yes', {
cwd: projectDir,
stdio: 'inherit',
});
}
Loading