Dushan
beccd74f83
|
3 years ago | |
---|---|---|
.github/workflows | 3 years ago | |
app | 3 years ago | |
bin | 3 years ago | |
config | 3 years ago | |
db | 3 years ago | |
doc/adr | 3 years ago | |
lib | 3 years ago | |
log | 3 years ago | |
public | 3 years ago | |
spec | 3 years ago | |
storage | 3 years ago | |
tmp | 3 years ago | |
vendor | 3 years ago | |
.browserslistrc | 3 years ago | |
.cfignore | 3 years ago | |
.dockerignore | 3 years ago | |
.editorconfig | 3 years ago | |
.env.example | 3 years ago | |
.gitignore | 3 years ago | |
.overcommit.yml | 3 years ago | |
.rspec | 3 years ago | |
.rubocop.yml | 3 years ago | |
.ruby-version | 3 years ago | |
Dockerfile | 3 years ago | |
Gemfile | 3 years ago | |
Gemfile.lock | 3 years ago | |
LICENSE | 3 years ago | |
README.md | 3 years ago | |
Rakefile | 3 years ago | |
babel.config.js | 3 years ago | |
config.ru | 3 years ago | |
docker-compose.yml | 3 years ago | |
manifest.yml | 3 years ago | |
package.json | 3 years ago | |
postcss.config.js | 3 years ago | |
yarn.lock | 3 years ago |
README.md
Data Collection App
This is the codebase for the Ruby on Rails app that will handle the submission of Lettings and Sales of Social Housing in England data.
Required Setup
Pre-requisites:
- Ruby
- Rails
- Postgres
Quick start
-
Copy the
.env.example
to.env
and replace the database credentials with your local postgres user credentials. -
Install the dependencies:
bundle install
-
Create the database:
rake db:create
-
Run the database migrations:
rake db:migrate
-
Install the frontend depenencies:
yarn install
-
Start the Rails server:
bundle exec rails s
The Rails server will start on http://localhost:3000.
Using Docker
docker-compose build
docker-compose run --rm app rails db:create
docker-compose up
The Rails server will start on http://localhost:8080.
Note docker-compose
runs the production docker image (RAILS_ENV=production
) as the Dockerfile doesn’t include development gems to keep the image size down.
Infrastructure
This application is running on GOV.UK PaaS. To deploy you need to:
-
Contact your organisation manager to get an account in
dluhc-core
organization and in the relevant spaces (sandbox/production). -
Login:
cf login -a api.london.cloud.service.gov.uk -u <your_username>
-
Set your deployment target (sandbox/production):
cf target -o dluhc-core -s <deploy_environment>
-
Deploy:
cf push dluhc-core --strategy rolling
. This will use the manifest file
Once the app is deployed:
-
Get a Rails console:
cf ssh dluhc-core -t -c "/tmp/lifecycle/launcher /home/vcap/app 'rails console' ''"
-
Check logs:
cf logs dluhc-core --recent
CI/CD
When a commit is made to main
the following GitHub action jobs are triggered:
- Test: RSpec runs our test suite
- Deploy: If the Test stage passes, this job will deploy the app to our GOV.UK PaaS account using the Cloud Foundry CLI
When a pull request is opened to main
only the Test stage runs.
Single log submission
The form for this is driven by a JSON file in /config/forms/{start_year}_{end_year}.json
The JSON should follow the structure:
{
"form_type": "lettings" / "sales",
"start_year": Integer, // i.e. 2020
"end_year": Integer, // i.e. 2021
"sections": {
"[snake_case_section_name_string]": {
"label": String,
"subsections": {
"[snake_case_subsection_name_string]": {
"label": String,
"pages": {
"[snake_case_page_name_string]": {
"header": String,
"description": String,
"questions": {
"[snake_case_question_name_string]": {
"header": String,
"hint_text": String,
"type": "text" / "numeric" / "radio" / "checkbox" / "date",
"min": Integer, // numeric only
"max": Integer, // numeric only
"step": Integer, // numeric only
"answer_options": { // checkbox and radio only
"0": String,
"1": String
},
"conditional_for": {
"[snake_case_question_to_enable_1_name_string]": ["condition-that-enables"],
"[snake_case_question_to_enable_2_name_string]": ["condition-that-enables"]
}
}
}
}
}
}
}
}
}
}
Assumptions made by the format:
- All forms have at least 1 section
- All sections have at least 1 subsection
- All subsections have at least 1 page
- All pages have at least 1 question
- The ActiveRecord case log model has a field for each question name (must match). In the case of checkbox questions it must have one field for every answer option (again names must match).
- Text not required by a page/question such as a header or hint text should be passed as an empty string
- For conditionally shown questions conditions that have been implemented and can be used are:
- Radio question answer option selected matches one of conditional e.g. ["answer-options-1-string", "answer-option-3-string"]
- Numeric question value matches condition e.g. [">2"], ["<7"] or ["== 6"]