Skip to content

Added 'do_generated_content' module with provision script for non-production content generation.#154

Merged
AlexSkrypnyk merged 2 commits intodevelopfrom
feature/generated-content
Mar 17, 2026
Merged

Added 'do_generated_content' module with provision script for non-production content generation.#154
AlexSkrypnyk merged 2 commits intodevelopfrom
feature/generated-content

Conversation

@AlexSkrypnyk
Copy link
Copy Markdown
Member

@AlexSkrypnyk AlexSkrypnyk commented Mar 17, 2026

Summary

Added the do_generated_content custom Drupal module to provide programmatic content generation for non-production environments (local, dev, CI). The module uses the drupal/generated_content package (added as a Composer dependency) and defines plugins that generate files, image media, taxonomy terms, and CivicTheme page nodes with realistic paragraph components. A provision script is included to enable the module automatically during environment provisioning when a fresh database override is detected.

Changes

New custom module: web/modules/custom/do_generated_content/

  • do_generated_content.info.yml — Module definition declaring dependency on generated_content and do_base.
  • src/Plugin/GeneratedContent/FileFile.php — Generates 20 random JPG/PNG image files at varying dimensions.
  • src/Plugin/GeneratedContent/TaxonomyTermCivicthemeTopics.php — Creates 10 predefined topic taxonomy terms (Drupal, DevOps, CI/CD, etc.) with weight 11.
  • src/Plugin/GeneratedContent/MediaCivicthemeImage.php — Creates 10 civictheme_image media entities using randomly selected generated files, with weight 1.
  • src/Plugin/GeneratedContent/NodeCivicthemePage.php — Creates 10 civictheme_page nodes (weight 30) with paragraph components (content, accordion, promo, callout) and random topic/thumbnail assignments.

New provision script: scripts/custom/provision-20-generated-content.sh

Checks the current environment (dev/ci/local) and, when a fresh DB override is active and GENERATED_CONTENT_SKIP is not set, enables the do_generated_content module with GENERATED_CONTENT_CREATE=1 to trigger content generation.

Composer dependency

  • composer.json / composer.lock — Added drupal/generated_content: ^2 (version 2.0.0).

Summary by CodeRabbit

  • New Features

    • Adds content generation to populate sample files, media assets, civictheme pages, and taxonomy terms for non-production environments.
  • Chores

    • Adds an external dependency to support generated content.
    • Adds an automated provisioning script to control when and how generated content is applied.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 17, 2026

📝 Walkthrough

Walkthrough

Adds a new Drupal module do_generated_content with GeneratedContent plugins (files, media, nodes, taxonomy terms), a provisioning script that conditionally enables the module in non-production environments, and a composer dependency on drupal/generated_content (^2).

Changes

Cohort / File(s) Summary
Composer & Module Descriptor
composer.json, web/modules/custom/do_generated_content/do_generated_content.info.yml
Adds drupal/generated_content: ^2 to project requirements and declares the do_generated_content module with its metadata and dependency.
Provisioning Script
scripts/custom/provision-20-generated-content.sh
New Bash script that detects environment, respects VORTEX_PROVISION_OVERRIDE_DB and GENERATED_CONTENT_SKIP, and conditionally enables the do_generated_content module via Drush (with increased memory).
GeneratedContent Plugins — Files & Media
web/modules/custom/do_generated_content/src/Plugin/GeneratedContent/FileFile.php, .../MediaCivicthemeImage.php
Adds plugins to generate image file entities (20 files with randomized formats/dimensions) and media entities (10 civictheme_image media using generated files, setting image field and alt text).
GeneratedContent Plugins — Nodes & Taxonomy
web/modules/custom/do_generated_content/src/Plugin/GeneratedContent/NodeCivicthemePage.php, .../TaxonomyTermCivicthemeTopics.php
Adds plugins to create 10 civictheme_page nodes with composed paragraph components (content, accordion, promo, callout patterns) and to create civictheme_topics taxonomy terms (predefined terms).

Sequence Diagram(s)

sequenceDiagram
  participant Script as Provision Script
  participant Drush as Drush
  participant Drupal as Drupal App
  participant DB as Database
  Script->>Drush: check environment via php-eval
  Script->>Script: evaluate VORTEX_PROVISION_OVERRIDE_DB / GENERATED_CONTENT_SKIP
  alt enable flow
    Script->>Drush: drush en do_generated_content
    Drush->>Drupal: enable module
    Drupal->>DB: record schema/module enabled
    Drupal->>GeneratedPlugins: invoke generation (when run)
    GeneratedPlugins->>Drupal: create Files, Media, Nodes, Terms
    Drupal->>DB: persist entities
  else skip/production
    Script->>Script: log skip
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

PR: AUTOMERGE

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 76.92% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a custom Drupal module 'do_generated_content' with a provision script for non-production content generation, which aligns with all files added in the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/generated-content
📝 Coding Plan
  • Generate coding plan for human review comments

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

@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown

Code coverage (GitHub Actions)

Code Coverage Report:
  2026-03-17 13:49:26

 Summary:
  Classes: 50.00% (5/10)
  Methods: 73.91% (17/23)
  Lines:   92.81% (310/334)

Drupal\do_feed\FeedUrlBuilder
  Methods: 100.00% ( 4/ 4)   Lines: 100.00% ( 18/ 18)
Drupal\do_feed\Form\FeedSettingsForm
  Methods: 100.00% ( 4/ 4)   Lines: 100.00% ( 15/ 15)
Drupal\do_feed\Hook\EntityDeleteHook
  Methods:  50.00% ( 1/ 2)   Lines:  92.31% ( 12/ 13)
Drupal\do_feed\Hook\EntityPresaveHook
  Methods: 100.00% ( 4/ 4)   Lines: 100.00% ( 54/ 54)
Drupal\do_feed\Hook\PreprocessParagraphHook
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 14/ 14)
Drupal\do_feed\Hook\PreprocessViewsViewRowRssHook
  Methods: 100.00% ( 1/ 1)   Lines: 100.00% (  3/  3)
Drupal\do_feed\Hook\ViewsPreViewHook
  Methods:  50.00% ( 1/ 2)   Lines:  96.43% ( 27/ 28)

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@web/modules/custom/do_generated_content/do_generated_content.info.yml`:
- Around line 6-7: The module metadata is missing the do_base dependency which
can break install/enable order; update the dependencies block in
do_generated_content.info.yml (the dependencies: list for the
do_generated_content module that currently contains
generated_content:generated_content) to include do_base (e.g., add
do_base:do_base or the appropriate do_base machine name entry) so that the
do_generated_content module declares and enforces the required base module at
install time.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3a03f1bb-bb16-441b-9e2a-1182843cb42f

📥 Commits

Reviewing files that changed from the base of the PR and between c0d2ed4 and 33a36c8.

⛔ Files ignored due to path filters (1)
  • composer.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • composer.json
  • scripts/custom/provision-20-generated-content.sh
  • web/modules/custom/do_generated_content/do_generated_content.info.yml
  • web/modules/custom/do_generated_content/src/Plugin/GeneratedContent/FileFile.php
  • web/modules/custom/do_generated_content/src/Plugin/GeneratedContent/MediaCivicthemeImage.php
  • web/modules/custom/do_generated_content/src/Plugin/GeneratedContent/NodeCivicthemePage.php
  • web/modules/custom/do_generated_content/src/Plugin/GeneratedContent/TaxonomyTermCivicthemeTopics.php

Comment on lines +6 to +7
dependencies:
- generated_content:generated_content
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add missing do_base dependency declaration.

The module metadata currently omits do_base, even though this feature set assumes base content model availability. Without explicit dependency, enable/install order can break and generators can fail at runtime.

🔧 Proposed fix
 dependencies:
   - generated_content:generated_content
+  - do_base:do_base
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
dependencies:
- generated_content:generated_content
dependencies:
- generated_content:generated_content
- do_base:do_base
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/modules/custom/do_generated_content/do_generated_content.info.yml` around
lines 6 - 7, The module metadata is missing the do_base dependency which can
break install/enable order; update the dependencies block in
do_generated_content.info.yml (the dependencies: list for the
do_generated_content module that currently contains
generated_content:generated_content) to include do_base (e.g., add
do_base:do_base or the appropriate do_base machine name entry) so that the
do_generated_content module declares and enforces the required base module at
install time.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@web/modules/custom/do_generated_content/src/Plugin/GeneratedContent/FileFile.php`:
- Around line 41-47: Ensure you null-check and validate the result of
helper::createFile before using it: after calling $file =
$this->helper::createFile($type, [...]) verify that $file is an instance of
FileInterface (mirroring the MediaCivicthemeImage pattern) and only then push to
$entities and call $this->helper::log('Created file: %s', $file->getFilename());
otherwise skip logging/adding or handle the error path accordingly so no null
pointer occurs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 827c13dd-c41d-46d0-94b8-b0d03e88a357

📥 Commits

Reviewing files that changed from the base of the PR and between 33a36c8 and 7ad4d05.

📒 Files selected for processing (4)
  • web/modules/custom/do_generated_content/src/Plugin/GeneratedContent/FileFile.php
  • web/modules/custom/do_generated_content/src/Plugin/GeneratedContent/MediaCivicthemeImage.php
  • web/modules/custom/do_generated_content/src/Plugin/GeneratedContent/NodeCivicthemePage.php
  • web/modules/custom/do_generated_content/src/Plugin/GeneratedContent/TaxonomyTermCivicthemeTopics.php

Comment on lines +41 to +47
$file = $this->helper::createFile($type, [
'width' => $width,
'height' => $height,
]);

$entities[] = $file;
$this->helper::log('Created file: %s', $file->getFilename());
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add null check before using $file.

If helper::createFile() fails or returns null, calling $file->getFilename() on line 47 will cause a null pointer exception. The MediaCivicthemeImage plugin demonstrates the defensive pattern by checking if (!$file instanceof FileInterface).

🛡️ Proposed fix to add validation
       $file = $this->helper::createFile($type, [
         'width' => $width,
         'height' => $height,
       ]);
 
+      if ($file === NULL) {
+        continue;
+      }
+
       $entities[] = $file;
       $this->helper::log('Created file: %s', $file->getFilename());
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
$file = $this->helper::createFile($type, [
'width' => $width,
'height' => $height,
]);
$entities[] = $file;
$this->helper::log('Created file: %s', $file->getFilename());
$file = $this->helper::createFile($type, [
'width' => $width,
'height' => $height,
]);
if ($file === NULL) {
continue;
}
$entities[] = $file;
$this->helper::log('Created file: %s', $file->getFilename());
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@web/modules/custom/do_generated_content/src/Plugin/GeneratedContent/FileFile.php`
around lines 41 - 47, Ensure you null-check and validate the result of
helper::createFile before using it: after calling $file =
$this->helper::createFile($type, [...]) verify that $file is an instance of
FileInterface (mirroring the MediaCivicthemeImage pattern) and only then push to
$entities and call $this->helper::log('Created file: %s', $file->getFilename());
otherwise skip logging/adding or handle the error path accordingly so no null
pointer occurs.

@AlexSkrypnyk AlexSkrypnyk merged commit 8a46f3d into develop Mar 17, 2026
8 checks passed
@AlexSkrypnyk AlexSkrypnyk deleted the feature/generated-content branch March 17, 2026 03:06
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.73%. Comparing base (c0d2ed4) to head (7ad4d05).
⚠️ Report is 2 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #154   +/-   ##
========================================
  Coverage    87.73%   87.73%           
========================================
  Files           11       11           
  Lines          163      163           
========================================
  Hits           143      143           
  Misses          20       20           

☔ View full report in Codecov by Sentry.
📢 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants