Skip to content

fix(2.3): Disable phpcs Magento2.Legacy.EscapeMethodsOnBlockClass for… #20

fix(2.3): Disable phpcs Magento2.Legacy.EscapeMethodsOnBlockClass for…

fix(2.3): Disable phpcs Magento2.Legacy.EscapeMethodsOnBlockClass for… #20

name: End-to-end auto-prepend-file mode tests
on:
push:
branches:
- main
paths-ignore:
- '**.md'
workflow_dispatch:
permissions:
contents: read
env:
# Allow ddev get to use a GitHub token to prevent rate limiting by tests
DDEV_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
end-to-end-auto-prepend-file-test-suite:
strategy:
fail-fast: false
matrix:
# Last 2 patches for the current minor, and last one for the previous minor, greatest php version
include:
- m2-version: '2.3.7'
php-version: '7.4'
- m2-version: '2.4.5'
php-version: '8.1'
- m2-version: '2.4.6'
php-version: '8.2'
name: End-to-end auto-prepend-file mode test suite
if: ${{ !contains(github.event.head_commit.message, 'chore(') }}
runs-on: ubuntu-latest
env:
EXTENSION_PACKAGE_NAME: "crowdsec/magento2-module-bouncer"
EXTENSION_NAME: "CrowdSec_Bouncer"
EXTENSION_PATH: "crowdsec-bouncer"
steps:
- name: Install Magento 2 with DDEV
uses: julienloizelet/[email protected]
with:
php_version: ${{ matrix.php-version }}
magento_version: ${{ matrix.m2-version }}
composer_auth: ${{ secrets.M2_COMPOSER_AUTH }}
magento_repository: "https://repo.magento.com/"
- name: Add Redis and Memcached
run: |
ddev get ddev/ddev-redis
ddev get ddev/ddev-memcached
# override redis.conf
ddev get julienloizelet/ddev-tools
- name: Add Playwright
run: ddev get julienloizelet/ddev-playwright
- name: Clone M2 ${{ env.EXTENSION_NAME }} files
uses: actions/checkout@v3
with:
path: my-own-modules/${{ env.EXTENSION_PATH }}
- name: Prepare composer repositories
run: |
ddev composer config --unset repositories.0
ddev composer config repositories.0 '{"type": "path", "url":"my-own-modules/${{ env.EXTENSION_PATH }}/", "canonical": true}'
ddev composer config repositories.1 '{"type": "composer", "url":"https://repo.magento.com/", "exclude": ["${{ env.EXTENSION_PACKAGE_NAME }}", "magento/composer-dependency-version-audit-plugin"]}'
cat composer.json
- name: Add ${{ env.EXTENSION_NAME }} as composer dependency
run: |
ddev composer require ${{ env.EXTENSION_PACKAGE_NAME }}:@dev --no-interaction
- name: Disable some extensions for 2.4.6
if: startsWith(matrix.m2-version, '2.4.6')
run: ddev magento module:disable Magento_AdminAdobeImsTwoFactorAuth
- name: Disable some extensions for 2.4
if: startsWith(matrix.m2-version, '2.4')
run: |
ddev magento module:disable Magento_TwoFactorAuth
ddev magento module:disable Magento_AdminNotification
- name: Make some workaround for 2.3.5
if: startsWith(matrix.m2-version, '2.3.5')
run: |
ddev magento module:disable Dotdigitalgroup_Chat
ddev magento module:disable Dotdigitalgroup_Email
- name: Enable extension and prepare Crowdsec
run: |
ddev magento deploy:mode:set developer
ddev magento module:enable ${{ env.EXTENSION_NAME }}
ddev magento setup:upgrade
ddev magento setup:static-content:deploy -f
ddev magento cache:flush
ddev get julienloizelet/ddev-crowdsec-php
ddev restart
- name: Prepare for playwright test
run: |
cp .ddev/okaeli-add-on/magento2/custom_files/varnish-profile.xml varnish-profile.xml
ddev magento setup:performance:generate-fixtures ./varnish-profile.xml
ddev magento cache:flush
mkdir -p var/crowdsec/tls
cp -r .ddev/okaeli-add-on/custom_files/crowdsec/cfssl/* var/crowdsec/tls
ddev maxmind-download DEFAULT GeoLite2-City /var/www/html/var/crowdsec
ddev maxmind-download DEFAULT GeoLite2-Country /var/www/html/var/crowdsec
cd var/crowdsec
sha256sum -c GeoLite2-Country.tar.gz.sha256.txt
sha256sum -c GeoLite2-City.tar.gz.sha256.txt
tar -xf GeoLite2-Country.tar.gz
tar -xf GeoLite2-City.tar.gz
rm GeoLite2-Country.tar.gz GeoLite2-Country.tar.gz.sha256.txt GeoLite2-City.tar.gz GeoLite2-City.tar.gz.sha256.txt
cd ${{ github.workspace }}
cp .ddev/okaeli-add-on/magento2/custom_scripts/cronLaunch.php ${{ github.workspace }}/pub/cronLaunch.php
cp .ddev/okaeli-add-on/magento2/custom_scripts/crowdsec/cacheActions.php ${{ github.workspace }}/pub/cacheActions.php
cp ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/crowdsec-prepend.php.example ${{ github.workspace }}/app/etc/crowdsec-prepend.php
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/Test/EndToEnd/__scripts__
chmod +x test-init.sh
./test-init.sh
chmod +x run-tests.sh
- name: Prepare auto-prepend-file mode test suite
run: |
cd ${{ github.workspace }}/.ddev
ddev nginx-config okaeli-add-on/magento2/custom_files/crowdsec/crowdsec-prepend-nginx-site.conf
- name: Verify auto_prepend_file directive
run: |
cd ${{ github.workspace }}
cp .ddev/okaeli-add-on/common/custom_files/phpinfo.php pub/phpinfo.php
curl -v https://${{ env.M2_VERSION_CODE }}.ddev.site/phpinfo.php
PREPENDVERIF=$(curl https://${{ env.M2_VERSION_CODE }}.ddev.site/phpinfo.php | grep -o -E "auto_prepend_file=(.*)php(.*)" | sed 's/<\/tr>//g; s/<\/td>//g;' | tr '\n' '#')
if [[ $PREPENDVERIF == "auto_prepend_file=/var/www/html/app/etc/crowdsec-prepend.php#auto_prepend_file=/var/www/html/app/etc/crowdsec-prepend.php#" ]]
then
echo "AUTO PREPEND FILE OK"
else
echo "AUTO PREPEND FILE KO"
echo $PREPENDVERIF
exit 1
fi
- name: Run config test
uses: ./my-own-modules/crowdsec-bouncer/.github/workflows/end-to-end/run-single-test
with:
test_path: ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/Test/EndToEnd
file_path: 1-config.js
- name: Run live mode test
uses: ./my-own-modules/crowdsec-bouncer/.github/workflows/end-to-end/run-single-test
with:
test_path: ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/Test/EndToEnd
file_path: 2-live-mode.js
- name: Run stream mode test
uses: ./my-own-modules/crowdsec-bouncer/.github/workflows/end-to-end/run-single-test
with:
test_path: ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/Test/EndToEnd
file_path: 3-stream-mode.js
- name: Run cron test
uses: ./my-own-modules/crowdsec-bouncer/.github/workflows/end-to-end/run-single-test
with:
test_path: ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/Test/EndToEnd
file_path: 4-cron.js
- name: Run api tests
uses: ./my-own-modules/crowdsec-bouncer/.github/workflows/end-to-end/run-single-test
with:
test_path: ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/Test/EndToEnd
file_path: 5-api.js
- name: Run geolocation test
uses: ./my-own-modules/crowdsec-bouncer/.github/workflows/end-to-end/run-single-test
with:
test_path: ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/Test/EndToEnd
file_path: 7-geolocation.js