Skip to content

Commit 064964c

Browse files
committed
🧪 Improve CI harness integration
1 parent f5b171d commit 064964c

12 files changed

Lines changed: 136 additions & 59 deletions

File tree

.github/workflows/coverage.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ jobs:
5555
steps:
5656
### COUCHDB
5757
- name: Start CouchDB
58-
uses: iamssen/couchdb-github-action@5456fb038864d42f8b82d4c29e3c1decd7fa82fd # master
58+
uses: iamssen/couchdb-github-action@master
5959
with:
6060
couchdb-version: "3.4.1"
6161

6262
### MONGODB
6363
- name: Start MongoDB
64-
uses: supercharge/mongodb-github-action@90002f17bc44255a478ffc85b2401743d8367152 # v1.12.1
64+
uses: supercharge/mongodb-github-action@1.12.1
6565
with:
6666
mongodb-version: "8.0"
6767

.github/workflows/locked_deps.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ env:
3636
on:
3737
push:
3838
branches:
39-
- 'main'
40-
- '*-stable'
39+
- "main"
40+
- "*-stable"
4141
tags:
42-
- '!*' # Do not execute on tags
42+
- "!*" # Do not execute on tags
4343
pull_request:
4444
branches:
45-
- '*'
45+
- "*"
4646
# Allow manually triggering the workflow.
4747
workflow_dispatch:
4848

@@ -70,6 +70,24 @@ jobs:
7070
experimental: false
7171

7272
steps:
73+
### COUCHDB
74+
- name: Start CouchDB
75+
uses: iamssen/couchdb-github-action@master
76+
with:
77+
couchdb-version: "3.4.1"
78+
79+
### MONGODB
80+
- name: Start MongoDB
81+
uses: supercharge/mongodb-github-action@1.12.1
82+
with:
83+
mongodb-version: "8.0"
84+
85+
### SMOKE-TEST
86+
- name: Smoke CouchDB
87+
run: |
88+
curl -f http://127.0.0.1:5984/
89+
curl -X POST -H "Content-Type: application/json; charset=utf-8" -d '{"name": "admin", "password": "password"}' http://127.0.0.1:5984/_session
90+
7391
- name: Checkout
7492
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
7593
with:

.github/workflows/unlocked_deps.yml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ env:
2626
on:
2727
push:
2828
branches:
29-
- 'main'
30-
- '*-stable'
29+
- "main"
30+
- "*-stable"
3131
tags:
32-
- '!*' # Do not execute on tags
32+
- "!*" # Do not execute on tags
3333
pull_request:
3434
branches:
35-
- '*'
35+
- "*"
3636
# Allow manually triggering the workflow.
3737
workflow_dispatch:
3838

@@ -61,6 +61,24 @@ jobs:
6161
bundler: latest
6262

6363
steps:
64+
### COUCHDB
65+
- name: Start CouchDB
66+
uses: iamssen/couchdb-github-action@master
67+
with:
68+
couchdb-version: "3.4.1"
69+
70+
### MONGODB
71+
- name: Start MongoDB
72+
uses: supercharge/mongodb-github-action@1.12.1
73+
with:
74+
mongodb-version: "8.0"
75+
76+
### SMOKE-TEST
77+
- name: Smoke CouchDB
78+
run: |
79+
curl -f http://127.0.0.1:5984/
80+
curl -X POST -H "Content-Type: application/json; charset=utf-8" -d '{"name": "admin", "password": "password"}' http://127.0.0.1:5984/_session
81+
6482
- name: Checkout
6583
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
6684
with:

Appraisals

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,15 @@ appraise "unlocked_deps" do
4747
eval_gemfile "modular/optional.gemfile"
4848
eval_gemfile "modular/style.gemfile"
4949
eval_gemfile "modular/x_std_libs.gemfile"
50+
gem "couch_potato", "~> 1.17"
51+
gem "mongoid", "~> 9.0", ">= 9.0.3"
52+
gem "mongoid-rspec", "~> 4.2"
5053
gem "sequel", "~> 5.86", ">= 5.86.0"
5154
gem "rom-sql", "~> 3.7"
5255
eval_gemfile "modular/activerecord/r3/v8.0.gemfile"
56+
eval_gemfile "modular/bson/r3/v5.1.gemfile"
5357
eval_gemfile "modular/omniauth/r3/v2.1.gemfile"
58+
gem "ostruct", "~> 0.6", ">= 0.6.1" # Ruby >= 2.5
5459
end
5560

5661
appraise "head" do
@@ -84,6 +89,7 @@ end
8489

8590
appraise "ruby-3-0" do
8691
eval_gemfile "modular/x_std_libs/r3.1/libs.gemfile"
92+
gem "json", "< 2.16"
8793
end
8894

8995
appraise "ruby-3-1" do
@@ -92,7 +98,7 @@ end
9298

9399
appraise "ruby-3-2" do
94100
eval_gemfile "modular/x_std_libs/r3/libs.gemfile"
95-
gem "json", "< 2.19"
101+
gem "json", "< 2.16"
96102
end
97103

98104
appraise "ruby-3-3" do

Rakefile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,21 @@ begin
209209
end
210210
end
211211

212+
orm_specs.each do |orm, spec_file|
213+
RSpec::Core::RakeTask.new("spec_orm_#{orm}") do |task|
214+
task.pattern = spec_file
215+
end
216+
end
217+
218+
desc("Run all ORM specs (requires CouchDB and MongoDB running; NoBrainer remains isolated)")
219+
task(spec_orms: %i[
220+
spec_orm_active_record
221+
spec_orm_couch_potato
222+
spec_orm_mongoid
223+
spec_orm_rom
224+
spec_orm_sequel
225+
])
226+
212227
task(default: :test)
213228
rescue LoadError
214229
desc("spec task stub")

gemfiles/unlocked_deps.gemfile

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,28 @@
22

33
source "https://gem.coop"
44

5+
gem "irb", "~> 1.17"
6+
gem "couch_potato", "~> 1.17"
7+
gem "mongoid", "~> 9.0", ">= 9.0.3"
8+
gem "mongoid-rspec", "~> 4.2"
59
gem "sequel", "~> 5.86", ">= 5.86.0"
610
gem "rom-sql", "~> 3.7"
11+
gem "ostruct", "~> 0.6", ">= 0.6.1"
712

8-
gemspec path: "../"
9-
10-
eval_gemfile("modular/activerecord/r3/v8.0.gemfile")
11-
12-
eval_gemfile("modular/omniauth/r3/v2.1.gemfile")
13+
gemspec :path => "../"
1314

1415
eval_gemfile("modular/coverage.gemfile")
1516

1617
eval_gemfile("modular/documentation.gemfile")
1718

18-
eval_gemfile("modular/style.gemfile")
19-
2019
eval_gemfile("modular/optional.gemfile")
2120

21+
eval_gemfile("modular/style.gemfile")
22+
2223
eval_gemfile("modular/x_std_libs.gemfile")
24+
25+
eval_gemfile("modular/activerecord/r3/v8.0.gemfile")
26+
27+
eval_gemfile("modular/bson/r3/v5.1.gemfile")
28+
29+
eval_gemfile("modular/omniauth/r3/v2.1.gemfile")

spec/omniauth/identity/models/couch_potato_module_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# Placing above omniauth because it is a dependency of omniauth,
77
# which is undeclared in older versions.
88
require "logger"
9+
require "active_support"
910

1011
require "couch_potato"
1112

spec/omniauth/identity/models/no_brainer_spec.rb

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,48 +14,56 @@
1414
# If you try it, one or both of them will not work.
1515
#
1616
# However, if you have RethinkDB installed locally, this spec should work in isolation!
17-
require "nobrainer"
18-
19-
RSpec.describe(OmniAuth::Identity::Models::NoBrainer, :rethinkdb) do
20-
before(:context) do
21-
NoBrainer.configure do |config|
22-
config.app_name = "DeezBrains"
23-
config.rethinkdb_urls = ["rethinkdb://127.0.0.1:28015/DeezBrains_test"]
24-
config.table_options = {
25-
shards: 1,
26-
replicas: 1,
27-
write_acks: :majority,
28-
}
17+
if ENV.fetch("CI", "false").casecmp("true").zero? && ENV.fetch("OMNIAUTH_IDENTITY_ENABLE_RETHINKDB", "false").casecmp("true") != 0
18+
RSpec.describe("NoBrainer ORM", :rethinkdb) do
19+
it("is isolated to local RethinkDB-enabled runs") do
20+
skip("NoBrainer specs require RethinkDB; set OMNIAUTH_IDENTITY_ENABLE_RETHINKDB=true to run them in CI")
2921
end
30-
NoBrainer.sync_schema
3122
end
23+
else
24+
require "nobrainer"
3225

33-
before do
34-
nobrainer_test_identity = Class.new do
35-
include NoBrainer::Document
26+
RSpec.describe(OmniAuth::Identity::Models::NoBrainer, :rethinkdb) do
27+
before(:context) do
28+
NoBrainer.configure do |config|
29+
config.app_name = "DeezBrains"
30+
config.rethinkdb_urls = ["rethinkdb://127.0.0.1:28015/DeezBrains_test"]
31+
config.table_options = {
32+
shards: 1,
33+
replicas: 1,
34+
write_acks: :majority,
35+
}
36+
end
37+
NoBrainer.sync_schema
38+
end
39+
40+
before do
41+
nobrainer_test_identity = Class.new do
42+
include NoBrainer::Document
3643

37-
include OmniAuth::Identity::Models::NoBrainer
44+
include OmniAuth::Identity::Models::NoBrainer
3845

39-
field :email
40-
field :password_digest
46+
field :email
47+
field :password_digest
48+
end
49+
stub_const("NoBrainerTestIdentity", nobrainer_test_identity)
50+
NoBrainer.purge!
4151
end
42-
stub_const("NoBrainerTestIdentity", nobrainer_test_identity)
43-
NoBrainer.purge!
44-
end
4552

46-
describe "model", type: :model do
47-
let(:model_klass) { NoBrainerTestIdentity }
53+
describe "model", type: :model do
54+
let(:model_klass) { NoBrainerTestIdentity }
4855

49-
include_context "with persistable model"
56+
include_context "with persistable model"
5057

51-
describe "::locate" do
52-
it "delegates locate to the where query method" do
53-
args = {
54-
"email" => "open faced",
55-
"category" => "sandwiches",
56-
}
57-
allow(model_klass).to(receive(:where).with(args).and_return(["wakka"]))
58-
expect(model_klass.locate(args)).to(eq("wakka"))
58+
describe "::locate" do
59+
it "delegates locate to the where query method" do
60+
args = {
61+
"email" => "open faced",
62+
"category" => "sandwiches",
63+
}
64+
allow(model_klass).to(receive(:where).with(args).and_return(["wakka"]))
65+
expect(model_klass.locate(args)).to(eq("wakka"))
66+
end
5967
end
6068
end
6169
end

spec/omniauth/identity/models/rom_spec.rb

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,23 @@
44

55
RSpec.describe(OmniAuth::Identity::Models::Rom, :sqlite3) do
66
before do
7-
# Use create_table? so this is idempotent and safe to run before each example.
8-
ROM_DB.create_table?(:rom_test_identities) do
7+
ROM_DB.drop_table?(:rom_test_identities)
8+
ROM_DB.drop_table?(:rom_test_owners)
9+
10+
ROM_DB.create_table(:rom_test_identities) do
911
primary_key :id
1012
String :email, null: false
1113
String :password_digest, null: false
14+
String :pwd_hash
1215
# Add the login column to support tests that use a non-standard auth_key
1316
String :login
1417
Integer :owner_id
1518
end
1619

17-
ROM_DB.create_table?(:rom_test_owners) do
20+
ROM_DB.create_table(:rom_test_owners) do
1821
primary_key :id
1922
String :name, null: false
2023
end
21-
22-
# Clear the tables before each test
23-
ROM_DB[:rom_test_identities].delete
24-
ROM_DB[:rom_test_owners].delete
2524
end
2625

2726
describe "model", type: :model do

spec/spec_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@
6060
# Enable flags like --only-failures and --next-failure
6161
config.example_status_persistence_file_path = ".rspec_status"
6262

63+
if ENV.fetch("CI", "false").casecmp("true").zero? && ENV.fetch("OMNIAUTH_IDENTITY_ENABLE_RETHINKDB", "false").casecmp("true") != 0
64+
config.filter_run_excluding(rethinkdb: true)
65+
end
66+
6367
# Disable RSpec exposing methods globally on `Module` and `main`
6468
config.disable_monkey_patching!
6569

0 commit comments

Comments
 (0)