happy-heron, or H2 (from "Hydrus 2.0"), is a Rails web application enabling users to deposit scholarly content into the SDR. It will replace Hydrus.
- Comps: https://projects.invisionapp.com/share/EQXC9CLKCR2
- Design Documentation: https://docs.google.com/document/d/1fcr2DYo7OrX-qTdeUOTWKSS1rlq_47sehESmbvgUsrk/edit
Ruby dependencies can be installed with bundle install
, JavaScript dependencies are installed via yarn install
.
Start up dependencies with docker-compose up db
(with -d
to run in background), then run tests with bundle exec rspec
.
To run the server in development mode set REMOTE_USER
because we aren't running behind Shibboleth.
REMOTE_USER=auser@stanford.edu bin/rails server
Spin up all docker-compose services for local development and in-browser testing:
$ docker-compose up # use -d to run in background
This will spin up the H2 web application, its background workers, and all service dependencies declared in docker-compose.yml.
H2 uses Sorbet optional Ruby type checking. Run a manual static type check via srb tc
; note that CI for H2 will automate this. After adding a new gem to the Gemfile, or running bundle update
, build the new type definitions with srb rbi update
.
If you would like to automate this step, consider using a git pre-commit hook. To do this, create a file named .git/hooks/pre-commit
and add code like the following:
# .git/hooks/pre-commit
if git diff --cached --name-only --diff-filter=ACM | grep --quiet 'Gemfile.lock'
then
exec env SRB_YES=1 bundle exec srb rbi update
fi
if git diff --cached --name-only --diff-filter=ACM | grep --quiet '^app/'
then
exec bundle exec rake rails_rbi:all
exec bundle exec srb rbi hidden-definitions
exec bundle exec srb rbi suggest-typed
fi
and then chmod +x .git/hooks/pre-commit
.
Thereafter, every time you commit changes to Gemfile.lock
or app
, Sorbet will update type-checking information. Once it's done, add & commit the changes in sorbet/
(feel free to squash them into the prior commit).
Before running rake rails_rbi:all
, make sure the db
docker-compose service is running, else the type definitions for the app's models will be deleted.
H2 is deployed via Capistrano to servers running the Passenger server in standalone mode (as a systemd service rather than as an Apache module). Passenger configuration lives in config/Passengerfile.json
which is managed by Puppet and does not live in the application repository.
At the end of the 2020 workcycle, H2 should use sdr-api to do file and metadata deposits.
If your Git muscle memory is too strong and you find you keep typing master
when you mean main
(the default branch for H2), you can help yourself a bit by creating an alias thusly:
$ git symbolic-ref refs/heads/master refs/heads/main