[#2814] Added search re-index provision script for development environments. - #2815
Conversation
WalkthroughA new provisioning script reindexes Drupal Search API content in development environments, supports ChangesDrupal search indexing provisioning
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Provisioning
participant SearchIndexScript
participant Drush
participant DrupalSearchAPI
Provisioning->>SearchIndexScript: Run provisioning script
SearchIndexScript->>Drush: Read Drupal environment
Drush-->>SearchIndexScript: Return environment
SearchIndexScript->>Drush: Reset tracker and index content
Drush->>DrupalSearchAPI: Execute Search API operations
DrupalSearchAPI-->>Drush: Complete indexing
Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.vortex/tooling/tests/unit/provision-search-index.bats:
- Around line 7-9: Update the suite setup in provision-search-index.bats to
unset DRUPAL_SEARCH_INDEX_SKIP before tests run, ensuring default and
non-development cases are not affected by the parent environment. Keep the
explicit DRUPAL_SEARCH_INDEX_SKIP export in the opt-out test unchanged.
In `@scripts/provision-30-search-index.sh`:
- Around line 40-50: Update the environment check surrounding the search
indexing commands to use an exact match for only local, ci, dev, and stage,
preferably with a case statement. Keep indexing skipped for all other values,
including lookalikes such as staging and development, and add coverage for these
supported and excluded environment names.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: c85fc235-c65b-4d6e-a53f-0e5e33526b95
⛔ Files ignored due to path filters (4)
.vortex/installer/tests/Fixtures/handler_process/_baseline/scripts/provision-30-search-index.shis excluded by!.vortex/installer/tests/Fixtures/**.vortex/installer/tests/Fixtures/handler_process/custom_modules_search_without_solr/scripts/-provision-30-search-index.shis excluded by!.vortex/installer/tests/Fixtures/**.vortex/installer/tests/Fixtures/handler_process/services_no_solr/scripts/-provision-30-search-index.shis excluded by!.vortex/installer/tests/Fixtures/**.vortex/installer/tests/Fixtures/handler_process/services_none/scripts/-provision-30-search-index.shis excluded by!.vortex/installer/tests/Fixtures/**
📒 Files selected for processing (7)
.vortex/docs/content/development/variables.mdx.vortex/docs/content/drupal/provision.mdx.vortex/installer/src/Prompts/Handlers/Services.php.vortex/installer/tests/Functional/Handlers/ServicesHandlerProcessTest.php.vortex/tests/phpunit/Traits/SutTrait.php.vortex/tooling/tests/unit/provision-search-index.batsscripts/provision-30-search-index.sh
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.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2815 +/- ##
==========================================
- Coverage 86.71% 86.34% -0.38%
==========================================
Files 97 91 -6
Lines 4758 4620 -138
Branches 47 3 -44
==========================================
- Hits 4126 3989 -137
+ Misses 632 631 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
📖 Documentation preview for this pull request has been deployed to Netlify: https://6a5eb93b83a656602fff29b3--vortex-docs.netlify.app This preview is rebuilt on every commit and is not the production documentation site. |
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.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.vortex/tooling/tests/unit/provision-search-index.bats (1)
9-49: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd regression cases for all supported development environments.
This test only exercises
local; add equivalent coverage forci,dev, andstageso regressions in the environment allow-list cannot go unnoticed.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.vortex/tooling/tests/unit/provision-search-index.bats around lines 9 - 49, Extend the provision search-index test coverage to include equivalent default-flow cases for the supported development environments ci, dev, and stage, in addition to local. Update each case’s mocked environment output and expected “Environment” line while preserving the existing indexing, skip, and success assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In @.vortex/tooling/tests/unit/provision-search-index.bats:
- Around line 9-49: Extend the provision search-index test coverage to include
equivalent default-flow cases for the supported development environments ci,
dev, and stage, in addition to local. Update each case’s mocked environment
output and expected “Environment” line while preserving the existing indexing,
skip, and success assertions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: a1d1d607-f6ae-4279-bdab-aae228337c07
📒 Files selected for processing (2)
.vortex/tooling/tests/unit/provision-search-index.bats.vortex/tooling/tests/unit/provision.bats
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.
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 |
#2815) Forward-ported from main 1c3f618. 2.x drives provisioning through 'drupal/deploy_steps', so the behaviour of main's 'scripts/provision-30-search-index.sh' is re-authored as a 'RebuildSearchIndex' deploy step in 'ys_search': it resets the Search API tracker and re-indexes on the 'local', 'ci', 'dev' and 'stage' environments, gated by the 'DRUPAL_SEARCH_INDEX_SKIP' opt-out. Added 'DRUPAL_SEARCH_INDEX_SKIP' to '.env' under the 'SERVICE_SEARCH' fence, regenerated the docs variables table, and documented the step in 'provision.mdx'.
Closes #2814
Summary
Development environments (
local,ci,dev,stage) import a database snapshot whose Search API index tracker state does not match their own search backend, so search results stay empty or stale until someone manually resets the tracker and reindexes. This addsscripts/provision-30-search-index.sh, a new custom provision subscript that runs at the end of provisioning - afterprovision-10-example.shinstalls modules andprovision-20-migration.shmigrates content - to reset the Search API index tracker and reindex content automatically, but only when the Drupalenvironmentsetting islocal,ci,dev, orstage. Other environments are skipped to avoid disturbing an existing index (e.g. production). ADRUPAL_SEARCH_INDEX_SKIP=1variable opts out entirely. The installer removes the script when the Solr service is not selected, since thesearch_apimodules are only installed under theSERVICE_SOLRfence.Changes
Script
scripts/provision-30-search-index.sh: reads the Drupalenvironmentsetting viadrush php:eval, then runsdrush search-api:reset-trackeranddrush search-api:indexwhen the environment islocal,ci,dev, orstage. Skips with a note in any other environment, or entirely whenDRUPAL_SEARCH_INDEX_SKIP=1is set.Installer
.vortex/installer/src/Prompts/Handlers/Services.php: removesscripts/provision-30-search-index.shwhen the Solr service is not selected, alongside the other Solr-only file removals (.docker/solr.dockerfile,settings.solr.php,search.feature).Tests
.vortex/tooling/tests/unit/provision-search-index.batswith 3 BATS tests: default flow in a development environment (reset tracker + index), skip viaDRUPAL_SEARCH_INDEX_SKIP=1, and skip in a non-development environment. The default-flow and non-development tests unsetDRUPAL_SEARCH_INDEX_SKIPfirst so a value inherited from the parent environment cannot short-circuit them..vortex/tooling/tests/unit/provision.batsfrom the new subscript: each scenario already removesprovision-20-migration.shin its setup and now removesprovision-30-search-index.shthe same way, keeping the fully-mocked provision flow unaffected while the subscript keeps its own dedicated test file.ServicesHandlerProcessTest.php: the Solr-selected scenario now assertsscripts/provision-30-search-index.shexists; the Solr-not-selected and no-services scenarios now assert it does not exist.scripts/provision-30-search-index.shtoSutTrait::assertVortexFilesPresent()so full-build tests assert the script ships by default.Docs
.vortex/docs/content/drupal/provision.mdxdocumenting the script, the environments it targets, and theDRUPAL_SEARCH_INDEX_SKIPopt-out..vortex/docs/content/development/variables.mdxwith the newDRUPAL_SEARCH_INDEX_SKIPvariable row.Fixtures
_baselinenow includesscripts/provision-30-search-index.sh;services_no_solr,services_none, andcustom_modules_search_without_solrrecord its removal.Screenshots
N/A - non-visual change (provisioning shell script, installer logic, tests and docs only).
Before / After
Summary by CodeRabbit
DRUPAL_SEARCH_INDEX_SKIP=1.DRUPAL_SEARCH_INDEX_SKIPenvironment variable.