Sign inSign up

halalbooking/primary

By halalbooking

Updated 7 months ago

Image
0

500K+

halalbooking/primary repository overview

Required libs and tools
  • PostgreSQL 13.x (If psql can't connect to the server)
  • Ruby. Better to install via rbenv or rvm. See .ruby-version file. Exact version is not present in the .ruby-version file. For example regardless of your local version 3.1.2 or 3.1.1 in .ruby-version it will be 3.1. To create an alias:
    • rbenv ln -s ~/.rbenv/versions/3.1.2 ~/.rbenv/versions/3.1
    • rvm rvm alias create ruby-3.1.0 3.1.2
  • node 14.x
  • Yarn
  • For images: imagemagick
Only macOS (10.13 or later)

If you are running Puma server in clustered mode, web workers will crash due to an issue with "Ethon" library. To work around the issue, disable fork safety:

export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES

This variable must be exported before starting Puma server. A good place for that would be .pumaenv (Puma-dev), ~/.profile or equivalent.

Project setup
make setup

Also, you will need a "development" version of the production DB. For that just run

make fetchdb

It will fetch the dump and restore it automatically as halalbooking DB.

Notes on database dump creation

We have multiple make commands that help prefill the local database with sample data retrieved from the production database. Running these commands requires access to our servers through ssh. Currently we execute these commands on the oscar server.

  • make refreshdb - Creates a new dump file on the server running this script. It is saved as last.dump which is later fetched and used on the local machine as hb.dump.

  • make fetchdb - Executes fetch-dump and then restore-dump commands, see details below

  • make fetch-dump - Downloads last.dump from the server to a local machine and saves it as hb.dump (in repository's root folder)

  • make restore-dump - Restores data from local hb.dump (stored in the root folder of this repository) to the local database, applies local changes and deletes hb.dump

  • make refresh-and-fetchdb - Runs refreshdb and then fetchdb commands

ClojureScript
Dev setup
  1. Install leiningen.
  2. Run lein fig to start building and hot reloading CLJS code.
  3. Open any cljs-powered page in a browser.

If you prefer to work with concatenated file (because of performance reasons), you can run

lein cljsbuild auto front-whitespace (or "extranet-whitespace", or both)

It will still watch for changes. If you just want to build file once, use:

lein cljsbuild once front-whitespace (or "extranet-whitespace", or both)

To clean the output directory run lein clean.

Devcards setup
  1. Install leiningen.
  2. Run lein fig.
  3. Open /dev/cards in a browser.
Clojure

Dev setup:

  1. Install Clojure CLI.
  2. Run clj -M:dev.
  3. Type (start) in REPL.
  4. Open http://localhost:8090.
Database connection setup

By default PGUSER and PGDATABASE is used to define the connection. Otherwise current shell user will be used as a DB user (same behavior as with psql) and "halalbooking" as a DB name.

If you want to override database name default, you can either specify PGDATABASE globally via export in your .bash_profile or provide it directly in shell PGDATABASE=hb clj -M:dev.

Rails setup

By default Rails stubs all Clojure-backed requests in development. Make sure you have HANDLE_CLOJURE_REQUESTS=proxy set up in your env.

Linting

See https://github.com/borkdude/clj-kondo/blob/master/doc/editor-integration.md for live linting setup.

Tests
Rspec

Run all tests: bin/rake spec:all

Front tests only: bin/rspec front/spec

Clojurescript tests

CLJS based:

  1. Run yarn (first time only).
  2. Run make cljs-test-auto (if you want to run tests once, use make cljs-test-once).

Capybara based:

  1. Install brew install chromedriver (first time only). (or upgrade it: brew upgrade chromedriver)
  2. Run lein fig.
  3. Run a Capybara feature test as usual.
Clojure backend

You will need to manually start Clojure backend for some tests. Note different environment (test) and database (halalbooking_test). A custom server port is used (8091) so that you can run it alongside a development server on the default port (8090).

env HTTP_KIT__PORT=8091 PGDATABASE=halalbooking_test clojure -M:test -m hb.core

Run tests:

env HTTP_KIT__PORT=8091 HANDLE_CLOJURE_REQUESTS=proxy rspec front/spec/features/search_filters_spec.rb
Clojure tests
  1. Install Clojure CLI.
  2. Make sure your test DB is prepared: bin/rake db:test:prepare.
  3. Run make clj-test-once (or make clj-test-auto if you want tests being re-run once you save a file).
Screenshot tests

Prepare Install Selenium - npm install -g selenium-standalone selenium-standalone install

Run

To run tests against staging edit .hermione.conf.js file.

  1. Start rails server & lein
  2. Start Selenium - selenium-standalone start
  3. Run tests - yarn run screenshots
Profiling & local benchmarks

Run RAILS_ENV=profiling bin/rails s. Note, this is effectively a production environment, so you have to restart application after each code change.

CircleCI

See .circleci/README.

SVG sprite
  1. To update run yarn run svg-sprite
  2. To prevent image from adding to sprite add _ right before .svg (e. g. circle_.svg)
Enable CSS live reload
  1. Set ENV variable CSS_LIVE_RELOAD=true or run server with it CSS_LIVE_RELOAD=true rails s
  2. Run yarn run watch-css
Watch & rebuild CSS docs
  1. Run yarn run watch-css
Supported browsers

See .browserlistrc file.

Usage

Server:

  • rails s

The rails server command launches a web server named Puma which comes bundled with Rails.

  • puma-dev

Alternative to rails s.

Puma-dev: A fast, zero-config development server for OS X and Linux.

Use the following syntax to create a symbolic link in ~/.puma-dev directory :

$ cd ~/.puma-dev && ln -s /path/to/halalbooking hb

Set "hb.test" as APP_HOST in your "~/.bash_profile":

export APP_HOST=hb.test

Console:

  • rails c

The console command lets you interact with your Rails application from the command line. You must always restart the console after code changes.

Background jobs
Development

By default all jobs are stored into "queue_classic_jobs" table (QC adapter), but not executed. You have to start a QC worker in parallel if you want background jobs, such as sending emails, to be executed:

make jobs

If you don't want the worker to process all previously queued jobs, clear all of them with

bin/rake qc:truncate
Testing

Enqueueing jobs is stubbed and thus it can be asserted.

Staging

We don't run recurring jobs on staging.

Production

All jobs are stored into "queue_classic_jobs" table and picked up by multiple QC workers (see example).

We run recurring jobs via cron.

Tag summary

Content type

Image

Digest

sha256:ba6400712

Size

1.3 GB

Last updated

over 3 years ago

docker pull halalbooking/primary