Skip to content

Commit

Permalink
Clean up ci.yml and remove capybara (for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
dracco1993 committed May 15, 2024
1 parent 75b9ba7 commit 57db7b6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 118 deletions.
105 changes: 11 additions & 94 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,81 +6,10 @@ on:
branches: [ main ]

jobs:
<%- unless skip_brakeman? -%>
scan_ruby:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: true

- name: Scan for security vulnerabilities in Ruby dependencies
run: bin/brakeman --no-pager

<% end -%>
<%- if options[:javascript] == "importmap" -%>
scan_js:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: true

- name: Scan for security vulnerabilities in JavaScript dependencies
run: bin/importmap audit

<% end -%>
<%- unless skip_rubocop? -%>
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: true

- name: Lint code for consistent style
run: bin/rubocop -f github

<% end -%>
<% unless options[:skip_test] -%>
test:
runs-on: ubuntu-latest

<%- if options[:database] == "sqlite3" -%>
# services:
# redis:
# image: redis
# ports:
# - 6379:6379
# options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5
<%- else -%>
services:
<%- if options[:database] == "mysql" || options[:database] == "trilogy" -%>
mysql:
image: mysql
env:
MYSQL_ALLOW_EMPTY_PASSWORD: true
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
<%- elsif options[:database] == "postgresql" -%>
postgres:
image: postgres
env:
Expand All @@ -89,18 +18,16 @@ jobs:
ports:
- 5432:5432
options: --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3
<%- end -%>

# redis:
# image: redis
# ports:
# - 6379:6379
# options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5

<%- end -%>
steps:
- name: Install packages
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y google-chrome-stable <%= (dockerfile_base_packages + [database.base_package]).join(" ") %>
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y google-chrome-stable curl libjemalloc2 libvips postgresql-client libpq-dev

- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -110,29 +37,19 @@ jobs:
with:
ruby-version: .ruby-version
bundler-cache: true
<%- if using_bun? -%>

- uses: oven-sh/setup-bun@v1
with:
bun-version: <%= dockerfile_bun_version %>
<%- end -%>

- name: Run tests
env:
RAILS_ENV: test
<%- if options[:database] == "mysql" || options[:database] == "trilogy" -%>
DATABASE_URL: mysql2://127.0.0.1:3306
<%- elsif options[:database] == "postgresql" -%>
DATABASE_URL: postgres://postgres:postgres@localhost:5432
<%- end -%>
# REDIS_URL: redis://localhost:6379/0
run: bin/rails db:test:prepare spec

- name: Keep screenshots from failed system tests
uses: actions/upload-artifact@v4
if: failure()
with:
name: screenshots
path: ${{ github.workspace }}/tmp/screenshots
if-no-files-found: ignore
<% end -%>
run: bin/rails spec
# run: bin/rails db:test:prepare spec

# - name: Keep screenshots from failed system tests
# uses: actions/upload-artifact@v4
# if: failure()
# with:
# name: screenshots
# path: ${{ github.workspace }}/tmp/capybara
# if-no-files-found: ignore
48 changes: 24 additions & 24 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,27 +95,27 @@
Kernel.srand config.seed
end

Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, browser: :chrome)
end

Capybara.register_driver :chrome_headless_container_friendly do |app|
browser_options = ::Selenium::WebDriver::Chrome::Options.new
browser_options.args << "--headless"
browser_options.args << "--disable-gpu"
# Sandbox cannot be used inside unprivileged containers
browser_options.args << "--no-sandbox"
# Forces docker to allocate enough memory to chromedriver for page rendering
# https://developers.google.com/web/tools/puppeteer/troubleshooting#tips
browser_options.args << "--disable-dev-shm-usage"
browser_options.args << "--enable-features=ConversionMeasurement,AttributionReportingCrossAppWeb"
# browser_options.args << "--remote-debugging-pipe"
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
end

# Capybara 3 and later defaults to using puma.
Capybara.server = :puma

Capybara.javascript_driver = ENV["INCONTAINER"] ? :chrome_headless_container_friendly : :chrome

Capybara.default_max_wait_time = 15
# Capybara.register_driver :chrome do |app|
# Capybara::Selenium::Driver.new(app, browser: :chrome)
# end

# Capybara.register_driver :chrome_headless_container_friendly do |app|
# browser_options = ::Selenium::WebDriver::Chrome::Options.new
# browser_options.args << "--headless"
# browser_options.args << "--disable-gpu"
# # Sandbox cannot be used inside unprivileged containers
# browser_options.args << "--no-sandbox"
# # Forces docker to allocate enough memory to chromedriver for page rendering
# # https://developers.google.com/web/tools/puppeteer/troubleshooting#tips
# browser_options.args << "--disable-dev-shm-usage"
# browser_options.args << "--enable-features=ConversionMeasurement,AttributionReportingCrossAppWeb"
# # browser_options.args << "--remote-debugging-pipe"
# Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
# end

# # Capybara 3 and later defaults to using puma.
# Capybara.server = :puma

# Capybara.javascript_driver = ENV["INCONTAINER"] ? :chrome_headless_container_friendly : :chrome

# Capybara.default_max_wait_time = 15

0 comments on commit 57db7b6

Please sign in to comment.