Skip to content
freerangePublic

About

A platform co-operative for musicians and fans

Resources

Code of conduct

Contributing

Stars

67 stars

Watchers

3 watching

Forks

Repository files navigation

README CI

Development

This is a Rails app running on the version of Ruby specified in .ruby-version and the version of Node specified in .node-version. If you're using asdf you can install the correct versions of Ruby and Node locally with asdf install. If you're using mise you can install the correct versions of Ruby and Node locally with mise install.

We're using PostgreSQL 15 in production, so it's recommended you run that in development too. You can use mise for this too. Once mise has installed postgres, start it with

postgres -D $PGDATA

You'll need to create a database user

psql -U postgres
# CREATE USER <username>;
# ALTER USER <username> WITH SUPERUSER;

We're using Rails' default image processor library vips, which you need to install

brew install libvips

We're using FFmpeg to transcode original audio into formats suitable for download. You need to install it:

brew install ffmpeg

Copy the example .env file

cp `.env.example .env`

Then

bin/setup

The app should be running on http://localhost:3000/

Testing

Linters and test can be run using the default rake task.

To run the system tests in a visible/headed browser set the HEADLESS environment variable to false. For example: to run all system tests in a visible browser, execute HEADLESS=false rails test test/system.

If a system test fails, screenshots and Playwright traces will be saved for each session in tmp/screenshots and tmp/playwright-traces respectively. These are also made available as downloadable artifacts in the CI build. You can view a Playwright trace by running npx playwright show-trace tmp/playwright-traces/<test-name>-<session-name>.zip or by dropping the zip file into the online viewer.

Credentials

Environment specific API keys etc. are stored in environment variables. The file .env.example should be copied to .env so that Dotenv can find these in development. You may only need to set these to real values if you need a particular third party service for the code you're working on. For example, Rollbar credentials are only needed if for some reason you need to use rollbar in development.

Sending email in development

If you need to send email via Postmark in development you can set the USE_POSTMARK_IN_DEVELOPMENT variable to true in .env.

Using Stripe in development

Get the API Secret key from the Test sandbox in Stripe and set STRIPE_SECRET_KEY to this value in your local .env file.

To receive events from Stripe webhooks in your local environment you need to run the Stripe CLI with:

stripe listen --forward-to localhost:3000/stripe_webhook_events

When you first run this command it will show a value for the "webhook signing secret". Copy this value and set STRIPE_ENDPOINT_SECRET to this value in your local .env file.

Deployment

When a CI build on the main branch succeeds the commits are promoted to the production branch. Render is configured to automatically deploy the latest changes from the production branch. The login credentials for Render are available in the shared 1Password vault.

Downloading production data

This requires you to store the Render external database URL in an environment variable (e.g. in .envrc if using direnv). Get this from the jam-db dashboard on render.com (under the "connect" dropdown).

# Create a backup of the production database
pg_dump --dbname=${RENDER_EXTERNAL_DB_URL} -n public --no-owner > tmp/jam-production-db.sql

# Drop and create the local database
rails db:drop
rails db:create

# Restore the production database locally
rails db -p < tmp/jam-production-db.sql

# Set the environment to development so that we don't see scary warnings about modifying the production database when we attempt to drop it
echo "update ar_internal_metadata set value = 'development' where key = 'environment' and value = 'production'" | rails db -p

Troubleshooting

Generating image varients fails locally

I saw this error locally on my M2 Macbook Air

[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called

The solution was to add the following to my .zshrc

export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES

About

A platform co-operative for musicians and fans

Resources

Code of conduct

Contributing

Stars

67 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages