-
-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: added suppress_required_validations option #152
base: master
Are you sure you want to change the base?
feature: added suppress_required_validations option #152
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Left some comments/suggestions.
@@ -2,6 +2,15 @@ | |||
|
|||
## master | |||
|
|||
## 2.6.5 (2024-05-30) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, do not update version numbers/dates; it's only done on release
- [Test helpers](#test-helpers) | ||
- [OptionParser integration](#optionparser-integration) | ||
- [RBS support](#rbs-support) | ||
- [Anyway Config](#anyway-config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is irrelevant and not needed; please, revert.
@@ -79,5 +79,7 @@ def app_root | |||
self.use_local_files ||= ::Rails.env.development? | |||
# Don't try read defaults when no key defined | |||
self.default_environmental_key = nil | |||
|
|||
self.suppress_required_validations = ENV["SECRET_KEY_BASE_DUMMY"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway-specific env var must have precedence:
self.suppress_required_validations = ENV["SECRET_KEY_BASE_DUMMY"] | |
self.suppress_required_validations = !!ENV["SECRET_KEY_BASE_DUMMY"] unless ENV.key?("ANYWAY_SUPPRESS_VALIDATIONS") |
@@ -107,5 +110,8 @@ def matching_env?(env) | |||
|
|||
# Tracing is enabled by default | |||
self.tracing_enabled = true | |||
|
|||
# By default, use ANYWAY_SUPPRESS_VALIDATIONS | |||
self.suppress_required_validations = ENV["ANYWAY_SUPPRESS_VALIDATIONS"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's be more specific here:
self.suppress_required_validations = ENV["ANYWAY_SUPPRESS_VALIDATIONS"] | |
self.suppress_required_validations = %w[1 t true y yes].include?(ENV["ANYWAY_SUPPRESS_VALIDATIONS"]) |
@@ -7,6 +7,7 @@ module Anyway | |||
def self.future: -> Future | |||
def self.current_environment: -> String? | |||
def self.default_environmental_key: -> String? | |||
def self.suppress_required_validations: -> bool? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's either true or false
def self.suppress_required_validations: -> bool? | |
def self.suppress_required_validations: -> bool |
|
||
context "with env" do | ||
it "not to raise ValidationError" do | ||
with_env("ANYWAY_SUPPRESS_VALIDATIONS" => "1") do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add another test case with the falsey value (e.g., "ANYWAY_SUPPRESS_VALIDATIONS=0").
What is the purpose of this pull request?
Closes #151
What changes did you make? (overview)
Added
suppress_required_validations
configuration for skipping validation in CI:Support for the Rails built-in environment variable
SECRET_KEY_BASE_DUMMY
. If this variable is set, all validations for required attributes are skipped. This is particularly useful for executingbundle exec rails assets:precompile
in CI/CD pipelines.Introduced a global setting
Anyway::Settings.suppress_required_validations = true
to disable validations. This can be toggled via the environment variableANYWAY_SUPPRESS_VALIDATIONS
.For Rails applications,
suppress_required_validations
is automatically set totrue
ifSECRET_KEY_BASE_DUMMY
is defined.Is there anything you'd like reviewers to focus on?
Checklist