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
Environment
cleanups
#2353
Environment
cleanups
#2353
Conversation
… the value is effectively a compile-time constant. Also improve the use of MARK comments so Xcode renders the intended divisions nicely.
…al behavior of its value.
…ions). Significantly simplify the implementation of the path-taking version. IMPORTANT NOTE: This is an interim step of cleanup while a much more complete revamping of this API is worked on.
I have a complete rework of the
(The existing API on |
…ons for the testing environment. I forgot to mention in a previous commit that support was added for `VAPOR_ENV` too...
(Note: CI failures are being addressed.) |
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.
1 lil nit
…ary. This is necessarily a little specific to the version of SwiftPM and Xcode involved, but should at least be specific enough a check to not interfere with normal operations if the call sequence changes.
…Convertible conformance. Logger.Level is already RawRepresentable as String and that conformance can be used transparently. (And it has CaseIterable for good measure, which provides yet another way to scale this particular elevation.)
Want a new review for new changes, dismissing old
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.
LGTM overall. 2 small comments
Ping @tanner0101 |
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.
Looks great, thanks! Only style nits.
These changes are now available in 4.6.0 |
* New works-for-everything CI (vapor#2365) * New works-for-everything CI This version of the test workflow can be pasted without changes into any repo whose tests don't have additional dependencies and don't need to separately test that they're still Vapor-compatible (such as console-kit). Improvements over existing CI: - Runs on pushes to master as well as PRs - Full coverage of all available Swift runner images for Linux - Uses latest Xcode without hardcoding on macOS - Nice names for each test step - Nice name for the workflow itself * Apply suggestions from code review * `Environment` cleanups (vapor#2353) * Remove numerous unnecessary code stanzas. * Don't check `isRelease` in `Environment.==`, it will always be equal because the value is effectively a compile-time constant. Also improve the use of MARK comments so Xcode renders the intended divisions nicely. * Add warning to `Environment.isRelease` explaining the seemingly unusual behavior of its value. * Redo the documentation comments for `Environment.secret()` (both versions). Significantly simplify the implementation of the path-taking version. IMPORTANT NOTE: This is an interim step of cleanup while a much more complete revamping of this API is worked on. * Correctly sanitize the excess arguments Xcode passes to test invocations for the testing environment. I forgot to mention in a previous commit that support was added for `VAPOR_ENV` too... * Add sanitization of raw SwiftPM's invocation of the xctest runner binary. This is necessarily a little specific to the version of SwiftPM and Xcode involved, but should at least be specific enough a check to not interfere with normal operations if the call sequence changes. * There is no need to hardcode all the logger levels for `LosslessStringConvertible` conformance. `Logger.Level` is already `RawRepresentable` as `String` and that conformance can be used transparently. (And it has `CaseIterable` for good measure, which provides yet another way to scale this particular elevation.) Co-authored-by: Gwynne Raskind <gwynne@darkrainfall.org>
Clean up
Environment
's implementation.Add the ability to specify the application environment using the environment variable
VAPOR_ENV
(partial implementation of Support $PORT and $HOSTNAME #2333). If bothVAPOR_ENV
and--env
are provided, the latter always takes precedence.Environment
now recognizes and strips the spurious arguments Xcode passes to test runners when a scheme doesn't specify any arguments of its own. It will do this especially specifically for thetesting
environment, which is often explicitly specified toApplication
's initializers instead of.detect()
in unit tests. This behavior is only enabled when building in Xcode or withxcodebuild
. This negates the need to explicitly override the input arguments in the non-production presets, meaning command line arguments no longer occasionally seem to vanish into thin air in certain cases.Redo the documentation comments for both versions of
Environment.secret()
and significantly simplify the implementation. Important: This is an interim cleanup step pending a complete revamp of thesecret()
API.Note: Pains have been taken not to change the observable behavior of any public APIs and to remain otherwise behaviorally consistent. The addition of
VAPOR_ENV
counts as new public API and thus drives this being asemver-minor
change, but in all other respects it should have no visible effect.