Skip to content

Commit

Permalink
Merge branch 'master' into valgrind
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Nov 11, 2024
2 parents 6a067ad + 9f4577a commit 6b3c3fc
Show file tree
Hide file tree
Showing 18 changed files with 98 additions and 31 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ jobs:
include:
- ruby: 3.3
gemfile: Gemfile
# - ruby: 3.3
# gemfile: gemfiles/rails72.gemfile
# - ruby: 3.2
# gemfile: gemfiles/rails71.gemfile
# - ruby: 3.1
# gemfile: gemfiles/rails70.gemfile
env:
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
steps:
Expand All @@ -18,5 +24,14 @@ jobs:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- run: bundle exec rake compile
- run: bundle exec rake test

- uses: ankane/setup-postgres@v1
- run: ADAPTER=postgresql bundle exec rake test

- uses: ankane/setup-mysql@v1
- run: ADAPTER=mysql2 bundle exec rake test
- run: ADAPTER=trilogy bundle exec rake test

- run: sudo apt-get update && sudo apt-get install valgrind
- run: bundle exec rake test:valgrind
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 0.7.0 (2024-10-22)

- Added support for Trilogy
- Dropped support for Ruby < 3.1 and Rails < 7

## 0.6.1 (2024-09-04)

- Improved CSP support

## 0.6.0 (2023-07-02)

- Fixed support for aliases, dates, and times in config file
Expand Down
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ gem "rake"
gem "rake-compiler"
gem "minitest"
gem "combustion"
gem "rails", "~> 7.1.0"
gem "rails", "~> 8.0.0"
gem "sqlite3"
gem "mysql2"
gem "trilogy"
gem "pg"
gem "benchmark-ips"
gem "ruby_memcheck"
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2016-2023 Andrew Kane
Copyright (c) 2016-2024 Andrew Kane

MIT License

Expand Down
8 changes: 4 additions & 4 deletions app/views/field_test/experiments/_experiments.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
<thead>
<tr>
<th>Variant</th>
<th style="width: 20%;">Participants</th>
<th style="width: 20%;">Conversions</th>
<th style="width: 20%;">Conversion Rate</th>
<th style="width: 20%;">Prob Winning</th>
<th class="width-20">Participants</th>
<th class="width-20">Conversions</th>
<th class="width-20">Conversion Rate</th>
<th class="width-20">Prob Winning</th>
</tr>
</thead>
<tbody>
Expand Down
6 changes: 3 additions & 3 deletions app/views/field_test/experiments/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
<thead>
<tr>
<th>Participant</th>
<th style="width: 20%;">Variant</th>
<th style="width: 20%;">Converted</th>
<th style="width: 20%;">Started</th>
<th class="width-20">Variant</th>
<th class="width-20">Converted</th>
<th class="width-20">Started</th>
</tr>
</thead>
<tbody>
Expand Down
17 changes: 13 additions & 4 deletions app/views/field_test/participants/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<thead>
<tr>
<th>Experiment</th>
<th style="width: 20%;">Variant</th>
<th style="width: 20%;">Converted</th>
<th style="width: 20%;">Started</th>
<th class="width-20">Variant</th>
<th class="width-20">Converted</th>
<th class="width-20">Started</th>
</tr>
</thead>
<tbody>
Expand All @@ -23,7 +23,7 @@
<% experiment = FieldTest::Experiment.find(membership.experiment) rescue nil %>
<% if experiment %>
<%= form_for membership do |f| %>
<%= f.select "variant", options_for_select(FieldTest::Experiment.find(membership.experiment).variants.map { |v| [v, v] }, membership.variant), {}, onchange: "this.form.submit()" %>
<%= f.select "variant", options_for_select(FieldTest::Experiment.find(membership.experiment).variants.map { |v| [v, v] }, membership.variant) %>
<% end %>
<% else %>
<%= membership.variant %>
Expand Down Expand Up @@ -60,3 +60,12 @@
<% end %>
</tbody>
</table>

<%= javascript_tag nonce: true do %>
var selects = document.querySelectorAll(".edit_membership select");
for (var i = 0; i < selects.length; i++) {
selects[i].addEventListener("change", function () {
this.form.submit();
});
}
<% end %>
11 changes: 9 additions & 2 deletions app/views/layouts/field_test/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>Field Test</title>

<style>
<meta charset="utf-8" />

<%= content_tag :style, nonce: request.content_security_policy_nonce_directives&.include?("style-src") ? content_security_policy_nonce : nil do %>
body {
margin: 0;
padding: 20px;
Expand Down Expand Up @@ -78,7 +81,11 @@
padding-left: 10px;
padding-right: 10px;
}
</style>

.width-20 {
width: 20%;
}
<% end %>
</head>
<body>
<%= yield %>
Expand Down
8 changes: 4 additions & 4 deletions field_test.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ Gem::Specification.new do |spec|
spec.require_path = "lib"
spec.extensions = ["ext/field_test/extconf.rb"]

spec.required_ruby_version = ">= 3"
spec.required_ruby_version = ">= 3.1"

spec.add_dependency "railties", ">= 6.1"
spec.add_dependency "activerecord", ">= 6.1"
spec.add_dependency "railties", ">= 7"
spec.add_dependency "activerecord", ">= 7"
spec.add_dependency "browser", ">= 2"
spec.add_dependency "rice", ">= 4.0.2"
spec.add_dependency "rice", ">= 4.3.3"
end
3 changes: 2 additions & 1 deletion gemfiles/rails70.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ gem "rake-compiler"
gem "minitest"
gem "combustion"
gem "rails", "~> 7.0.0"
gem "sqlite3"
gem "sqlite3", "< 2"
gem "mysql2"
gem "activerecord-trilogy-adapter"
gem "pg"
13 changes: 13 additions & 0 deletions gemfiles/rails71.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
source "https://rubygems.org"

gemspec path: ".."

gem "rake"
gem "rake-compiler"
gem "minitest"
gem "combustion"
gem "rails", "~> 7.1.0"
gem "sqlite3", "< 2"
gem "mysql2"
gem "trilogy"
gem "pg"
3 changes: 2 additions & 1 deletion gemfiles/rails61.gemfile → gemfiles/rails72.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ gem "rake"
gem "rake-compiler"
gem "minitest"
gem "combustion"
gem "rails", "~> 6.1.0"
gem "rails", "~> 7.2.0"
gem "sqlite3"
gem "mysql2"
gem "trilogy"
gem "pg"
11 changes: 6 additions & 5 deletions lib/field_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ def self.precision

def self.events_supported?
unless defined?(@events_supported)
connection = FieldTest::Membership.connection
table_name = "field_test_events"
@events_supported =
if connection.respond_to?(:data_source_exists?)
connection.data_source_exists?(table_name)
else
connection.table_exists?(table_name)
FieldTest::Membership.connection_pool.with_connection do |connection|
if connection.respond_to?(:data_source_exists?)
connection.data_source_exists?(table_name)
else
connection.table_exists?(table_name)
end
end
end
@events_supported
Expand Down
6 changes: 3 additions & 3 deletions lib/field_test/experiment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ def results(goal: nil)

participated = relation.count

adapter_name = relation.connection.adapter_name
adapter_name = relation.connection_db_config.adapter.to_s
column =
if FieldTest.legacy_participants
:participant
elsif adapter_name =~ /postg/i # postgres
elsif adapter_name.match?(/postg/i) # postgres
"(participant_type, participant_id)"
elsif adapter_name =~ /mysql/i
elsif adapter_name.match?(/mysql|trilogy/i)
"COALESCE(participant_type, ''), participant_id"
else
# SQLite supports single column
Expand Down
2 changes: 1 addition & 1 deletion lib/field_test/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module FieldTest
VERSION = "0.6.0"
VERSION = "0.7.0"
end
8 changes: 8 additions & 0 deletions test/dashboard_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require_relative "test_helper"

class DashboardTest < ActionDispatch::IntegrationTest
def test_root
get field_test_engine.root_path
assert_response :success
end
end
3 changes: 2 additions & 1 deletion test/internal/config/database.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
test:
adapter: <%= ENV["ADAPTER"] || "sqlite3" %>
database: <%= ["postgresql", "mysql2"].include?(ENV["ADAPTER"]) ? "field_test_test" : "db/combustion_test.sqlite" %>
database: <%= ["postgresql", "mysql2", "trilogy"].include?(ENV["ADAPTER"]) ? "field_test_test" : "db/combustion_test.sqlite" %>
host: <%= ENV["ADAPTER"] == "trilogy" ? "127.0.0.1" : nil %>
1 change: 1 addition & 0 deletions test/internal/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Rails.application.routes.draw do
resources :users, only: [:index]
get "exclude", to: "users#exclude"
mount FieldTest::Engine, at: "field_test"
end

0 comments on commit 6b3c3fc

Please sign in to comment.