diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..03bc5b1a --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @raul-gracia @padv2010 \ No newline at end of file diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..7b669868 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,5 @@ +## Description + +## Trello Card Link + +https://trello.com/c/ diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..ca8be2eb --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,23 @@ +version: 2 +updates: + - package-ecosystem: bundler + directory: '/' + schedule: + interval: daily + open-pull-requests-limit: 10 + ignore: + - dependency-name: faker + - package-ecosystem: npm + directory: '/' + schedule: + interval: daily + open-pull-requests-limit: 10 + - package-ecosystem: github-actions + directory: '/' + schedule: + interval: daily + open-pull-requests-limit: 10 + labels: + - DevOps + - dependencies + - github_actions diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..d8330339 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,57 @@ +# This workflow uses actions that are not certified by GitHub. They are +# provided by a third-party and are governed by separate terms of service, +# privacy policy, and support documentation. +# +# This workflow will install a prebuilt Ruby version, install dependencies, and +# run tests and linters. +name: 'Test' +on: + push: + branches: ['main'] + pull_request: + branches: ['main'] +jobs: + Rspec: + runs-on: ubuntu-latest + services: + postgres: + image: postgres:11-alpine + ports: + - '5432:5432' + env: + POSTGRES_DB: rails_test + POSTGRES_USER: rails + POSTGRES_PASSWORD: password + env: + RAILS_ENV: test + DATABASE_URL: 'postgres://rails:password@localhost:5432/rails_test' + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Install Ruby and gems + uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0 + with: + bundler-cache: true + - name: Set up database schema + run: bin/rails db:schema:load + - name: Set up database schema + run: bin/rails db:seed + - name: Run tests + run: bin/rspec + + Lint: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Install Ruby and gems + uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0 + with: + bundler-cache: true + # Add or replace any other lints here + - name: Security audit dependencies + run: bin/bundler-audit --update + - name: Security audit application code + run: bin/brakeman -q -w2 + - name: Lint Ruby files + run: bin/rubocop --parallel diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..2108c866 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,17 @@ +name: Deploy to Heroku + +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: akhileshns/heroku-deploy@v3.12.14 # This is the action + with: + heroku_api_key: ${{secrets.HEROKU_API_KEY}} + heroku_app_name: 'teacher-relocation-payment' #Must be unique in Heroku + heroku_email: 'raul.gracia@education.gov.uk' diff --git a/.gitignore b/.gitignore index 9e24f230..5f01464f 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ /yarn-error.log yarn-debug.log* .yarn-integrity +coverage/ diff --git a/.ruby-version b/.ruby-version index ccfb6efd..ff365e06 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-2.7.0 +3.1.3 diff --git a/Gemfile b/Gemfile index 3bcf12d1..7c5c4a91 100644 --- a/Gemfile +++ b/Gemfile @@ -52,6 +52,7 @@ gem "httparty", "~> 0.21" group :test do gem 'shoulda-matchers', '~> 5.0' + gem 'simplecov', require: false end group :development, :test do @@ -62,7 +63,6 @@ group :development, :test do gem "rubocop-rspec" # Debugging - gem "debug" gem "pry-byebug" # Better use of test helpers such as save_and_open_page/screenshot @@ -73,6 +73,9 @@ group :development, :test do gem "dotenv-rails" gem 'capybara' + + gem 'brakeman' + gem 'bundler-audit' end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index cc7191ce..df3c8074 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -72,7 +72,11 @@ GEM bindex (0.8.1) bootsnap (1.16.0) msgpack (~> 1.2) + brakeman (6.0.0) builder (3.2.4) + bundler-audit (0.9.1) + bundler (>= 1.2.0, < 3) + thor (~> 1.0) byebug (11.1.3) capybara (3.39.0) addressable @@ -95,6 +99,7 @@ GEM reline (>= 0.3.1) deep_merge (1.2.2) diff-lcs (1.5.0) + docile (1.4.0) dotenv (2.8.1) dotenv-rails (2.8.1) dotenv (= 2.8.1) @@ -282,6 +287,12 @@ GEM semantic_range (3.0.0) shoulda-matchers (5.3.0) activesupport (>= 5.2.0) + simplecov (0.22.0) + docile (~> 1.1) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.12.3) + simplecov_json_formatter (0.1.4) sprockets (4.2.0) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) @@ -320,6 +331,8 @@ PLATFORMS DEPENDENCIES bootsnap + brakeman + bundler-audit capybara config (~> 4.1) debug @@ -338,6 +351,7 @@ DEPENDENCIES rubocop-rails rubocop-rspec shoulda-matchers (~> 5.0) + simplecov sprockets-rails tzinfo-data uk_postcode diff --git a/Procfile b/Procfile new file mode 100644 index 00000000..9bddbbb3 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: bin/rails server -p ${PORT:-5000} -e $RAILS_ENV \ No newline at end of file diff --git a/bin/brakeman b/bin/brakeman new file mode 100755 index 00000000..4b790031 --- /dev/null +++ b/bin/brakeman @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'brakeman' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +bundle_binstub = File.expand_path("../bundle", __FILE__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("brakeman", "brakeman") diff --git a/bin/bundler-audit b/bin/bundler-audit new file mode 100755 index 00000000..39710847 --- /dev/null +++ b/bin/bundler-audit @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'bundler-audit' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +bundle_binstub = File.expand_path("../bundle", __FILE__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("bundler-audit", "bundler-audit") diff --git a/bin/rspec b/bin/rspec new file mode 100755 index 00000000..a6c78521 --- /dev/null +++ b/bin/rspec @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'rspec' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +bundle_binstub = File.expand_path("../bundle", __FILE__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("rspec-core", "rspec") diff --git a/bin/rubocop b/bin/rubocop new file mode 100755 index 00000000..d0c48829 --- /dev/null +++ b/bin/rubocop @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'rubocop' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +bundle_binstub = File.expand_path("../bundle", __FILE__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("rubocop", "rubocop") diff --git a/spec/features/completing_the_form_spec.rb b/spec/features/completing_the_form_spec.rb index 154c7a9e..e551fa55 100644 --- a/spec/features/completing_the_form_spec.rb +++ b/spec/features/completing_the_form_spec.rb @@ -25,7 +25,7 @@ def when_i_start_the_form end def and_i_complete_application_route_question - choose("Teacher") + choose(option: "teacher") click_button("Continue") end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 4658a1dd..2f5e3656 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,3 +1,7 @@ +require 'simplecov' +SimpleCov.start('rails') do + enable_coverage :branch +end # This file is copied to spec/ when you run 'rails generate rspec:install' require 'spec_helper' ENV['RAILS_ENV'] ||= 'test'