Skip to content

Commit ab83a01

Browse files
ci(multisite): Use subfolder for multisite
1 parent 0cbac64 commit ab83a01

File tree

4 files changed

+24
-21
lines changed

4 files changed

+24
-21
lines changed

.github/workflows/end-to-end-multisite.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
matrix:
2323
wp-version: [ "4.9", "6.2" ]
2424
php-version: [ "7.2" ]
25-
subdomain: ["site1", "site2"]
25+
subsite: ["site1", "site2"]
2626

2727
name: End-to-end test suite
2828
runs-on: ubuntu-latest
@@ -52,7 +52,7 @@ jobs:
5252
echo "WP_VERSION_CODE=$(echo wp${{ matrix.wp-version }} | sed 's/\.//g' )" >> $GITHUB_ENV
5353
5454
- name: Create empty WordPress DDEV project (with Apache)
55-
run: ddev config --project-type=wordpress --project-name=${{ env.WP_VERSION_CODE }} --php-version=${{ matrix.php-version }} --webserver-type=apache-fpm --additional-hostnames=site1.${{ env.WP_VERSION_CODE }},site2.${{ env.WP_VERSION_CODE }}
55+
run: ddev config --project-type=wordpress --project-name=${{ env.WP_VERSION_CODE }} --php-version=${{ matrix.php-version }} --webserver-type=apache-fpm
5656

5757
- name: Add Redis, Memcached, Crowdsec and Playwright
5858
run: |
@@ -69,17 +69,17 @@ jobs:
6969
- name: Download WordPress
7070
run: ddev wp core download --version=${{ matrix.wp-version }}
7171

72-
- name: Setup WordPress ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }}
72+
- name: Setup Multisite WordPress ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }}
7373
run: |
74-
ddev wp core multisite-install --url='https://${{ env.WP_VERSION_CODE }}.ddev.site' --title='WordPress' --admin_user='admin' --admin_password='admin123' --admin_email='admin@admin.com' --subdomains=true
74+
ddev wp core multisite-install --url='https://${{ env.WP_VERSION_CODE }}.ddev.site' --title='WordPress' --admin_user='admin' --admin_password='admin123' --admin_email='admin@admin.com'
7575
7676
- name: Copy multisite .htaccess
77-
run: cp .ddev/okaeli-add-on/wordpress/custom_files/.htaccess-multisite-subdomain .htaccess
77+
run: cp .ddev/okaeli-add-on/wordpress/custom_files/.htaccess-multisite-subfolder .htaccess
7878

7979
- name: Prepare multisite config
8080
run: |
8181
sed -i -e 's/#ddev-generated//g' wp-config-ddev.php
82-
sed -i -e 's/REPLACE_SUBDOMAIN_INSTALL/true/g' .ddev/okaeli-add-on/wordpress/custom_files/multisite-config.php
82+
sed -i -e 's/REPLACE_SUBDOMAIN_INSTALL/false/g' .ddev/okaeli-add-on/wordpress/custom_files/multisite-config.php
8383
sed -i -e 's/REPLACE_PROJECT_URI/${{ env.WP_VERSION_CODE }}.ddev.site/g' .ddev/okaeli-add-on/wordpress/custom_files/multisite-config.php
8484
sed -i '/DB_HOST/ r .ddev/okaeli-add-on/wordpress/custom_files/multisite-config.php' wp-config-ddev.php
8585
sed -i -e 's/#ddev-generated//g' wp-config-ddev.php
@@ -124,7 +124,7 @@ jobs:
124124
with:
125125
test_path: ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
126126
file_path: 1-activate-plugin.js
127-
subdomain: ${{ matrix.subdomain }}
127+
subsite: ${{ matrix.subsite }}
128128

129129
- name: Configure CrowdSec and Wordpress bouncer plugin
130130
run: |
@@ -135,21 +135,21 @@ jobs:
135135
with:
136136
test_path: ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
137137
file_path: 2-live-mode-remediations.js
138-
subdomain: ${{ matrix.subdomain }}
138+
subsite: ${{ matrix.subsite }}
139139

140140
- name: Run more Live mode remediation tests
141141
uses: ./wp-content/plugins/crowdsec/.github/workflows/end-to-end/run-single-test
142142
with:
143143
test_path: ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
144144
file_path: 3-live-mode-more.js
145-
subdomain: ${{ matrix.subdomain }}
145+
subsite: ${{ matrix.subsite }}
146146

147147
- name: Run Live mode cache tests
148148
uses: ./wp-content/plugins/crowdsec/.github/workflows/end-to-end/run-single-test
149149
with:
150150
test_path: ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
151151
file_path: 4-live-mode-cache.js
152-
subdomain: ${{ matrix.subdomain }}
152+
subsite: ${{ matrix.subsite }}
153153

154154
- name: Prepare cron usage
155155
run: |
@@ -160,28 +160,28 @@ jobs:
160160
with:
161161
test_path: ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
162162
file_path: 5-stream-mode.js
163-
subdomain: ${{ matrix.subdomain }}
163+
subsite: ${{ matrix.subsite }}
164164

165165
- name: Run Redis tests
166166
uses: ./wp-content/plugins/crowdsec/.github/workflows/end-to-end/run-single-test
167167
with:
168168
test_path: ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
169169
file_path: 6-redis.js
170-
subdomain: ${{ matrix.subdomain }}
170+
subsite: ${{ matrix.subsite }}
171171

172172
- name: Run Memcached tests
173173
uses: ./wp-content/plugins/crowdsec/.github/workflows/end-to-end/run-single-test
174174
with:
175175
test_path: ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
176176
file_path: 7-memcached.js
177-
subdomain: ${{ matrix.subdomain }}
177+
subsite: ${{ matrix.subsite }}
178178

179179
- name: Run Geolocation tests
180180
uses: ./wp-content/plugins/crowdsec/.github/workflows/end-to-end/run-single-test
181181
with:
182182
test_path: ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
183183
file_path: 8-geolocation.js
184-
subdomain: ${{ matrix.subdomain }}
184+
subsite: ${{ matrix.subsite }}
185185

186186

187187
- name: tmate debugging session

.github/workflows/end-to-end/run-single-test/action.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ inputs:
1010
required: true
1111
description: "Path to the js test file"
1212

13-
subdomain:
13+
subsite:
1414
required: false
15-
description: "Subdomain for Multisite frontend test"
15+
description: "Subsite for Multisite frontend test"
1616

1717
runs:
1818
using: "composite"
@@ -21,7 +21,7 @@ runs:
2121
shell: bash
2222
run: |
2323
cd ${{ inputs.test_path }}/__scripts__
24-
./run-tests.sh ci "./__tests__/${{ inputs.file_path }}" "${{ inputs.subdomain }}"
24+
./run-tests.sh ci "./__tests__/${{ inputs.file_path }}" "${{ inputs.subsite }}"
2525
cd ${{ inputs.test_path }}
2626
PENDING_TESTS=$(grep -oP '"numPendingTests":\K(.*),"numRuntimeErrorTestSuites"' .test-results.json | sed 's/,"numRuntimeErrorTestSuites"//g')
2727
if [[ $PENDING_TESTS == "0" ]]

tests/e2e-ddev/__scripts__/run-tests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fi
1515

1616
TYPE=${1:-host}
1717
FILE_LIST=${2:-""}
18-
SUBDOMAIN=${3:-""}
18+
SUBSITE=${3:-""}
1919

2020

2121
case $TYPE in
@@ -51,7 +51,7 @@ HOSTNAME=$(ddev exec printenv DDEV_HOSTNAME | sed 's/\r//g')
5151
WORDPRESS_VERSION=$(ddev exec printenv DDEV_PROJECT | sed 's/\r//g' | sed 's/wp//g')
5252
WORDPRESS_ADMIN_URL=$(ddev exec printenv DDEV_PRIMARY_URL | sed 's/\r//g')
5353
if [ $CHECKMULTISITE == "true" ]; then
54-
WORDPRESS_FRONT_URL="https://${SUBDOMAIN}.${SITE_NAME}.ddev.site"
54+
WORDPRESS_FRONT_URL="https://${SITE_NAME}.ddev.site/${SUBSITE}"
5555
else
5656
WORDPRESS_FRONT_URL=$WORDPRESS_ADMIN_URL
5757
fi

tests/e2e-ddev/__tests__/1-activate-plugin.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable no-undef */
2-
const { WP59, WP58, WP57, WP56, WP55 } = require("../utils/constants");
2+
const { WP59, WP58, WP57, WP56, WP55, MULTISITE } = require("../utils/constants");
33

44
const {
55
goToAdmin,
@@ -20,7 +20,10 @@ describe(`Setup CrowdSec plugin`, () => {
2020
await goToAdmin("/plugins.php");
2121
if (WP55 || WP56 || WP57 || WP58 || WP59) {
2222
await page.click("#activate-crowdsec");
23-
} else {
23+
} else if(MULTISITE == "true"){
24+
await page.click('[aria-label="Network Activate CrowdSec"]');
25+
}
26+
else {
2427
await page.click('[aria-label="Activate CrowdSec"]');
2528
}
2629

0 commit comments

Comments
 (0)