Compare commits

...

1 Commits

Author SHA1 Message Date
Samuel Young b591d6992f CLDC-NONE: Improve README 2 weeks ago
  1. 69
      docs/setup.md

69
docs/setup.md

@ -22,6 +22,8 @@ We recommend using [nvm](https://github.com/nvm-sh/nvm) to manage NodeJS version
1. Install PostgreSQL
If you already have a valid Postgres installation you can skip this step.
macOS:
```bash
@ -38,6 +40,8 @@ We recommend using [nvm](https://github.com/nvm-sh/nvm) to manage NodeJS version
2. Create a Postgres user
If you already have a valid Postgres installation you can skip this step.
```bash
sudo su - postgres -c "createuser <username> -s -P"
```
@ -84,25 +88,10 @@ We recommend using [nvm](https://github.com/nvm-sh/nvm) to manage NodeJS version
brew install yarn
```
or you could run it without specifying the version and it should use the version from .nvmrc
```bash
nvm install
nvm use
brew install yarn
```
Linux (Debian):
```bash
curl -sL https://deb.nodesource.com/setup_20.x | sudo bash -
sudo apt -y install nodejs
mkdir -p ~/.npm-packages
npm config set prefix ~/.npm-packages
echo 'NPM_PACKAGES="~/.npm-packages"' >> ~/.bashrc
echo 'export PATH="$PATH:$NPM_PACKAGES/bin"' >> ~/.bashrc
source ~/.bashrc
npm install --location=global yarn
npm install --global yarn
```
6. (For running tests) Install Gecko Driver
@ -132,42 +121,50 @@ Also ensure you have firefox installed
2. Install the dependencies:
```bash
bundle install && yarn install
rbenv exec bundle install && yarn install
```
3. Create the database & run migrations:
```bash
bundle exec rake db:create db:migrate
rbenv exec bundle exec rake db:create db:migrate
```
4. Seed the database if required:
```bash
bundle exec rake db:seed
rbenv exec bundle exec rake db:seed
```
5. Build assets once before running the app for the first time:
```bash
yarn build --mode=development
```
5. For Ordinance Survey related functionality, such as using the UPRN, you will need to set `OS_DATA_KEY` in your .env file. This key is shared across the team and can be found in AWS Secrets Manager.
6. For email functionality, you will need a GOV.UK Notify API key, which is individual to you. Ask an existing team member to invite you to the "CORE Helpdesk" Notify service. Once invited, sign in and go to "API integration" to generate an API key, and set this as `GOVUK_NOTIFY_API_KEY` in your .env file.
6. For Ordinance Survey related functionality, such as using the UPRN, you will need to set `OS_DATA_KEY` in your .env file. This key is shared across the team and can be found in AWS Secrets Manager.
7. For email functionality, you will need a GOV.UK Notify API key, which is individual to you. Ask an existing team member to invite you to the "CORE Helpdesk" Notify service. Once invited, sign in and go to "API integration" to generate an API key, and set this as `GOVUK_NOTIFY_API_KEY` in your .env file.
## Running Locally
### Application
Start the dev servers
Start the dev servers via one of the following methods:
a. If using RubyMine, run the "submit-social-housing-lettings-and-sales-data" Rails configuration.
a. Using Foreman:
b. Using Foreman:
```bash
./bin/dev
```
b. Individually:
c. Individually:
Rails:
```bash
bundle exec rails s
rbenv exec bundle exec rails s
```
JavaScript (for hot reloading):
@ -176,20 +173,18 @@ JavaScript (for hot reloading):
yarn build --mode=development --watch
```
If you’re not modifying front end assets you can bundle them as a one off task:
```bash
yarn build --mode=development
```
Development mode will target the latest versions of Chrome, Firefox and Safari for transpilation while production mode will target older browsers.
The Rails server will start on <http://localhost:3000>.
To sign in locally, you can use any username and password from your local database. The seed task in `seeds.rb` creates users in various roles all with the password `REVIEW_APP_USER_PASSWORD` from your .env file (which has default value `password`).
To create any other users, you can edit the seed commands, or run similar commands in the rails console.
To create any other users, you can log in as a support user and create new users via the admin interface. Or, you can edit the seed commands, or run similar commands in the rails console.
You can also insert a new user row using SQL, but you will need to generate a correctly encrypted password. You can find the value to use for encrypted password which corresponds to the password `YOURPASSWORDHERE` using `User.new(:password => [YOURPASSWORDHERE]).encrypted_password`.
### rbenv
In general, whenever needing to run a Ruby command, use `rbenv exec bundle exec <command>` to ensure the correct Ruby version and gemset are used.
### Debugging
Add the line `binding.pry` to the code to pause the execution of the code at that line and open a powerful interactive console for debugging.
@ -216,19 +211,21 @@ More details on debugging in RubyMine can be found at <https://www.jetbrains.com
### Tests
```bash
bundle exec rspec
rbenv exec bundle exec rspec
```
Or if using RubyMine, right click a spec file and select the 'Run' option.
To run a specific folder use
```bash
bundle exec rspec ./spec/folder
rbenv exec bundle exec rspec ./spec/folder
```
To run individual files use
```bash
bundle exec rspec ./spec/path/to/file.rb
rbenv exec bundle exec rspec ./spec/path/to/file.rb
```
or run individual files/tests from your IDE
@ -247,7 +244,7 @@ Feature toggles can be found in `app/services/feature_toggle.rb`
### Linting
```bash
bundle exec rake lint
rbenv exec bundle exec rake lint
```
## Using Docker

Loading…
Cancel
Save