Add modular safeguard support
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
調査の方向性
Issue で説明されている DatabaseCleaner::Safeguard::CHECKS と既存の ActiveRecord::Tasks::DatabaseTasks.check_protected_environments! メカニズムから始めます。テストスイートを確認し、bin/rspec を実行して現在の safeguard の動作を理解します。safeguard をモジュール化し、ENV 変数だけに依存せずに ORM 固有の checks を提供できるようになれば完了です。
索引モデルが issue の本文から書いたものです。
説明
My team recently came across a really nasty issue where spring kept our ActiveRecord::Base.connection_config cached. In that case, the current ENV var based safeguards failed us (luckily nobody was seriously injured).
For example,
# First, let's run a console
> DATABASE_URL=$(heroku config:get DATABASE_URL -a my-prod-app) bin/rails console
# :tada: we're running tests against the old DATABASE_URL even though it's not set
> bin/rspec
There are lots of different ways to get into this scenario (like other code loaders or multiple ORMs that use other variables). While checking for the ENV vars works for some low hanging fruit, it doesn't let ORMs (or maybe even other app/test frameworks) make more intelligent decisions.
We actually just added this to our test suite and it works great (based on the idea in https://github.com/DatabaseCleaner/database_cleaner/pull/521#issuecomment-380757595)
# Simplified version
DatabaseCleaner::Safeguard::CHECKS << Class.new do
def run
# Prevent running tests against protected environments
# - This is the same mechanism that the `rake` tasks use so you can't
# run destructive operations like `db:reset` against production
::ActiveRecord::Tasks::DatabaseTasks.check_protected_environments!
end
end
I think it could be very useful to modularize the concept of a Safeguard so that various ORM modules could provide their own (the above case could something like DatabaseCleaner::ActiveRecord::Safeguard::ProtectedEnvironment).
I would be more than willing to work on this, but wanted to gauge interest and possibly talk about some design decisions before going ahead with it.
- 主要言語
- Ruby
- スター
- 3k
- フォーク
- 485
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
DatabaseCleaner/database_cleaner のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 67/100
-
Cleaning of dev DBオープン
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
Cannot truncate a table referenced in a foreign key constraint (ActiveRecord::StatementInvalid)オープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
DatabaseCleaner/database_cleaner#717 · コメント 5 件 · リアクション 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
DatabaseCleaner/database_cleaner#716 · コメント 2 件 ·
DatabaseCleaner/database_cleaner の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
betagouv/conseillers-entreprises#4720 ·
メンテナーはふだん 3 日以内に返信
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
zerocracy/judges-action#2692 · コメント 1 件 ·
メンテナーはふだん 6 日以内に返信
-
agent:triaged bug bughunt pm:bundler priority:p1
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
SocketDev/socket-patch#896 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
eurosky-social/eu-haul#32 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
e0ipso/self-review#171 ·
メンテナーはふだん 1 日以内に返信