- <%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "logs", filters_count: applied_filters_count(@filter_type))) %>
+ <%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "log", filters_count: applied_filters_count(@filter_type))) %>
<% if logs&.any? %>
<%= govuk_link_to "Download (CSV)", csv_download_url, type: "text/csv", class: "govuk-!-margin-right-4", style: "white-space: nowrap" %>
<% if @current_user.support? %>
diff --git a/app/views/logs/index.html.erb b/app/views/logs/index.html.erb
index f142a2580..c51466097 100644
--- a/app/views/logs/index.html.erb
+++ b/app/views/logs/index.html.erb
@@ -1,4 +1,4 @@
-<% item_label = format_label(@pagy.count, "logs") %>
+<% item_label = format_label(@pagy.count, "log") %>
<% title = format_title(@searched, "#{log_type_for_controller(controller).capitalize} logs", current_user, item_label, @pagy.count, nil) %>
<% content_for :title, title %>
diff --git a/app/views/logs/update_logs.html.erb b/app/views/logs/update_logs.html.erb
index 1ab1fa31c..985adecf3 100644
--- a/app/views/logs/update_logs.html.erb
+++ b/app/views/logs/update_logs.html.erb
@@ -1,4 +1,4 @@
-<% item_label = format_label(@pagy.count, "logs") %>
+<% item_label = format_label(@pagy.count, "log") %>
<% title = "Update logs" %>
<% content_for :title, title %>
diff --git a/app/views/organisation_relationships/managing_agents.html.erb b/app/views/organisation_relationships/managing_agents.html.erb
index 726533e53..d09056d86 100644
--- a/app/views/organisation_relationships/managing_agents.html.erb
+++ b/app/views/organisation_relationships/managing_agents.html.erb
@@ -1,4 +1,4 @@
-<% item_label = format_label(@pagy.count, "managing agents") %>
+<% item_label = format_label(@pagy.count, "managing agent") %>
<% if current_user.support? %>
<%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %>
@@ -44,7 +44,7 @@
pagy: @pagy,
searched: @searched,
item_label:,
- search_item: "managing agents",
+ search_item: "managing agent",
total_count: @total_count,
remove_path: ->(org_id) { managing_agents_remove_organisation_path(target_organisation_id: org_id) },
} %>
diff --git a/app/views/organisation_relationships/stock_owners.html.erb b/app/views/organisation_relationships/stock_owners.html.erb
index 41b7af06d..3bbba6bf8 100644
--- a/app/views/organisation_relationships/stock_owners.html.erb
+++ b/app/views/organisation_relationships/stock_owners.html.erb
@@ -1,4 +1,4 @@
-<% item_label = format_label(@pagy.count, "stock owners") %>
+<% item_label = format_label(@pagy.count, "stock owner") %>
<% if current_user.support? %>
<%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %>
<%= render SubNavigationComponent.new(items: secondary_items(request.path, @organisation.id)) %>
@@ -41,7 +41,7 @@
pagy: @pagy,
searched: @searched,
item_label:,
- search_item: "stock owners",
+ search_item: "stock owner",
total_count: @total_count,
remove_path: ->(org_id) { stock_owners_remove_organisation_path(target_organisation_id: org_id) },
} %>
diff --git a/app/views/organisations/_organisation_list.html.erb b/app/views/organisations/_organisation_list.html.erb
index 67cc9c7a3..16309a5eb 100644
--- a/app/views/organisations/_organisation_list.html.erb
+++ b/app/views/organisations/_organisation_list.html.erb
@@ -1,7 +1,7 @@
<%= govuk_table do |table| %>
<%= table.with_caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %>
- <%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "organisations", filters_count: applied_filters_count(@filter_type))) %>
+ <%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "organisation", filters_count: applied_filters_count(@filter_type))) %>
<% end %>
<%= table.with_head do |head| %>
<%= head.with_row do |row| %>
diff --git a/app/views/organisations/index.html.erb b/app/views/organisations/index.html.erb
index 411d792c1..1de12ab77 100644
--- a/app/views/organisations/index.html.erb
+++ b/app/views/organisations/index.html.erb
@@ -1,4 +1,4 @@
-<% item_label = format_label(@pagy.count, "organisations") %>
+<% item_label = format_label(@pagy.count, "organisation") %>
<% title = format_title(@searched, "Organisations", current_user, item_label, @pagy.count, nil) %>
<% content_for :title, title %>
diff --git a/app/views/organisations/logs.html.erb b/app/views/organisations/logs.html.erb
index e172a76a9..e318ff6ee 100644
--- a/app/views/organisations/logs.html.erb
+++ b/app/views/organisations/logs.html.erb
@@ -1,4 +1,4 @@
-<% item_label = format_label(@pagy.count, "logs") %>
+<% item_label = format_label(@pagy.count, "log") %>
<% title = format_title(@searched, action_name.humanize, current_user, item_label, @pagy.count, @organisation.name) %>
<% content_for :title, title %>
diff --git a/app/views/schemes/_scheme_list.html.erb b/app/views/schemes/_scheme_list.html.erb
index 967295236..1c11e86d1 100644
--- a/app/views/schemes/_scheme_list.html.erb
+++ b/app/views/schemes/_scheme_list.html.erb
@@ -2,7 +2,7 @@
<%= govuk_table do |table| %>
<%= table.with_caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %>
- <%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "schemes", filters_count: applied_filters_count(@filter_type))) %>
+ <%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "scheme", filters_count: applied_filters_count(@filter_type))) %>
<% if @schemes&.any? %>
<%= govuk_link_to "Download schemes (CSV)", schemes_csv_download_url, type: "text/csv", class: "govuk-!-margin-right-4", style: "white-space: nowrap" %>
<%= govuk_link_to "Download locations (CSV)", locations_csv_download_url, type: "text/csv", class: "govuk-!-margin-right-4", style: "white-space: nowrap" %>
diff --git a/app/views/users/_user_list.html.erb b/app/views/users/_user_list.html.erb
index 436c0def2..82a82b33b 100644
--- a/app/views/users/_user_list.html.erb
+++ b/app/views/users/_user_list.html.erb
@@ -1,7 +1,7 @@
<%= govuk_table do |table| %>
<%= table.with_caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %>
- <%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "users", filters_count: applied_filters_count(@filter_type))) %>
+ <%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "user", filters_count: applied_filters_count(@filter_type))) %>
<% if current_user.support? %>
<% query = searched.present? ? "?search=#{searched}" : nil %>
<%= govuk_link_to "Download (CSV)", "#{request.path}.csv#{query}", type: "text/csv", style: "white-space: nowrap" %>
diff --git a/spec/components/search_result_caption_component_spec.rb b/spec/components/search_result_caption_component_spec.rb
index 25cbc1bdd..05ac09630 100644
--- a/spec/components/search_result_caption_component_spec.rb
+++ b/spec/components/search_result_caption_component_spec.rb
@@ -5,7 +5,7 @@ RSpec.describe SearchResultCaptionComponent, type: :component do
let(:count) { 2 }
let(:item_label) { "user" }
let(:total_count) { 3 }
- let(:item) { "schemes" }
+ let(:item) { "scheme" }
let(:filters_count) { 1 }
let(:result) { render_inline(described_class.new(searched:, count:, item_label:, total_count:, item:, filters_count:)) }
@@ -21,6 +21,14 @@ RSpec.describe SearchResultCaptionComponent, type: :component do
it "renders table caption including the search results and total" do
expect(result.to_html).to eq("\n 2 users matching search
\n\n")
end
+
+ context "with 1 result" do
+ let(:count) { 1 }
+
+ it "renders table caption including the search results and total" do
+ expect(result.to_html).to eq("\n 1 user matching search
\n\n")
+ end
+ end
end
context "when filter results are found" do
@@ -29,6 +37,14 @@ RSpec.describe SearchResultCaptionComponent, type: :component do
it "renders table caption including the search results and total" do
expect(result.to_html).to eq("\n 2 users matching filters
\n\n")
end
+
+ context "with 1 result" do
+ let(:count) { 1 }
+
+ it "renders table caption including the search results and total" do
+ expect(result.to_html).to eq("\n 1 user matching filters
\n\n")
+ end
+ end
end
context "when no search/filter is applied" do
@@ -38,6 +54,14 @@ RSpec.describe SearchResultCaptionComponent, type: :component do
it "renders table caption with total count only" do
expect(result.to_html).to eq("\n \n 2 total schemes\n \n\n")
end
+
+ context "with 1 result" do
+ let(:count) { 1 }
+
+ it "renders table caption with total count only" do
+ expect(result.to_html).to eq("\n \n 1 total scheme\n \n\n")
+ end
+ end
end
context "when nothing is found" do
diff --git a/spec/requests/lettings_logs_controller_spec.rb b/spec/requests/lettings_logs_controller_spec.rb
index e795b76ea..d84a6d714 100644
--- a/spec/requests/lettings_logs_controller_spec.rb
+++ b/spec/requests/lettings_logs_controller_spec.rb
@@ -759,7 +759,7 @@ RSpec.describe LettingsLogsController, type: :request do
it "has search results in the title" do
get "/lettings-logs?search=#{log_to_search.id}", headers:, params: {}
- expect(page).to have_title("Lettings logs (1 logs matching ‘#{log_to_search.id}’) - Submit social housing lettings and sales data (CORE) - GOV.UK")
+ expect(page).to have_title("Lettings logs (1 log matching ‘#{log_to_search.id}’) - Submit social housing lettings and sales data (CORE) - GOV.UK")
end
it "shows lettings logs matching the id" do
@@ -895,7 +895,7 @@ RSpec.describe LettingsLogsController, type: :request do
end
it "shows the total log count" do
- expect(CGI.unescape_html(response.body)).to match("1 total logs")
+ expect(CGI.unescape_html(response.body)).to match("1 total log")
end
it "does not show the pagination links" do
diff --git a/spec/requests/organisation_relationships_controller_spec.rb b/spec/requests/organisation_relationships_controller_spec.rb
index 79706fff9..8e8dc4f2d 100644
--- a/spec/requests/organisation_relationships_controller_spec.rb
+++ b/spec/requests/organisation_relationships_controller_spec.rb
@@ -53,7 +53,7 @@ RSpec.describe OrganisationRelationshipsController, type: :request do
end
it "shows the pagination count" do
- expect(page).to have_content("1 total stock owners")
+ expect(page).to have_content("1 total stock owner")
end
context "when adding a stock owner" do
@@ -149,7 +149,7 @@ RSpec.describe OrganisationRelationshipsController, type: :request do
end
it "shows the pagination count" do
- expect(page).to have_content("1 total managing agents")
+ expect(page).to have_content("1 total managing agent")
end
context "and current organisation is deactivated" do
@@ -345,7 +345,7 @@ RSpec.describe OrganisationRelationshipsController, type: :request do
end
it "shows the pagination count" do
- expect(page).to have_content("1 total stock owners")
+ expect(page).to have_content("1 total stock owner")
end
end
@@ -481,7 +481,7 @@ RSpec.describe OrganisationRelationshipsController, type: :request do
end
it "shows the pagination count" do
- expect(page).to have_content("1 total managing agents")
+ expect(page).to have_content("1 total managing agent")
end
end
@@ -647,7 +647,7 @@ RSpec.describe OrganisationRelationshipsController, type: :request do
end
it "shows the pagination count" do
- expect(page).to have_content("1 total stock owners")
+ expect(page).to have_content("1 total stock owner")
end
context "when adding a stock owner" do
@@ -697,7 +697,7 @@ RSpec.describe OrganisationRelationshipsController, type: :request do
end
it "shows the pagination count" do
- expect(page).to have_content("1 total managing agents")
+ expect(page).to have_content("1 total managing agent")
end
it "shows remove link(s)" do
diff --git a/spec/requests/organisations_controller_spec.rb b/spec/requests/organisations_controller_spec.rb
index ae3297d59..26723a563 100644
--- a/spec/requests/organisations_controller_spec.rb
+++ b/spec/requests/organisations_controller_spec.rb
@@ -1203,7 +1203,7 @@ RSpec.describe OrganisationsController, type: :request do
it "has search results in the title" do
get "/organisations/#{organisation.id}/lettings-logs?search=#{log_to_search.id}", headers: headers, params: {}
- expect(page).to have_title("#{organisation.name} (1 logs matching ‘#{log_to_search.id}’) - Submit social housing lettings and sales data (CORE) - GOV.UK")
+ expect(page).to have_title("#{organisation.name} (1 log matching ‘#{log_to_search.id}’) - Submit social housing lettings and sales data (CORE) - GOV.UK")
end
it "has search term in the search box" do
@@ -1352,7 +1352,7 @@ RSpec.describe OrganisationsController, type: :request do
it "has search results in the title" do
get "/organisations/#{organisation.id}/sales-logs?search=#{log_to_search.id}", headers: headers, params: {}
- expect(page).to have_title("#{organisation.name} (1 logs matching ‘#{log_to_search.id}’) - Submit social housing lettings and sales data (CORE) - GOV.UK")
+ expect(page).to have_title("#{organisation.name} (1 log matching ‘#{log_to_search.id}’) - Submit social housing lettings and sales data (CORE) - GOV.UK")
end
it "shows sales logs matching the id" do
@@ -1616,11 +1616,11 @@ RSpec.describe OrganisationsController, type: :request do
end
it "updates the table caption" do
- expect(page).to have_content("1 organisations matching search")
+ expect(page).to have_content("1 organisation matching search")
end
it "has search in the title" do
- expect(page).to have_title("Organisations (1 organisations matching ‘#{search_param}’) - Submit social housing lettings and sales data (CORE) - GOV.UK")
+ expect(page).to have_title("Organisations (1 organisation matching ‘#{search_param}’) - Submit social housing lettings and sales data (CORE) - GOV.UK")
end
context "when the search term matches more than 1 result" do
diff --git a/spec/requests/sales_logs_controller_spec.rb b/spec/requests/sales_logs_controller_spec.rb
index dc056c1ed..6c882cc87 100644
--- a/spec/requests/sales_logs_controller_spec.rb
+++ b/spec/requests/sales_logs_controller_spec.rb
@@ -610,7 +610,7 @@ RSpec.describe SalesLogsController, type: :request do
it "has search results in the title" do
get "/sales-logs?search=#{log_to_search.id}", headers: headers, params: {}
- expect(page).to have_title("Sales logs (1 logs matching ‘#{log_to_search.id}’) - Submit social housing lettings and sales data (CORE) - GOV.UK")
+ expect(page).to have_title("Sales logs (1 log matching ‘#{log_to_search.id}’) - Submit social housing lettings and sales data (CORE) - GOV.UK")
end
it "shows sales logs matching the id" do
@@ -692,7 +692,7 @@ RSpec.describe SalesLogsController, type: :request do
end
it "shows the total log count" do
- expect(CGI.unescape_html(response.body)).to match("1 total logs")
+ expect(CGI.unescape_html(response.body)).to match("1 total log")
end
it "does not show the pagination links" do
From af79b58741dc9e18098ccade83adedf9d1936e75 Mon Sep 17 00:00:00 2001
From: Rachael Booth
Date: Fri, 6 Dec 2024 16:51:49 +0000
Subject: [PATCH 2/2] Separate services tests to improve pipeline times (#2853)
* Display slowest test
* Attempt to improve test times on github
* Run services tests in parallel
* Try keeping services in Tests
* Revert "Try keeping services in Tests"
This reverts commit ef2e1bf4d255ed9a4bf87abda2b4d2b33787d406.
* Fix parallel setup for services tests
* Remove profiling
---
.github/workflows/run_tests.yml | 411 +++++++++++++++++++++++++
.github/workflows/staging_pipeline.yml | 347 +--------------------
spec/db/seeds_spec.rb | 7 +-
3 files changed, 417 insertions(+), 348 deletions(-)
create mode 100644 .github/workflows/run_tests.yml
diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml
new file mode 100644
index 000000000..1965a4034
--- /dev/null
+++ b/.github/workflows/run_tests.yml
@@ -0,0 +1,411 @@
+name: Run Tests
+
+on:
+ workflow_call:
+ pull_request:
+ types:
+ - opened
+ - synchronize
+ merge_group:
+ workflow_dispatch:
+
+defaults:
+ run:
+ shell: bash
+
+jobs:
+ test:
+ name: Tests
+ runs-on: ubuntu-latest
+
+ services:
+ postgres:
+ image: postgres:13.5
+ env:
+ POSTGRES_PASSWORD: password
+ POSTGRES_USER: postgres
+ POSTGRES_DB: data_collector
+ ports:
+ - 5432:5432
+ # Needed because the Postgres container does not provide a health check
+ # tmpfs makes database faster by using RAM
+ options: >-
+ --mount type=tmpfs,destination=/var/lib/postgresql/data
+ --health-cmd pg_isready
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
+
+ env:
+ RAILS_ENV: test
+ GEMFILE_RUBY_VERSION: 3.1.1
+ DB_HOST: localhost
+ DB_DATABASE: data_collector
+ DB_USERNAME: postgres
+ DB_PASSWORD: password
+ RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
+ PARALLEL_TEST_PROCESSORS: 4
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Set up Ruby
+ uses: ruby/setup-ruby@v1
+ with:
+ bundler-cache: true
+
+ - name: Set up Node.js
+ uses: actions/setup-node@v4
+ with:
+ cache: yarn
+ node-version: 20
+
+ - name: Create database
+ run: |
+ bundle exec rake parallel:setup
+
+ - name: Compile assets
+ run: |
+ bundle exec rake assets:precompile
+
+ - name: Run tests
+ run: |
+ bundle exec rake parallel:spec['spec\/(?!features|models|requests|services)']
+
+ feature_test:
+ name: Feature Tests
+ runs-on: ubuntu-latest
+
+ services:
+ postgres:
+ image: postgres:13.5
+ env:
+ POSTGRES_PASSWORD: password
+ POSTGRES_USER: postgres
+ POSTGRES_DB: data_collector
+ ports:
+ - 5432:5432
+ # Needed because the Postgres container does not provide a health check
+ # tmpfs makes database faster by using RAM
+ options: >-
+ --mount type=tmpfs,destination=/var/lib/postgresql/data
+ --health-cmd pg_isready
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
+
+ env:
+ RAILS_ENV: test
+ GEMFILE_RUBY_VERSION: 3.1.1
+ DB_HOST: localhost
+ DB_DATABASE: data_collector
+ DB_USERNAME: postgres
+ DB_PASSWORD: password
+ RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Set up Ruby
+ uses: ruby/setup-ruby@v1
+ with:
+ bundler-cache: true
+
+ - name: Set up Node.js
+ uses: actions/setup-node@v4
+ with:
+ cache: yarn
+ node-version: 20
+
+ - name: Create database
+ run: |
+ bundle exec rake db:prepare
+
+ - name: Compile assets
+ run: |
+ bundle exec rake assets:precompile
+
+ - name: Run tests
+ run: |
+ bundle exec rspec spec/features --fail-fast --exclude-pattern "spec/features/accessibility_spec.rb"
+
+ model_test:
+ name: Model tests
+ runs-on: ubuntu-latest
+
+ services:
+ postgres:
+ image: postgres:13.5
+ env:
+ POSTGRES_PASSWORD: password
+ POSTGRES_USER: postgres
+ POSTGRES_DB: data_collector
+ ports:
+ - 5432:5432
+ # Needed because the Postgres container does not provide a health check
+ # tmpfs makes database faster by using RAM
+ options: >-
+ --mount type=tmpfs,destination=/var/lib/postgresql/data
+ --health-cmd pg_isready
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
+
+ env:
+ RAILS_ENV: test
+ GEMFILE_RUBY_VERSION: 3.1.1
+ DB_HOST: localhost
+ DB_DATABASE: data_collector
+ DB_USERNAME: postgres
+ DB_PASSWORD: password
+ RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Set up Ruby
+ uses: ruby/setup-ruby@v1
+ with:
+ bundler-cache: true
+
+ - name: Set up Node.js
+ uses: actions/setup-node@v4
+ with:
+ cache: yarn
+ node-version: 20
+
+ - name: Create database
+ run: |
+ bundle exec rake db:prepare
+
+ - name: Compile assets
+ run: |
+ bundle exec rake assets:precompile
+
+ - name: Run tests
+ run: |
+ bundle exec rspec spec/models --fail-fast
+
+ requests_test:
+ name: Requests tests
+ runs-on: ubuntu-latest
+
+ services:
+ postgres:
+ image: postgres:13.5
+ env:
+ POSTGRES_PASSWORD: password
+ POSTGRES_USER: postgres
+ POSTGRES_DB: data_collector
+ ports:
+ - 5432:5432
+ # Needed because the Postgres container does not provide a health check
+ # tmpfs makes database faster by using RAM
+ options: >-
+ --mount type=tmpfs,destination=/var/lib/postgresql/data
+ --health-cmd pg_isready
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
+
+ env:
+ RAILS_ENV: test
+ GEMFILE_RUBY_VERSION: 3.1.1
+ DB_HOST: localhost
+ DB_DATABASE: data_collector
+ DB_USERNAME: postgres
+ DB_PASSWORD: password
+ RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
+ PARALLEL_TEST_PROCESSORS: 4
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Set up Ruby
+ uses: ruby/setup-ruby@v1
+ with:
+ bundler-cache: true
+
+ - name: Set up Node.js
+ uses: actions/setup-node@v4
+ with:
+ cache: yarn
+ node-version: 20
+
+ - name: Create database
+ run: |
+ bundle exec rake parallel:setup
+
+ - name: Compile assets
+ run: |
+ bundle exec rake assets:precompile
+
+ - name: Run tests
+ run: |
+ bundle exec rake parallel:spec['spec/requests']
+
+ services_test:
+ name: Services Tests
+ runs-on: ubuntu-latest
+
+ services:
+ postgres:
+ image: postgres:13.5
+ env:
+ POSTGRES_PASSWORD: password
+ POSTGRES_USER: postgres
+ POSTGRES_DB: data_collector
+ ports:
+ - 5432:5432
+ # Needed because the Postgres container does not provide a health check
+ # tmpfs makes database faster by using RAM
+ options: >-
+ --mount type=tmpfs,destination=/var/lib/postgresql/data
+ --health-cmd pg_isready
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
+
+ env:
+ RAILS_ENV: test
+ GEMFILE_RUBY_VERSION: 3.1.1
+ DB_HOST: localhost
+ DB_DATABASE: data_collector
+ DB_USERNAME: postgres
+ DB_PASSWORD: password
+ RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
+ PARALLEL_TEST_PROCESSORS: 4
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Set up Ruby
+ uses: ruby/setup-ruby@v1
+ with:
+ bundler-cache: true
+
+ - name: Set up Node.js
+ uses: actions/setup-node@v4
+ with:
+ cache: yarn
+ node-version: 20
+
+ - name: Create database
+ run: |
+ bundle exec rake parallel:setup
+
+ - name: Compile assets
+ run: |
+ bundle exec rake assets:precompile
+
+ - name: Run tests
+ run: |
+ bundle exec rake parallel:spec['spec\/services']
+
+ accessibility_test:
+ name: Accessibility tests
+ runs-on: ubuntu-latest
+
+ services:
+ postgres:
+ image: postgres:13.5
+ env:
+ POSTGRES_PASSWORD: password
+ POSTGRES_USER: postgres
+ POSTGRES_DB: data_collector
+ ports:
+ - 5432:5432
+ # Needed because the Postgres container does not provide a health check
+ # tmpfs makes database faster by using RAM
+ options: >-
+ --mount type=tmpfs,destination=/var/lib/postgresql/data
+ --health-cmd pg_isready
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
+
+ env:
+ RAILS_ENV: test
+ GEMFILE_RUBY_VERSION: 3.1.1
+ DB_HOST: localhost
+ DB_DATABASE: data_collector
+ DB_USERNAME: postgres
+ DB_PASSWORD: password
+ RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
+ PARALLEL_TEST_PROCESSORS: 4
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Set up Ruby
+ uses: ruby/setup-ruby@v1
+ with:
+ bundler-cache: true
+
+ - name: Set up Node.js
+ uses: actions/setup-node@v4
+ with:
+ cache: yarn
+ node-version: 20
+
+ - name: Create database
+ run: |
+ bundle exec rake parallel:setup
+
+ - name: Compile assets
+ run: |
+ bundle exec rake assets:precompile
+
+ - name: Run tests
+ run: |
+ bundle exec rspec spec/features/accessibility_spec.rb --fail-fast
+
+ lint:
+ name: Lint
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Set up Ruby
+ uses: ruby/setup-ruby@v1
+ with:
+ bundler-cache: true
+
+ - name: Set up Node.js
+ uses: actions/setup-node@v4
+ with:
+ cache: yarn
+ node-version: 20
+
+ - name: Install packages and symlink local dependencies
+ run: |
+ yarn install --immutable --immutable-cache --check-cache
+
+ - name: Lint
+ run: |
+ bundle exec rake lint
+
+ audit:
+ name: Audit dependencies
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ - name: Set up Ruby
+ uses: ruby/setup-ruby@v1
+ with:
+ bundler-cache: true
+
+ - name: Audit
+ run: |
+ bundle exec bundler-audit
diff --git a/.github/workflows/staging_pipeline.yml b/.github/workflows/staging_pipeline.yml
index aff0fe5f0..a2e777db0 100644
--- a/.github/workflows/staging_pipeline.yml
+++ b/.github/workflows/staging_pipeline.yml
@@ -4,11 +4,6 @@ on:
push:
branches:
- main
- pull_request:
- types:
- - opened
- - synchronize
- merge_group:
workflow_dispatch:
defaults:
@@ -21,347 +16,13 @@ env:
repository: core
jobs:
- test:
- name: Tests
- runs-on: ubuntu-latest
-
- services:
- postgres:
- image: postgres:13.5
- env:
- POSTGRES_PASSWORD: password
- POSTGRES_USER: postgres
- POSTGRES_DB: data_collector
- ports:
- - 5432:5432
- # Needed because the Postgres container does not provide a health check
- # tmpfs makes database faster by using RAM
- options: >-
- --mount type=tmpfs,destination=/var/lib/postgresql/data
- --health-cmd pg_isready
- --health-interval 10s
- --health-timeout 5s
- --health-retries 5
-
- env:
- RAILS_ENV: test
- GEMFILE_RUBY_VERSION: 3.1.1
- DB_HOST: localhost
- DB_DATABASE: data_collector
- DB_USERNAME: postgres
- DB_PASSWORD: password
- RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
- PARALLEL_TEST_PROCESSORS: 4
-
- steps:
- - name: Checkout
- uses: actions/checkout@v4
-
- - name: Set up Ruby
- uses: ruby/setup-ruby@v1
- with:
- bundler-cache: true
-
- - name: Set up Node.js
- uses: actions/setup-node@v4
- with:
- cache: yarn
- node-version: 20
-
- - name: Create database
- run: |
- bundle exec rake parallel:setup
-
- - name: Compile assets
- run: |
- bundle exec rake assets:precompile
-
- - name: Run tests
- run: |
- bundle exec rake parallel:spec['spec\/(?!features|models|requests)']
-
- feature_test:
- name: Feature Tests
- runs-on: ubuntu-latest
-
- services:
- postgres:
- image: postgres:13.5
- env:
- POSTGRES_PASSWORD: password
- POSTGRES_USER: postgres
- POSTGRES_DB: data_collector
- ports:
- - 5432:5432
- # Needed because the Postgres container does not provide a health check
- # tmpfs makes database faster by using RAM
- options: >-
- --mount type=tmpfs,destination=/var/lib/postgresql/data
- --health-cmd pg_isready
- --health-interval 10s
- --health-timeout 5s
- --health-retries 5
-
- env:
- RAILS_ENV: test
- GEMFILE_RUBY_VERSION: 3.1.1
- DB_HOST: localhost
- DB_DATABASE: data_collector
- DB_USERNAME: postgres
- DB_PASSWORD: password
- RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
-
- steps:
- - name: Checkout
- uses: actions/checkout@v4
-
- - name: Set up Ruby
- uses: ruby/setup-ruby@v1
- with:
- bundler-cache: true
-
- - name: Set up Node.js
- uses: actions/setup-node@v4
- with:
- cache: yarn
- node-version: 20
-
- - name: Create database
- run: |
- bundle exec rake db:prepare
-
- - name: Compile assets
- run: |
- bundle exec rake assets:precompile
-
- - name: Run tests
- run: |
- bundle exec rspec spec/features --fail-fast --exclude-pattern "spec/features/accessibility_spec.rb"
-
- model_test:
- name: Model tests
- runs-on: ubuntu-latest
-
- services:
- postgres:
- image: postgres:13.5
- env:
- POSTGRES_PASSWORD: password
- POSTGRES_USER: postgres
- POSTGRES_DB: data_collector
- ports:
- - 5432:5432
- # Needed because the Postgres container does not provide a health check
- # tmpfs makes database faster by using RAM
- options: >-
- --mount type=tmpfs,destination=/var/lib/postgresql/data
- --health-cmd pg_isready
- --health-interval 10s
- --health-timeout 5s
- --health-retries 5
-
- env:
- RAILS_ENV: test
- GEMFILE_RUBY_VERSION: 3.1.1
- DB_HOST: localhost
- DB_DATABASE: data_collector
- DB_USERNAME: postgres
- DB_PASSWORD: password
- RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
-
- steps:
- - name: Checkout
- uses: actions/checkout@v4
-
- - name: Set up Ruby
- uses: ruby/setup-ruby@v1
- with:
- bundler-cache: true
-
- - name: Set up Node.js
- uses: actions/setup-node@v4
- with:
- cache: yarn
- node-version: 20
-
- - name: Create database
- run: |
- bundle exec rake db:prepare
-
- - name: Compile assets
- run: |
- bundle exec rake assets:precompile
-
- - name: Run tests
- run: |
- bundle exec rspec spec/models --fail-fast
-
- requests_test:
- name: Requests tests
- runs-on: ubuntu-latest
-
- services:
- postgres:
- image: postgres:13.5
- env:
- POSTGRES_PASSWORD: password
- POSTGRES_USER: postgres
- POSTGRES_DB: data_collector
- ports:
- - 5432:5432
- # Needed because the Postgres container does not provide a health check
- # tmpfs makes database faster by using RAM
- options: >-
- --mount type=tmpfs,destination=/var/lib/postgresql/data
- --health-cmd pg_isready
- --health-interval 10s
- --health-timeout 5s
- --health-retries 5
-
- env:
- RAILS_ENV: test
- GEMFILE_RUBY_VERSION: 3.1.1
- DB_HOST: localhost
- DB_DATABASE: data_collector
- DB_USERNAME: postgres
- DB_PASSWORD: password
- RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
- PARALLEL_TEST_PROCESSORS: 4
-
- steps:
- - name: Checkout
- uses: actions/checkout@v4
-
- - name: Set up Ruby
- uses: ruby/setup-ruby@v1
- with:
- bundler-cache: true
-
- - name: Set up Node.js
- uses: actions/setup-node@v4
- with:
- cache: yarn
- node-version: 20
-
- - name: Create database
- run: |
- bundle exec rake parallel:setup
-
- - name: Compile assets
- run: |
- bundle exec rake assets:precompile
-
- - name: Run tests
- run: |
- bundle exec rake parallel:spec['spec/requests']
-
- accessibility_test:
- name: Accessibility tests
- runs-on: ubuntu-latest
-
- services:
- postgres:
- image: postgres:13.5
- env:
- POSTGRES_PASSWORD: password
- POSTGRES_USER: postgres
- POSTGRES_DB: data_collector
- ports:
- - 5432:5432
- # Needed because the Postgres container does not provide a health check
- # tmpfs makes database faster by using RAM
- options: >-
- --mount type=tmpfs,destination=/var/lib/postgresql/data
- --health-cmd pg_isready
- --health-interval 10s
- --health-timeout 5s
- --health-retries 5
-
- env:
- RAILS_ENV: test
- GEMFILE_RUBY_VERSION: 3.1.1
- DB_HOST: localhost
- DB_DATABASE: data_collector
- DB_USERNAME: postgres
- DB_PASSWORD: password
- RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
- PARALLEL_TEST_PROCESSORS: 4
-
- steps:
- - name: Checkout
- uses: actions/checkout@v4
-
- - name: Set up Ruby
- uses: ruby/setup-ruby@v1
- with:
- bundler-cache: true
-
- - name: Set up Node.js
- uses: actions/setup-node@v4
- with:
- cache: yarn
- node-version: 20
-
- - name: Create database
- run: |
- bundle exec rake parallel:setup
-
- - name: Compile assets
- run: |
- bundle exec rake assets:precompile
-
- - name: Run tests
- run: |
- bundle exec rspec spec/features/accessibility_spec.rb --fail-fast
-
- lint:
- name: Lint
- runs-on: ubuntu-latest
-
- steps:
- - name: Checkout
- uses: actions/checkout@v4
-
- - name: Set up Ruby
- uses: ruby/setup-ruby@v1
- with:
- bundler-cache: true
-
- - name: Set up Node.js
- uses: actions/setup-node@v4
- with:
- cache: yarn
- node-version: 20
-
- - name: Install packages and symlink local dependencies
- run: |
- yarn install --immutable --immutable-cache --check-cache
-
- - name: Lint
- run: |
- bundle exec rake lint
-
- audit:
- name: Audit dependencies
- runs-on: ubuntu-latest
-
- steps:
- - name: Checkout
- uses: actions/checkout@v4
-
- - name: Set up Ruby
- uses: ruby/setup-ruby@v1
- with:
- bundler-cache: true
-
- - name: Audit
- run: |
- bundle exec bundler-audit
+ tests:
+ name: Run Tests
+ uses: ./.github/workflows/run_tests.yml
aws_deploy:
name: AWS Deploy
- if: github.ref == 'refs/heads/main'
- needs: [lint, test, feature_test, requests_test, model_test, audit]
+ needs: [tests]
uses: ./.github/workflows/aws_deploy.yml
with:
aws_account_id: 107155005276
diff --git a/spec/db/seeds_spec.rb b/spec/db/seeds_spec.rb
index 316f04ba6..6ae07ddb0 100644
--- a/spec/db/seeds_spec.rb
+++ b/spec/db/seeds_spec.rb
@@ -21,7 +21,8 @@ RSpec.describe "seeding process", type: task do
allow(Rails.env).to receive(:review?).and_return(true)
end
- it "sets up correct data" do
+ # Doing this in one test should save ~2 minutes
+ it "sets up correct data idempotently" do
expect {
Rails.application.load_seed
}.to change(User, :count)
@@ -30,10 +31,6 @@ RSpec.describe "seeding process", type: task do
.and change(Scheme, :count)
.and change(Location, :count)
.and change(LaRentRange, :count)
- end
-
- it "is idempotent" do
- Rails.application.load_seed
expect {
Rails.application.load_seed