- Ruby - Use rbenv to install version specified in
.ruby-version
. - imagemagick -
brew install imagemagick
- postgresql - Install Postgres.app and follow instructions.
- puma-dev -
brew install puma/puma/puma-dev
- redis -
brew install redis
- Install Ruby with rbenv, as above.
- Install dependencies:
sudo apt-get install imagemagick redis-server postgresql postgresql-contrib autoconf libtool
You need to install bundler
before you install the required gems.
$ gem install bundler
Install all Gems using bundler
$ bundle install
If installation of of pg
gem crashes, asking for libpq-fe.h
, install the gem with:
On OSX:
find /Applications -name pg_config
gem install pg -- --with-pg-config=/path/to/pg_config
On Ubuntu:
sudo apt-get install libpq-dev
# Run psql command as postgres user.
sudo -u postgres psql postgres
# Set the password for this user.
\password postgres
# Quit.
\q
Copy example.env
to .env
.
$ cp example.env .env
Now, edit .env
and set values for Database username and password that you used in the previous step.
$ overcommit --install
$ overcommit --sign
- intsall NVM following instructions on the offical repository.
- Install Yarn following offical instructions.
- Intsall all node modules with
yarn
command.
$ rails db:setup
This will also seed data useful for development. To view the admin interface, (once you've started the server), visit
the sign in page, and use the development option to sign in as [email protected]
.
Use puma-dev to run the application.
When installing puma-dev, make sure that you set it up to listen on the .localhost
domain, and not the default .dev
domain.
After installing puma-dev using its instructions:
cd ~/.puma-dev
ln -s ~/path/to/sv_repository sv
It's useful to have puma-dev's log file in easy reach:
OSX Specific: ln -s ~/Library/Logs/puma-dev.log log/
To restart the server:
touch tmp/restart.txt
If it crashes, gets stuck, etc., kill the master process.
ps -ef | grep puma
kill -9 [PUMA_PROCESS_ID]
Running puma-dev on Ubuntu will require that you download the puma-dev
binary, and run it manually. There are other setup requirements detailed in the official docs (linked above.)
Use the following command to run puma-dev with correct configuration for dev environment.
puma-dev -d localhost -http-port 80 -https-port 443
You'll probably want to convert this to an alias to make starting the server simple.
If puma-dev crashes when starting the application with bundle: not found
in the logs, create a .powenv
file in the root of the repository and add commands to load the rbenv environment.
Follow official instructions install the CLI.
Login with your 'Heroku' credentials and follow the instrutions recived on the onbarding Email.
Load environment key for Rollbar from Heroku with:
heroku config -s --app sv-co | grep ROLLBAR_ACCESS_TOKEN >> .env
You might need to create the test database that you've configured with environment variables.
To execute all tests manually, run:
$ rspec
To generate spec coverage report, run:
COVERAGE=true rspec
This will generate a simplecov HTML coverage report within /coverage
Note: Code coverage is automatically generated by the CI server, and monitored using Codecov.
Background jobs are written as Rails ActiveJob-s, and deferred using Delayed::Job in the production environment.
By default, the development and test environment run jobs in-line. If you've manually configured the application to defer them instead, you can execute the jobs with:
$ rake jobs:workoff
TeamCity runs specs once commit are pushed to Github. When push is to the master
branch, and if specs pass, TeamCity marks the commit as successful on Github. This prompts Heroku to pick up the commit and deploy a new instance - so the entire process is automated.
We use two buildpacks at Heroku:
- Heroku's default ruby buildpack: https://github.com/heroku/heroku-buildpack-ruby
- Custom rake tasks (to run DB migrations): https://github.com/gunpowderlabs/buildpack-ruby-rake-deploy-tasks
Set up Heroku to have access to sv-co app.
Add heroku remote:
$ git remote add heroku [email protected]:sv-co.git
Then, to deploy:
- From
master
branch,git push heroku
will push local master to production (sv.co)
To safely deploy:
$ rspec && git push heroku && heroku run rake db:migrate --app sv-co && heroku restart --app sv-co
Basic coding conventions are defined in the .editorconfig file. Download plugin for your editor of choice. http://editorconfig.org/
- One blank line between discrete blocks of code.
- No more than one blank line between blocks / segments of code.
- Naming: Underscored variables and methods. CamelCase class names -
some_variable, some_method, SomeClass
- Use Coffeescript wherever possible.
- Naming: CamelCase variables and function -
someVariable, someFunction
- Use SCSS everywhere.
- Use BEM for naming classes -
block__element
, orblock__element--modifier