[#2849] Anchored environment name matching in provision scripts. - #2854
Conversation
WalkthroughProvisioning environment checks now require exact matches for ChangesEnvironment matching
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
2 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
📖 Documentation preview for this pull request has been deployed to Netlify: https://6a695911422562f0d270ed04--vortex-docs.netlify.app This preview is rebuilt on every commit and is not the production documentation site. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2854 +/- ##
==========================================
- Coverage 86.80% 86.42% -0.39%
==========================================
Files 98 91 -7
Lines 4789 4647 -142
Branches 47 3 -44
==========================================
- Hits 4157 4016 -141
+ Misses 632 631 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
2 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Code coverage (threshold: 90%) Per-class coverage |
This comment has been minimized.
This comment has been minimized.
2 similar comments
This comment has been minimized.
This comment has been minimized.
|
Code coverage (threshold: 90%) Per-class coverage |
Closes #2849
Summary
The provision scripts decided whether they were running in a non-production environment by piping the environment name into
grep -q -e dev -e stage -e ci -e local, an unanchored substring match rather than an equality check, so any environment name that merely contained one of those words took the development branch. An environment nameddevops,dev2,stage-uat, orlocal-testingwas silently treated as non-production, running example operations, installing development modules, and rebuilding the search index where none of that should happen. The blast radius is zero for the five environment names Vortex ships, but these scripts exist to be copied and edited by consumer projects, and$settings['environment']is freely overridable viaENVIRONMENT_TYPE.The fix adds
-x(match the whole line rather than a substring) and-F(fixed strings rather than regular expressions) to the existinggrep, so an environment name that is not one of the four listed now falls through to the production branch. The failure mode flips from fail-open to fail-closed. Both flags are POSIX-mandated rather than GNU extensions, and the behaviour was verified against BSD grep and busybox grep, the latter being what runs inside the Alpine-basedclicontainer.Anchoring the existing condition in place, rather than restructuring it into a
caseblock, keeps the guarded body untouched - so the change is one line per script and the regenerated fixtures move by one line each instead of being rewritten wholesale.Changes
scripts/provision-10-example.sh- example operations guard anchored withgrep -qxFscripts/provision-30-search-index.sh- search index rebuild guard anchored the same way.vortex/docs/content/drupal/provision-example.sh- the documented example that consumer projects copy from, anchored to match.vortex/docs/content/drupal/provision.mdx- the inline "Conditional execution" snippet anchored, and itsechomessage updated to list the environments in the same order.vortex/tooling/tests/unit/provision-example.bats- new regression test asserting an environment nameddevopstakes the skip branch, coveringprovision-10-example.shdirectly for the first time.vortex/tooling/tests/unit/provision-search-index.bats- the same regression test added for the search index guard.vortex/installer/tests/Fixtures/handler_process/_baseline/scripts/provision-*.sh- regenerated viaahoy update-snapshotsThe environment list is also normalised to
local,ci,dev,stagein all four places, matching the order the docs prose and theENVIRONMENT_*constants insettings.phpalready use.The regression tests assert behaviour rather than the shape of the conditional, so they fail if a later edit drops the
-xand reintroduces substring matching.Screenshots
N/A - the change is confined to shell scripts, documentation and test fixtures.
Before / After
Matching behaviour for representative environment names:
Summary by CodeRabbit
Bug Fixes
Tests