Skip to content

Commit

Permalink
Remove Doppler (#1403)
Browse files Browse the repository at this point in the history
* Fix test failures if database is not clean

* Remove Doppler
  • Loading branch information
stephenwade authored Mar 31, 2024
1 parent f4a4755 commit 102199a
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 40 deletions.
16 changes: 13 additions & 3 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
NODE_ENV=development
DATABASE_URL=mysql://USER:PASSWORD@HOST:PORT/DATABASE
AZURE_STORAGE_ACCOUNT=my-azure-storage-account
AZURE_STORAGE_KEY=my-azure-storage-account-access-key
AZURE_STORAGE_KEY=AzureStorageAccountAccessKey
AZURE_STORAGE_WEBSITE_DOMAIN=my-azure-storage-account.z13.web.core.windows.net
CLERK_PUBLISHABLE_KEY=pk_test_SamplePublishableKey
CLERK_SECRET_KEY=sk_test_SampleSecretKey
DATABASE_URL=mysql://${MYSQL_USER}:${MYSQL_PASSWORD}@localhost:3306/${MYSQL_DATABASE}
FIRST_ADMIN_EMAIL_ADDRESS=[email protected]
PORT=3000

# Set these values to configure MySQL in Docker for local development.
# In production, this can be inlined into the DATABASE_URL.
MYSQL_DATABASE=festival
MYSQL_USER=festival
MYSQL_PASSWORD=changeme
MYSQL_ROOT_PASSWORD=pleasechange
14 changes: 9 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ jobs:
- name: Check out repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- name: Install Doppler
run: wget -t 3 -qO- https://cli.doppler.com/install.sh | sudo sh

- name: Install MySQL
run: |
brew install mysql
Expand All @@ -33,9 +30,16 @@ jobs:
run: npx playwright install --with-deps

- name: Run tests
run: doppler run -- npm run test
run: npm run test
env:
DOPPLER_TOKEN: ${{ secrets.DOPPLER_TOKEN }}
AZURE_STORAGE_ACCOUNT: ${{ secrets.AZURE_STORAGE_ACCOUNT }}
AZURE_STORAGE_KEY: ${{ secrets.AZURE_STORAGE_KEY }}
AZURE_STORAGE_WEBSITE_DOMAIN: ${{ secrets.AZURE_STORAGE_WEBSITE_DOMAIN }}
CLERK_PUBLISHABLE_KEY: ${{ secrets.CLERK_PUBLISHABLE_KEY }}
CLERK_SECRET_KEY: ${{ secrets.CLERK_SECRET_KEY }}
DATABASE_URL: mysql://root:@localhost:3306/festival
FIRST_ADMIN_EMAIL_ADDRESS: [email protected]
PORT: '3000'

- name: Upload test results
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
.DS_Store

node_modules/
npm-debug.log

.cache/
build/
.env*

# runtime
upload

# Playwright
/test-results/
/playwright-report/
/playwright/.cache/
Expand Down
23 changes: 8 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,26 @@ at the same time) without requiring live streaming infrastructure.

## Local Development

- Run `doppler setup` to set up your [Doppler](https://www.doppler.com/) config.
- Copy `.env.sample` to `.env` and fill out the required values.
- Run `docker compose up -d` to start a MySQL database.
- Run `npm install` to install the required packages.
- Run `npm run dev` to serve the application locally.

## MySQL Setup

Run the following command to create a MySQL database for Festival using Docker.

```shell
doppler run --mount .env -- docker compose up -d
```

## Azure Setup

Make sure that your Azure storage account is set to allow
[CORS requests](https://stackoverflow.com/a/41351674).
This is required for the visualizer to work.

## Building
## Testing

- `npm run build` will bundle the application for production.
- `doppler run -- npm start` will serve the bundled application.
- `npm run test` will run the end-to-end tests.
- `npm run test-ct` will run the component tests.

## Testing
## Building

TODO
- `npm run build` will bundle the application for production.
- `npm start` will serve the bundled application.

## Deploying

Expand All @@ -45,6 +39,5 @@ Pushing to main triggers a deploy on Railway.
<!-- - [BetterStack](https://betterstack.com/) for monitoring -->
- [Clerk](https://clerk.com/) for authentication
- [DigitalOcean](https://www.digitalocean.com/) for database hosting, DNS, and proxying to Railway
- [Doppler](https://www.doppler.com/) for secrets management
- [Railway](https://railway.app/) for hosting
- [Sentry](https://sentry.io/) for error reporting
12 changes: 3 additions & 9 deletions app/db/db.server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { PrismaClient } from '@prisma/client';

let db: PrismaClient;

declare global {
// eslint-disable-next-line no-var
var __db: PrismaClient | undefined;
Expand All @@ -10,13 +8,9 @@ declare global {
// this is needed because in development we don't want to restart
// the server with every change, but we want to make sure we don't
// create a new connection to the DB with every change either.
if (process.env.NODE_ENV === 'production') {
db = new PrismaClient();
} else {
if (!global.__db) {
global.__db = new PrismaClient();
}
db = global.__db;
if (!global.__db) {
global.__db = new PrismaClient();
}
const db = global.__db;

export { db };
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ services:
db:
image: mysql@sha256:4552fcc5d3cdb8cdee76ee25cce28bf60b0eb3ce93d25ba3bfff7a66bfdcdee8
env_file: .env
environment:
MYSQL_USER: festival
volumes:
- db-data:/var/lib/mysql
- ./db-init:/docker-entrypoint-initdb.d
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"prepare": "husky; prisma generate",
"build": "remix build",
"dev": "doppler run -- remix dev",
"dev": "remix dev",
"start": "remix-serve ./build/index.js",
"lint:eslint": "eslint . --ignore-path .gitignore --max-warnings 0",
"lint:stylelint": "stylelint \"**/*.css\" --ignore-path .gitignore --max-warnings 0",
Expand Down
9 changes: 8 additions & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { defineConfig, devices } from '@playwright/test';
import { authFile } from 'playwright/tests/shared-data';
import dotenv from 'dotenv';

import { authFile } from './playwright/tests/shared-data';

dotenv.config();

const baseURL = `http://127.0.0.1:${process.env.PORT}`;

Expand All @@ -23,6 +27,9 @@ export default defineConfig({
command: ['npx prisma migrate dev', 'npx remix dev'].join(' && '),
url: `${baseURL}/admin`,
reuseExistingServer: !process.env.CI,
env: {
FIRST_ADMIN_EMAIL_ADDRESS: '[email protected]',
},
},

projects: [
Expand Down
4 changes: 4 additions & 0 deletions playwright/helpers/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ export function randomShowId() {
return `test-show-${crypto.randomUUID().slice(-12)}`;
}

export async function deleteTestShows() {
await prisma.show.deleteMany({ where: { id: { startsWith: 'test-show-' } } });
}

export async function seedShow(startDate: Date) {
const [showLogoFile, backgroundImageFile] = await Promise.all([
prisma.file.create({
Expand Down
4 changes: 3 additions & 1 deletion playwright/tests/global.setup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test as setup } from '@playwright/test';
import { addSeconds } from 'date-fns';

import { seedShow } from '../helpers/show';
import { deleteTestShows, seedShow } from '../helpers/show';
import { authFile } from './shared-data';

/**
Expand All @@ -13,6 +13,8 @@ import { authFile } from './shared-data';
*/

setup('seed show', async () => {
await deleteTestShows();

const show = await seedShow(addSeconds(new Date(), 10));

process.env.SHOW_ID = show.id;
Expand Down

0 comments on commit 102199a

Please sign in to comment.