Skip to content

Commit c5ec6e8

Browse files
committed
Don't install a package for system test when applications don't use it
1 parent 852d0cd commit c5ec6e8

File tree

5 files changed

+15
-2
lines changed

5 files changed

+15
-2
lines changed

railties/lib/rails/generators/app_base.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,14 @@ def dockerfile_build_packages
609609
packages.compact.sort
610610
end
611611

612+
def ci_packages
613+
if depends_on_system_test?
614+
dockerfile_build_packages << "google-chrome-stable"
615+
else
616+
dockerfile_build_packages
617+
end
618+
end
619+
612620
def css_gemfile_entry
613621
return if options[:api]
614622
return unless options[:css]

railties/lib/rails/generators/rails/app/templates/github/ci.yml.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jobs:
100100
<%- end -%>
101101
steps:
102102
- name: Install packages
103-
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y google-chrome-stable <%= dockerfile_base_packages.join(" ") %>
103+
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y <%= ci_packages.join(" ") %>
104104

105105
- name: Checkout code
106106
uses: actions/checkout@v4

railties/lib/rails/generators/rails/plugin/templates/github/ci.yml.tt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
<%- end -%>
6565
steps:
6666
- name: Install packages
67-
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y google-chrome-stable <%= dockerfile_base_packages.join(" ") %>
67+
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y <%= ci_packages.join(" ") %>
6868

6969
- name: Checkout code
7070
uses: actions/checkout@v4

railties/test/generators/api_app_generator_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def test_api_modified_files
6262
assert_no_match(/test:system/, content)
6363
assert_no_match(/screenshots/, content)
6464
assert_no_match(/scan_js/, content)
65+
assert_no_match(/google-chrome-stable/, content)
6566
end
6667
end
6768

railties/test/generators/app_generator_test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,10 @@ def test_generator_if_skip_system_test_is_given
519519
assert_directory("test")
520520

521521
assert_no_directory("test/system")
522+
523+
assert_file ".github/workflows/ci.yml" do |content|
524+
assert_no_match(/google-chrome-stable/, content)
525+
end
522526
end
523527

524528
def test_does_not_generate_system_test_files_if_skip_system_test_is_given

0 commit comments

Comments
 (0)