Submit social housing lettings and sales data (CORE)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
Daniel Baark 5e201d3553
CLDC-344: Validations (#36)
3 years ago
.github/workflows Allow workflow to be triggered manually 3 years ago
app CLDC-344: Validations (#36) 3 years ago
bin Move to Gov PaaS (#24) 3 years ago
config CLDC-344: Validations (#36) 3 years ago
db Add local authority section 3 years ago
doc/adr rename adr 3 years ago
lib Add application skeleton to repo 3 years ago
log Add application skeleton to repo 3 years ago
public Add application skeleton to repo 3 years ago
spec CLDC-344: Validations (#36) 3 years ago
storage Add application skeleton to repo 3 years ago
tmp Add application skeleton to repo 3 years ago
vendor Add application skeleton to repo 3 years ago
.browserslistrc Add application skeleton to repo 3 years ago
.cfignore Move to Gov PaaS (#24) 3 years ago
.dockerignore Add application skeleton to repo 3 years ago
.editorconfig Add application skeleton to repo 3 years ago
.env.example Avoid whitespace syntax mismatch between docker-compose and rails c 3 years ago
.gitignore CLDC-275: Form flow (#28) 3 years ago
.overcommit.yml Add application skeleton to repo 3 years ago
.rspec Add application skeleton to repo 3 years ago
.rubocop.yml Add application skeleton to repo 3 years ago
.ruby-version Update Ruby version and Gov UK frontend component gem 3 years ago
Dockerfile Update Ruby version and Gov UK frontend component gem 3 years ago
Gemfile CLDC-341: Conditional showing and hiding of question on a page (#29) 3 years ago
Gemfile.lock CLDC-344: Validations (#36) 3 years ago
LICENSE Initial commit 3 years ago
README.md Update README.md 3 years ago
Rakefile Add application skeleton to repo 3 years ago
babel.config.js Add application skeleton to repo 3 years ago
config.ru Add application skeleton to repo 3 years ago
docker-compose.yml Add application skeleton to repo 3 years ago
manifest.yml Single app name 3 years ago
package.json CLDC-341: Conditional showing and hiding of question on a page (#29) 3 years ago
postcss.config.js Add application skeleton to repo 3 years ago
yarn.lock CLDC-341: Conditional showing and hiding of question on a page (#29) 3 years ago

README.md

CI/CD Pipeline

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

  1. Copy the .env.example to .env and replace the database credentials with your local postgres user credentials.

  2. Install the dependencies:
    bundle install

  3. Create the database:
    rake db:create

  4. Run the database migrations:
    rake db:migrate

  5. Install the frontend depenencies:
    yarn install

  6. 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:

  1. Contact your organisation manager to get an account in dluhc-core organization and in the relevant spaces (sandbox/production).

  2. Install the Cloud Foundry CLI

  3. Login:
    cf login -a api.london.cloud.service.gov.uk -u <your_username>

  4. Set your deployment target (sandbox/production):
    cf target -o dluhc-core -s <deploy_environment>

  5. Deploy:
    cf push dluhc-core --strategy rolling. This will use the manifest file

Once the app is deployed:

  1. Get a Rails console:
    cf ssh dluhc-core -t -c "/tmp/lifecycle/launcher /home/vcap/app 'rails console' ''"

  2. Check logs:
    cf logs dluhc-core --recent

CI/CD

When a commit is made to main the following GitHub action jobs are triggered:

  1. Test: RSpec runs our test suite
  2. 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
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

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)
  • Text not required by a page/question such as a header or hint text should be passed as an empty string

Useful documentation (external dependencies)

GOV.UK Design System Form Builder for Rails

GOV.UK Frontend

Hotwire (Turbo/Stimulus)