Skip to content

[#2814] Added search re-index provision script for development environments. - #2815

Merged
AlexSkrypnyk merged 9 commits into
mainfrom
feature/2814-search-reindex
Jul 21, 2026
Merged

[#2814] Added search re-index provision script for development environments.#2815
AlexSkrypnyk merged 9 commits into
mainfrom
feature/2814-search-reindex

Conversation

@AlexSkrypnyk

@AlexSkrypnyk AlexSkrypnyk commented Jul 20, 2026

Copy link
Copy Markdown
Member

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 adds scripts/provision-30-search-index.sh, a new custom provision subscript that runs at the end of provisioning - after provision-10-example.sh installs modules and provision-20-migration.sh migrates content - to reset the Search API index tracker and reindex content automatically, but only when the Drupal environment setting is local, ci, dev, or stage. Other environments are skipped to avoid disturbing an existing index (e.g. production). A DRUPAL_SEARCH_INDEX_SKIP=1 variable opts out entirely. The installer removes the script when the Solr service is not selected, since the search_api modules are only installed under the SERVICE_SOLR fence.

Changes

Script

  • Added scripts/provision-30-search-index.sh: reads the Drupal environment setting via drush php:eval, then runs drush search-api:reset-tracker and drush search-api:index when the environment is local, ci, dev, or stage. Skips with a note in any other environment, or entirely when DRUPAL_SEARCH_INDEX_SKIP=1 is set.

Installer

  • .vortex/installer/src/Prompts/Handlers/Services.php: removes scripts/provision-30-search-index.sh when the Solr service is not selected, alongside the other Solr-only file removals (.docker/solr.dockerfile, settings.solr.php, search.feature).

Tests

  • Added .vortex/tooling/tests/unit/provision-search-index.bats with 3 BATS tests: default flow in a development environment (reset tracker + index), skip via DRUPAL_SEARCH_INDEX_SKIP=1, and skip in a non-development environment. The default-flow and non-development tests unset DRUPAL_SEARCH_INDEX_SKIP first so a value inherited from the parent environment cannot short-circuit them.
  • Isolated the full-provision scenarios in .vortex/tooling/tests/unit/provision.bats from the new subscript: each scenario already removes provision-20-migration.sh in its setup and now removes provision-30-search-index.sh the same way, keeping the fully-mocked provision flow unaffected while the subscript keeps its own dedicated test file.
  • Extended ServicesHandlerProcessTest.php: the Solr-selected scenario now asserts scripts/provision-30-search-index.sh exists; the Solr-not-selected and no-services scenarios now assert it does not exist.
  • Added scripts/provision-30-search-index.sh to SutTrait::assertVortexFilesPresent() so full-build tests assert the script ships by default.

Docs

  • Added a "Search indexing" subsection to .vortex/docs/content/drupal/provision.mdx documenting the script, the environments it targets, and the DRUPAL_SEARCH_INDEX_SKIP opt-out.
  • Regenerated .vortex/docs/content/development/variables.mdx with the new DRUPAL_SEARCH_INDEX_SKIP variable row.

Fixtures

  • Regenerated installer test fixtures: _baseline now includes scripts/provision-30-search-index.sh; services_no_solr, services_none, and custom_modules_search_without_solr record its removal.

Screenshots

N/A - non-visual change (provisioning shell script, installer logic, tests and docs only).

Before / After

BEFORE: search index left stale/empty after DB import
┌─────────────────────────────────────────────────────┐
│ ahoy provision                                       │
└──────────────────────────┬──────────────────────────┘
                            ▼
                  sanitize (non-prod only)
                            │
                            ▼
              scripts/provision-10-example.sh
                     (install modules)
                            │
                            ▼
             scripts/provision-20-migration.sh
                     (migrate content)
                            │
                            ▼
                          done
                            │
                            ▼
        ✗ Search API tracker still reflects the
          SOURCE environment; local/CI backend is
          empty or mismatched -> search stays empty
          until someone manually reindexes

AFTER: search index rebuilt automatically in dev environments
┌─────────────────────────────────────────────────────┐
│ ahoy provision                                       │
└──────────────────────────┬──────────────────────────┘
                            ▼
                  sanitize (non-prod only)
                            │
                            ▼
              scripts/provision-10-example.sh
                     (install modules)
                            │
                            ▼
             scripts/provision-20-migration.sh
                     (migrate content)
                            │
                            ▼
            scripts/provision-30-search-index.sh
                            │
              DRUPAL_SEARCH_INDEX_SKIP=1? ──yes──> skipped entirely
                            │ no
                            ▼
        environment in {local, ci, dev, stage}? ──no──> note + skip
                            │ yes                        (preserve index,
                            ▼                             e.g. production)
              search-api:reset-tracker
              search-api:index
                            │
                            ▼
        ✓ search results match freshly imported
          content immediately after provisioning

Installer: Solr service not selected
                            │
                            ▼
        scripts/provision-30-search-index.sh removed
        (search_api modules only installed under SERVICE_SOLR)

Summary by CodeRabbit

  • New Features
    • Provisioning now resets and re-indexes Drupal Search API content automatically in local, CI, development, and staging environments.
    • Search indexing can be skipped by setting DRUPAL_SEARCH_INDEX_SKIP=1.
    • Other environments keep existing indexing behavior.
  • Bug Fixes
    • Search indexing is no longer included when Solr isn’t enabled.
  • Documentation
    • Added guidance for provisioning-time search indexing and the new DRUPAL_SEARCH_INDEX_SKIP environment variable.

@github-project-automation github-project-automation Bot moved this to BACKLOG in Vortex 1.x Jul 20, 2026
@AlexSkrypnyk AlexSkrypnyk added this to the 1.41.0 milestone Jul 20, 2026
@AlexSkrypnyk AlexSkrypnyk added the A3 Board worker 3 label Jul 20, 2026
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

A new provisioning script reindexes Drupal Search API content in development environments, supports DRUPAL_SEARCH_INDEX_SKIP=1, and skips indexing elsewhere. Installer behavior removes the script without Solr, with tests and documentation updated accordingly.

Changes

Drupal search indexing provisioning

Layer / File(s) Summary
Search indexing script and tests
scripts/provision-30-search-index.sh, .vortex/tooling/tests/unit/provision-search-index.bats, .vortex/tooling/tests/unit/provision.bats
The script reads the Drupal environment, honors the skip flag, and resets and runs Search API indexing for local, ci, dev, and stage; tests cover default, opt-out, non-development, and isolated provisioning flows.
Installer service selection wiring
.vortex/installer/src/Prompts/Handlers/Services.php, .vortex/installer/tests/Functional/Handlers/ServicesHandlerProcessTest.php, .vortex/tests/phpunit/Traits/SutTrait.php
The installer removes the indexing script when Solr is unavailable, and service-selection tests verify its presence or absence.
Provisioning documentation and variable reference
.vortex/docs/content/drupal/provision.mdx, .vortex/docs/content/development/variables.mdx
Documentation describes indexing behavior, supported environments, and the DRUPAL_SEARCH_INDEX_SKIP variable.

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
Loading

Possibly related PRs

  • drevops/vortex#2539: Both changes update SutTrait::assertVortexFilesPresent() for provision script file expectations.

Suggested labels: Needs review

Poem

I’m a rabbit with scripts in my den,
Reindexing content again and again.
In dev fields I hop,
In prod fields I stop,
With one flag, indexing can end.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The script, opt-out flag, environment gating, docs, and installer/test updates match the issue requirements.
Out of Scope Changes check ✅ Passed Changes are limited to the search re-index script, related docs, tests, and installer handling, with no unrelated functionality added.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding a provisioning script to reindex search content in development environments.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/2814-search-reindex

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7742981 and af68430.

⛔ Files ignored due to path filters (4)
  • .vortex/installer/tests/Fixtures/handler_process/_baseline/scripts/provision-30-search-index.sh is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/custom_modules_search_without_solr/scripts/-provision-30-search-index.sh is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/services_no_solr/scripts/-provision-30-search-index.sh is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/services_none/scripts/-provision-30-search-index.sh is 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.bats
  • scripts/provision-30-search-index.sh

Comment thread .vortex/tooling/tests/unit/provision-search-index.bats
Comment thread scripts/provision-30-search-index.sh
@github-actions

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

2 similar comments
@AlexSkrypnyk

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.34%. Comparing base (7742981) to head (38ed060).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown

📖 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.

@github-actions

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

2 similar comments
@AlexSkrypnyk

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Add regression cases for all supported development environments.

This test only exercises local; add equivalent coverage for ci, dev, and stage so 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

📥 Commits

Reviewing files that changed from the base of the PR and between af68430 and ac5704c.

📒 Files selected for processing (2)
  • .vortex/tooling/tests/unit/provision-search-index.bats
  • .vortex/tooling/tests/unit/provision.bats

@github-actions

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown

Code coverage (threshold: 90%)

  Classes: 100.00% (1/1)
  Methods: 100.00% (2/2)
  Lines:   98.55% (204/207)
Per-class coverage
Drupal\ys_demo\Plugin\Block\CounterBlock
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 10/ 10)

@AlexSkrypnyk

This comment has been minimized.

2 similar comments
@AlexSkrypnyk

This comment has been minimized.

@AlexSkrypnyk

Copy link
Copy Markdown
Member Author

Code coverage (threshold: 90%)

  Classes: 100.00% (1/1)
  Methods: 100.00% (2/2)
  Lines:   98.55% (204/207)
Per-class coverage
Drupal\ys_demo\Plugin\Block\CounterBlock
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 10/ 10)

@AlexSkrypnyk AlexSkrypnyk added the Needs review Pull request needs a review from assigned developers label Jul 21, 2026
@AlexSkrypnyk
AlexSkrypnyk merged commit 1c3f618 into main Jul 21, 2026
34 checks passed
@AlexSkrypnyk
AlexSkrypnyk deleted the feature/2814-search-reindex branch July 21, 2026 03:37
@github-project-automation github-project-automation Bot moved this from BACKLOG to Release queue in Vortex 1.x Jul 21, 2026
AlexSkrypnyk added a commit that referenced this pull request Jul 22, 2026
#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'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A3 Board worker 3 Needs review Pull request needs a review from assigned developers

Projects

Status: Release queue

Development

Successfully merging this pull request may close these issues.

Add search re-index script for the dev envs

1 participant