Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

LunarLogic/smog_alert

Folders and files

NameName
Last commit message
Last commit date
Feb 18, 2020
Dec 4, 2019
Mar 16, 2020
Nov 14, 2019
Mar 16, 2020
Mar 16, 2020
Feb 24, 2020
Nov 14, 2019
Nov 14, 2019
Feb 25, 2020
Nov 14, 2019
Dec 30, 2019
Nov 14, 2019
Nov 14, 2019
Nov 15, 2019
Nov 14, 2019
Jan 22, 2020
Nov 15, 2019
Nov 25, 2019
Nov 26, 2019
Dec 13, 2019
Nov 5, 2019
Dec 17, 2019
Feb 25, 2020
Feb 25, 2020
Feb 26, 2020
Dec 16, 2019
Nov 14, 2019
Nov 14, 2019
Jan 2, 2020
Feb 12, 2020
Nov 15, 2019
Feb 12, 2020

Repository files navigation

Smog alert

CircleCI

Requirements

  • Ruby 2.6.5
  • Node.js

Ensure you use NVM (Node Version Manager) and only then install yarn via brew.

brew install yarn
  • Install and run PostgreSQL
brew update
brew install postgresql
brew services start postgresql
  • Install and run Redis
brew update
brew install redis
brew services start redis
  • Install ImageMagic
brew install imagemagick

Development setup

bundle install
yarn install

# setup database
rake db:setup

bundle exec rails s

# In separate terminal window run:
bin/webpack-dev-server

# In separate terminal window run:
bundle exec sidekiq

# To run migrations in database:
rails db:migrate
RAILS_ENV=test rails db:migrate
  • Run seeds to setup sample records in database (email: [email protected], password: 123456)
rails db:seed
  • You can see background jobs in Sidekiq web view by visiting http://localhost:3000/sidekiq You must be signed in as admin user.

  • To check Rails routes

rails routes

Editor config

  • Visual Studio Code
  • Install Prettier - Code formatter
  • Go to Code > Peferences > Settings > Text Editor > Formatting Turn on Format On Save checkbox From now on every change in code base will be automatically formatted by Prettier.

Deployment

  • To deploy from master branch use:

cap staging deploy

  • To specify a branch for deployment use:

BRANCH=example_branch cap staging deploy

  • Run DB seeds on container:

cap staging deploy:seed

Tips

  • Edit credentials in VIM by running:

EDITOR=vim rails credentials:edit

  • Edit credentials in VSCode by running:

EDITOR='code --wait' rails credentials:edit

or

EDITOR='code --wait' rails credentials:edit -e staging

  • To use RuboCop Linter run:

bundle exec rubocop

  • How to run rails console inside of staging container:
ssh [email protected]

# go to rails project directory
smogalert@staging:~$ cd application/current

# open rails console
RAILS_ENV=staging /usr/local/rbenv/bin/rbenv exec bundle exec rails console

Tests

  • Run the test suite: bundle exec rspec

  • Run tests in Chrome browser in development: CHROME=true rspec spec/features/homepage_spec.rb

API docs

React application uses API exposed by Rails.

We use Swagger Blocks to manage API docs.

How to preview documentation via staging

http://petstore.swagger.io/?url=https://staging.smogalert.lunarlogic.io/apidocs

How to preview documentation in development

http://petstore.swagger.io/?url=http://localhost:3000/apidocs