@@ -125,7 +125,7 @@ jobs:
125125 - name : WordPress Plugin Deploy
126126 if : github.event.inputs.deploy_to_wordpress == 'true'
127127 id : deploy
128- uses : 10up/action-wordpress-plugin-deploy@2.0.0
128+ uses : 10up/action-wordpress-plugin-deploy@2.1.1
129129 with :
130130 generate-zip : true
131131 env :
@@ -183,149 +183,151 @@ jobs:
183183
184184 env :
185185 EXTENSION_NAME : " CrowdSec_Bouncer"
186- EXTENSION_PATH : " crowdsec-bouncer"
186+ EXTENSION_PATH : " wp-content/plugins/crowdsec"
187+ GITHUB_ORIGIN : " crowdsecurity/cs-wordpress-bouncer"
187188
188189 steps :
189190
190- - name : Clone DDEV files
191- uses : actions/checkout@v3
192- with :
193- path : .ddev
194- repository : julienloizelet/ddev-wp
195-
196191 - name : Install DDEV
197- env :
198- DDEV_VERSION : v1.21.4
192+ # @see https://ddev.readthedocs.io/en/stable/#installationupgrade-script-linux-and-macos-armarm64-and-amd64-architectures
199193 run : |
200- # @see https://ddev.readthedocs .io/en/stable/#installationupgrade-script-linux-and-macos-armarm64-and-amd64-architectures
201- sudo apt-get -qq update
202- sudo apt-get -qq -y install libnss3-tools
203- curl -LO https://raw.githubusercontent.com/drud/ ddev/master/scripts/install_ddev.sh
204- bash install_ddev.sh ${{ env.DDEV_VERSION }}
194+ curl -fsSL https://apt.fury .io/drud/gpg.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/ddev.gpg > /dev/null
195+ echo "deb [signed-by=/etc/apt/trusted.gpg.d/ddev.gpg] https://apt.fury.io/drud/ * *" | sudo tee /etc/apt/sources.list.d/ddev.list
196+ sudo apt-get -q update
197+ sudo apt-get -q -y install libnss3-tools ddev
198+ mkcert -install
205199 ddev config global --instrumentation-opt-in=false --omit-containers=dba,ddev-ssh-agent
206- rm install_ddev.sh
207200
208201 - name : Set WP_VERSION_CODE env
209202 # used in some directory path and conventional file naming
210203 # Example : 5.6.5 => wp565
211204 run : |
212205 echo "WP_VERSION_CODE=$(echo wp${{ matrix.wp-version }} | sed 's/\.//g' )" >> $GITHUB_ENV
213206
214- - name : Start DDEV for ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }}
215- run : |
216- cp .ddev/config_overrides/config.${{ env.WP_VERSION_CODE }}.yaml .ddev/config.${{ env.WP_VERSION_CODE }}.yaml
217- cp .ddev/additional_docker_compose/docker-compose.crowdsec-without-plugin.yaml .ddev/docker-compose.crowdsec.yaml
218- cp .ddev/additional_docker_compose/docker-compose.playwright.yaml .ddev/docker-compose.playwright.yaml
219- sed -i -e 's/^php_version:.*/php_version: ${{ matrix.php-version }}/g' .ddev/config.${{ env.WP_VERSION_CODE }}.yaml
220- mkdir -p wp-content/plugins
221- mkdir -p my-own-modules/${{ env.EXTENSION_PATH }}
222- ddev start
223- sudo chmod -R 777 ${{ github.workspace }}/wp-content
224- sudo chmod -R 777 ${{ github.workspace }}/my-own-modules
207+ - name : Create empty WordPress DDEV project
208+ run : ddev config --project-type=wordpress --project-name=${{ env.WP_VERSION_CODE }}
225209
226- - name : Some DEBUG information
210+ - name : Handle PHP version
227211 run : |
228- ddev --version
229- ddev exec php -v
230- ddev exec -s crowdsec crowdsec -version
212+ sed -i -e 's/^php_version:.*/php_version: "${{ matrix.php-version }}"/g' .ddev/config.yaml
231213
232- - name : Install WordPress ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }}
214+ - name : Add Redis, Memcached, Crowdsec and Playwright
233215 run : |
234- wget https://wordpress.org/wordpress-${{ matrix.wp-version }}.tar.gz
235- tar -xf wordpress-${{ matrix.wp-version }}.tar.gz wordpress
236- cp -r wordpress/. ${{ github.workspace }}
237- rm -rf wordpress
238- rm wordpress-${{ matrix.wp-version }}.tar.gz
216+ ddev get ddev/ddev-redis
217+ ddev get ddev/ddev-memcached
218+ ddev get julienloizelet/ddev-playwright
219+ # override redis.conf
220+ ddev get julienloizelet/ddev-tools
221+ ddev get julienloizelet/ddev-crowdsec-php
222+
223+ - name : Start DDEV
224+ run : ddev start
225+
226+ - name : Download WordPress
227+ run : ddev wp core download --version=${{ matrix.wp-version }}
239228
240229 - name : Setup WordPress ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }}
241230 run : |
242- ddev exec wp core install --url='https://${{ env.WP_VERSION_CODE }}.ddev.site' --title='WordPress' --admin_user='admin' --admin_password='admin123' --admin_email='admin@admin.com'
231+ ddev exec wp core install --url='https://${{ env.WP_VERSION_CODE }}.ddev.site' --title='WordPress' --admin_user='admin' --admin_password='admin123' --admin_email='admin@admin.com'
243232
244- - name : Clone ${{ env.EXTENSION_NAME }} files
233+ - name : Set LAST_TAG env
234+ run : |
235+ echo "LAST_TAG=$(curl -Ls -o /dev/null -w %{url_effective} https://github.com/${{ env.GITHUB_ORIGIN }}/releases/latest | grep -oP "\/tag\/v\K(.*)$")" >> $GITHUB_ENV
236+
237+ - name : Clone files from last release
245238 uses : actions/checkout@v3
246239 with :
247- path : my-own-modules/${{ env.EXTENSION_PATH }}
240+ path : raw_sources
241+ ref : " v${{ env.LAST_TAG }}"
242+ repository : " ${{ env.GITHUB_ORIGIN }}"
248243
249244 - name : Retrieve last stable release zip
250- run : |
251- LAST_TAG=$(curl -Ls -o /dev/null -w %{url_effective} $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/releases/latest | grep -oP "\/tag\/v\K(.*)$")
252- curl -fL https://downloads.wordpress.org/plugin/crowdsec.$LAST_TAG.zip -o crowdsec.$LAST_TAG.zip
253- unzip crowdsec.$LAST_TAG.zip -d ${{ github.workspace }}/wp-content/plugins
245+ run : |
246+ curl -fL https://downloads.wordpress.org/plugin/crowdsec.${{ env.LAST_TAG }}.zip -o crowdsec.$LAST_TAG.zip
247+ unzip crowdsec.${{ env.LAST_TAG }}.zip -d ${{ github.workspace }}/wp-content/plugins
248+
249+ - name : Copy needed tests files
250+ run : |
251+ cp -r raw_sources/tests wp-content/plugins/crowdsec
252+ cp -r raw_sources/.github wp-content/plugins/crowdsec
254253
255254 - name : Prepare for playwright test
256255 run : |
257- cd ${{ github.workspace }}
258- cp .ddev/custom_files/crowdsec/php/cache-actions-from-plugin-folder.php cache-actions.php
259- cp -r .ddev/custom_files/crowdsec/cfssl/* wp-content/plugins/crowdsec/tls
260- cd wp-content/plugins/crowdsec
261- docker cp "tls" ddev-${{ env.WP_VERSION_CODE }}-playwright://var/www/html/wp-content/plugins/crowdsec
262- ddev maxmind-download DEFAULT GeoLite2-City /var/www/html/wp-content/plugins/crowdsec/geolocation
263- ddev maxmind-download DEFAULT GeoLite2-Country /var/www/html/wp-content/plugins/crowdsec/geolocation
264- cd ${{ github.workspace }}/wp-content/plugins/crowdsec/geolocation
256+ cp .ddev/okaeli-add-on/wordpress/custom_files/crowdsec/php/cache-actions-from-plugin-folder.php cache-actions.php
257+ cp -r .ddev/okaeli-add-on/custom_files/crowdsec/cfssl/* ${{ env.EXTENSION_PATH }}/tls
258+ ddev maxmind-download DEFAULT GeoLite2-City /var/www/html/${{ env.EXTENSION_PATH }}/geolocation
259+ ddev maxmind-download DEFAULT GeoLite2-Country /var/www/html/${{ env.EXTENSION_PATH }}/geolocation
260+ cd ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/geolocation
265261 sha256sum -c GeoLite2-Country.tar.gz.sha256.txt
266262 sha256sum -c GeoLite2-City.tar.gz.sha256.txt
267263 tar -xf GeoLite2-Country.tar.gz
268264 tar -xf GeoLite2-City.tar.gz
269265 rm GeoLite2-Country.tar.gz GeoLite2-Country.tar.gz.sha256.txt GeoLite2-City.tar.gz GeoLite2-City.tar.gz.sha256.txt
270- cd ${{ github.workspace }}/my-own-modules/ ${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
266+ cd ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
271267 chmod +x test-init.sh
272268 ./test-init.sh
273- chmod +x run-tests.sh
269+ chmod +x run-tests.sh
270+
271+ - name : Some DEBUG information
272+ run : |
273+ ddev --version
274+ ddev exec php -v
275+ ddev exec -s crowdsec crowdsec -version
274276
275277 - name : Run Plugin activation tests
276- uses : ./my-own-modules/ crowdsec-bouncer /.github/workflows/end-to-end/run-single-test
278+ uses : ./wp-content/plugins/ crowdsec/.github/workflows/end-to-end/run-single-test
277279 with :
278- test_path : ${{ github.workspace }}/my-own-modules/ ${{ env.EXTENSION_PATH }}/tests/e2e-ddev
280+ test_path : ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
279281 file_path : 1-activate-plugin.js
280282
281283 - name : Configure CrowdSec and Wordpress bouncer plugin
282284 run : |
283285 ddev crowdsec-config
284286
285287 - name : Run Live mode remediation tests
286- uses : ./my-own-modules/ crowdsec-bouncer /.github/workflows/end-to-end/run-single-test
288+ uses : ./wp-content/plugins/ crowdsec/.github/workflows/end-to-end/run-single-test
287289 with :
288- test_path : ${{ github.workspace }}/my-own-modules/ ${{ env.EXTENSION_PATH }}/tests/e2e-ddev
290+ test_path : ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
289291 file_path : 2-live-mode-remediations.js
290292
291293 - name : Run more Live mode remediation tests
292- uses : ./my-own-modules/ crowdsec-bouncer /.github/workflows/end-to-end/run-single-test
294+ uses : ./wp-content/plugins/ crowdsec/.github/workflows/end-to-end/run-single-test
293295 with :
294- test_path : ${{ github.workspace }}/my-own-modules/ ${{ env.EXTENSION_PATH }}/tests/e2e-ddev
296+ test_path : ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
295297 file_path : 3-live-mode-more.js
296298
297299 - name : Run Live mode cache tests
298- uses : ./my-own-modules/ crowdsec-bouncer /.github/workflows/end-to-end/run-single-test
300+ uses : ./wp-content/plugins/ crowdsec/.github/workflows/end-to-end/run-single-test
299301 with :
300- test_path : ${{ github.workspace }}/my-own-modules/ ${{ env.EXTENSION_PATH }}/tests/e2e-ddev
302+ test_path : ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
301303 file_path : 4-live-mode-cache.js
302304
303305 - name : Prepare cron usage
304306 run : |
305307 sed -i 's/fastcgi_finish_request/\/\/fastcgi_finish_request/g' wp-cron.php
306308
307309 - name : Run Stream mode tests
308- uses : ./my-own-modules/ crowdsec-bouncer /.github/workflows/end-to-end/run-single-test
310+ uses : ./wp-content/plugins/ crowdsec/.github/workflows/end-to-end/run-single-test
309311 with :
310- test_path : ${{ github.workspace }}/my-own-modules/ ${{ env.EXTENSION_PATH }}/tests/e2e-ddev
312+ test_path : ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
311313 file_path : 5-stream-mode.js
312314
313315 - name : Run Redis tests
314- uses : ./my-own-modules/ crowdsec-bouncer /.github/workflows/end-to-end/run-single-test
316+ uses : ./wp-content/plugins/ crowdsec/.github/workflows/end-to-end/run-single-test
315317 with :
316- test_path : ${{ github.workspace }}/my-own-modules/ ${{ env.EXTENSION_PATH }}/tests/e2e-ddev
318+ test_path : ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
317319 file_path : 6-redis.js
318320
319321 - name : Run Memcached tests
320- uses : ./my-own-modules/ crowdsec-bouncer /.github/workflows/end-to-end/run-single-test
322+ uses : ./wp-content/plugins/ crowdsec/.github/workflows/end-to-end/run-single-test
321323 with :
322- test_path : ${{ github.workspace }}/my-own-modules/ ${{ env.EXTENSION_PATH }}/tests/e2e-ddev
324+ test_path : ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
323325 file_path : 7-memcached.js
324326
325327 - name : Run Geolocation tests
326- uses : ./my-own-modules/ crowdsec-bouncer /.github/workflows/end-to-end/run-single-test
328+ uses : ./wp-content/plugins/ crowdsec/.github/workflows/end-to-end/run-single-test
327329 with :
328- test_path : ${{ github.workspace }}/my-own-modules/ ${{ env.EXTENSION_PATH }}/tests/e2e-ddev
330+ test_path : ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
329331 file_path : 8-geolocation.js
330332
331333 - name : tmate debugging session
0 commit comments