Skip to content

Commit 8e23b90

Browse files
committed
Cypress content module checkup
1 parent b51f95f commit 8e23b90

File tree

4 files changed

+38
-2
lines changed

4 files changed

+38
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Module detection status file (created by install-drupal command)
2+
.cypress_test_content_status

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ It supports both Drupal 8+ (`.info.yml`) and Drupal 7 (`.info`) module formats.
4545

4646
**Example usage in test scripts:**
4747
```bash
48+
# After running ddev install-drupal, source the status file
49+
if [ -f .cypress_test_content_status ]; then
50+
source .cypress_test_content_status
51+
fi
52+
4853
if [ "${CYPRESS_TEST_CONTENT_AVAILABLE}" = "true" ]; then
4954
echo "Running tests with cypress_test_content module"
5055
ddev cypress-headless --spec="cypress/e2e/content-tests.cy.js"
@@ -53,6 +58,8 @@ else
5358
fi
5459
```
5560

61+
**Note**: The `install-drupal` command writes the environment variable to `.cypress_test_content_status` file for use by CI/CD pipelines and host environment scripts.
62+
5663
## Installation
5764

5865
```bash
@@ -193,6 +200,28 @@ steps:
193200
ddev dev-lint
194201
```
195202

203+
#### CI/CD Module Detection
204+
205+
After running `ddev install-drupal`, the module detection result is saved to `.cypress_test_content_status` file. Source this file in your pipeline scripts:
206+
207+
```bash
208+
# Run Drupal installation which detects the module
209+
ddev install-drupal
210+
211+
# Source the module detection result
212+
if [ -f .cypress_test_content_status ]; then
213+
source .cypress_test_content_status
214+
fi
215+
216+
# Use the environment variable
217+
if [ "${CYPRESS_TEST_CONTENT_AVAILABLE}" = "true" ]; then
218+
echo "Running Cypress tests with test content"
219+
ddev cypress-headless
220+
else
221+
echo "Skipping Cypress tests - no test content module"
222+
fi
223+
```
224+
196225
### Testing Tools 🧪
197226
- **Cypress**
198227
- `cypress-open` - Open interactive Cypress window

commands/host/install-drupal

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,14 @@ for path in "${MODULE_PATHS[@]}"; do
9696
done
9797

9898
if [ "$MODULE_FOUND" = true ]; then
99-
export CYPRESS_TEST_CONTENT_AVAILABLE=true
10099
echo "✅ cypress_test_content module found at: $MODULE_LOCATION"
100+
# Write the environment variable to a file for pipeline access
101+
echo "export CYPRESS_TEST_CONTENT_AVAILABLE=true" > /var/www/html/.cypress_test_content_status
102+
ddev drush pm:enable cypress_test_content -y
101103
else
102-
export CYPRESS_TEST_CONTENT_AVAILABLE=false
103104
echo "❌ cypress_test_content module not found in filesystem"
105+
# Write the environment variable to a file for pipeline access
106+
echo "export CYPRESS_TEST_CONTENT_AVAILABLE=false" > /var/www/html/.cypress_test_content_status
104107
fi
105108

106109
echo "👤 Creating site admin user..."

examples/bitbucket-pipelines.yml.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ pipelines:
9393
- ddev add-on get Vardot/ddev-dev-tools
9494
- ddev restart
9595
- ddev install-drupal
96+
- # Source the environment variable from the file created by install-drupal
97+
- if [ -f .cypress_test_content_status ]; then source .cypress_test_content_status; fi
9698
- if [ "${CYPRESS_TEST_CONTENT_AVAILABLE:-false}" = "false" ]; then
9799
- echo "No test content found. Skipping Cypress tests..."
98100
- exit 0

0 commit comments

Comments
 (0)