[worker] warn on unknown build environment#3952
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3952 +/- ##
==========================================
+ Coverage 59.18% 59.27% +0.10%
==========================================
Files 935 936 +1
Lines 41075 41159 +84
Branches 8648 8675 +27
==========================================
+ Hits 24306 24393 +87
+ Misses 16674 16666 -8
- Partials 95 100 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
6e5f479 to
284fedd
Compare
284fedd to
595d6ba
Compare
|
Subscribed to pull request
Generated by CodeMention Warning: The preamble and epilogue options in commentConfiguration are deprecated. Use template instead. |
| { job: omit(ctx.job, 'secrets', 'projectArchive') }, | ||
| 'Builder is ready, starting build' | ||
| ); | ||
| warnOnUnknownEnvironment(ctx); |
There was a problem hiding this comment.
started with a new build phase but thought it was overkill and moved here. Let me know if you have any different thoughts
595d6ba to
7af22e7
Compare
7af22e7 to
bf57252
Compare
|
⏩ The changelog entry check has been skipped since the "no changelog" label is present. |
|
|
||
| export function warnOnUnknownEnvironment(ctx: EnvironmentWarningContext): void { | ||
| const environment = ctx.metadata?.environment; | ||
| if (environment && !KNOWN_BUILD_ENVIRONMENTS.includes(environment)) { |
There was a problem hiding this comment.
We support custom environments, so specifying a not-known environment is not an issue per se as long as the user has environment variables in that environment?
Initially I thought we might color the environment pill yellow on workflow run page if the environment has no variables, but that would color it yellow if a user does not use EAS Environment Variables at all which is bad?
Maybe we do this ^ but only if environment is not one of the known environments? Or sth like that
There was a problem hiding this comment.
Tysm for the review! I missed the custom environments UI, and the www enum only listing dev/preview/prod made me assume they weren't a thing. Should've asked claude:rolling_on_the_floor_laughing:
Agreed that false warnings would be bad here. I think the cleaner fix is to have www set a flag (that's where the resolved vars actually live from what I see) saying the environment matched no variables, and have the worker just react to it instead of hardcoding the known-environments list. wdyt?
There was a problem hiding this comment.
I think it depends on where do we want the flag to live!
We could have it be a column / flag (property in some new JSONB column) on a Workflow Job. Then, based on the flag supplied at creation time we would later show the warning in the UI or not. This requires adding a new field.
We could have it be something calculated dynamically, like we open workflow run page, website gets the list of environments used in the workflow run, website asks www if those environments currently have variables assigned to them. Bad thing about it is that this may drift as we don't have a notion of "environment variables at a given point in time".
We could have it be, as you suggest, a flag on the job, but then we can't show the warning on non-VM jobs!
I think the first is the most correct one.
There was a problem hiding this comment.
At first I was okay with not showing it for non-VM jobs, but reasoning through, the warning I'm showing was never the perfect place imho. Further on, maybe a new warningson WorkflowJob would allow us to have those warnings issues on www and more flexibility on how to show? (Maybe in the annotations?). Will dig further but sharing in case you have a different take or any input

Why
A workflow job with an environment that doesn't exist (e.g.
staging, vsdevelopment/preview/production) gets no warning. It silently resolves to zero environment variables and fails later in a confusing, unrelated-looking way (e.g. the app config failing to read).How
Warn in the "Spin up build environment" phase when the job's environment isn't
development/preview/production.Test Plan
Ran this job against a local worker: