Skip to content
This repository has been archived by the owner on Jan 5, 2021. It is now read-only.

Development Setup

Adam Wead edited this page Apr 9, 2019 · 9 revisions

Dependencies

  • Java 8
  • Ruby 2.4.1
  • Postgres 9 or later
  • File Information Tool Set (FITS) (brew install fits)
  • Node (11.8.0 or later is recommended) (brew install node)
  • Yarn (brew install yarn)

All of these can be installed using Brew. A Ruby manager is recommended for installing different versions of Ruby and its gems. Options here include:

Rbenv and chruby can also be installed with brew.

Development Setup

Ensure you have the above dependencies installed and working correctly. Verify that you have the correct version of Ruby installed:

ruby --version

Verify that Postgres is running:

psql

Clone the application and install:

git clone
cd cho
bundle install
yarn install

Ensure that postgres is installed and running, then:

createdb `whoami`
cp config/samples/database.yml config/database.yml

And edit config/database.yml, replacing YOUR_LOCAL_USERNAME with your local user's login name -- this should be the output of the whoami command. Enter you password, if you are using one. Note: this information is not saved in git.

Create the databases for dev and test:

`createdb cho_dev`
`createdb cho_test`

Run migrations:

rake db:drop db:create db:migrate
rake db:migrate RAILS_ENV=test

Running the Application Locally

LDAP

CHO is configured to connect to LDAP, however we don't store the config file in Git. You will need to obtain a config file from DSRD. Once you have the file, place it in the config directory:

cp hydra-ldap.yml config

Headers

Authentication is performed using headers sent by WebAuth via Apache. Locally, we need to fake these so CHO knows you're authenticated. See the Scholarsphere page on how to set this up.

Start Up

In another terminal window, start solr and leave it running. Alternatively, you can start it from your existing window and background the process.

bundle exec solr_wrapper

Seed the database with the required fields and schemas:

bundle exec rake db:seed

Start the Rails server:

bundle exec rails server

Start the webpacker dev server:

./bin/webpack-dev-server --watch --colors --progress

Running the Test Suite

Start up a test instance of Solr:

bundle exec solr_wrapper --config config/solr_wrapper_test.yml

Run the test suite:

bundle exec rspec

Linters

We use several different linters to ensure consistent, good-quality code. Most of these are managed via the gem, Niftany, which has Rubocop (for ruby code), erb-lint, and scss-list, for erb partials and sass. Additionally, there is JS linting via eslint.

Niftany will run in the CI build, but if you want to do it locally:

bundle exec niftany

It will also autocorrect as well:

bundle exec niftany -a

If you're doing JS code, you need to lint that separately:

yarn lint

This is not run during CI presently.

We can auto-configure Rubocop if we need:

bundle exec rubocop --auto-gen-config

This will re-generate the .rubocop-todo.yml file to whitelist certain files.