|
| 1 | +name: End-to-end test suite |
| 2 | +on: |
| 3 | + push: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - feature/ddev-e2e |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + end-to-end-test-suite: |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + wp-version: [ 5.7.4 ] |
| 15 | + php-version: [ 7.2 ] |
| 16 | + |
| 17 | + name: End-to-end test suite |
| 18 | + runs-on: ubuntu-latest |
| 19 | + |
| 20 | + env: |
| 21 | + EXTENSION_NAME: "CrowdSec_Bouncer" |
| 22 | + EXTENSION_PATH: "crowdsec-bouncer" |
| 23 | + |
| 24 | + steps: |
| 25 | + |
| 26 | + - name: Clone DDEV files |
| 27 | + uses: actions/checkout@v2 |
| 28 | + with: |
| 29 | + path: .ddev |
| 30 | + repository: julienloizelet/ddev-wp |
| 31 | + |
| 32 | + - name: Install DDEV |
| 33 | + run: | |
| 34 | + # @see https://ddev.readthedocs.io/en/stable/#installationupgrade-script-linux-and-macos-armarm64-and-amd64-architectures |
| 35 | + sudo apt-get -qq update |
| 36 | + sudo apt-get -qq -y install libnss3-tools |
| 37 | + curl -LO https://raw.githubusercontent.com/drud/ddev/master/scripts/install_ddev.sh |
| 38 | + bash install_ddev.sh |
| 39 | + ddev config global --instrumentation-opt-in=false --omit-containers=dba,ddev-ssh-agent |
| 40 | + rm install_ddev.sh |
| 41 | +
|
| 42 | + - name: Set WP_VERSION_CODE env |
| 43 | + # used in some directory path and conventional file naming |
| 44 | + # Example : 5.6.5 => wp565 |
| 45 | + run: | |
| 46 | + echo "WP_VERSION_CODE=$(echo wp${{ matrix.wp-version }} | sed 's/\.//g' )" >> $GITHUB_ENV |
| 47 | +
|
| 48 | +
|
| 49 | + - name: Start DDEV for ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }} |
| 50 | + run: | |
| 51 | + cp .ddev/config_overrides/config.${{ env.WP_VERSION_CODE }}.yaml .ddev/config.${{ env.WP_VERSION_CODE }}.yaml |
| 52 | + cp .ddev/additional_docker_compose/docker-compose.crowdsec.yaml .ddev/docker-compose.crowdsec.yaml |
| 53 | + cp .ddev/additional_docker_compose/docker-compose.playwright.yaml .ddev/docker-compose.playwright.yaml |
| 54 | + sed -i -e 's/^php_version:.*/php_version: ${{ matrix.php-version }}/g' .ddev/config.${{ env.WP_VERSION_CODE }}.yaml |
| 55 | + ddev start |
| 56 | + sudo chmod -R 777 ${{ github.workspace }}/wp-content |
| 57 | + sudo chmod -R 777 ${{ github.workspace }}/my-own-modules |
| 58 | +
|
| 59 | + - name: Install WordPress ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }} |
| 60 | + run: | |
| 61 | + wget https://wordpress.org/wordpress-${{ matrix.wp-version }}.tar.gz |
| 62 | + tar -xf wordpress-${{ matrix.wp-version }}.tar.gz wordpress |
| 63 | + cp -r wordpress/. ${{ github.workspace }} |
| 64 | + rm -rf wordpress |
| 65 | + rm wordpress-${{ matrix.wp-version }}.tar.gz |
| 66 | +
|
| 67 | + - name: Setup WordPress ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }} |
| 68 | + run: | |
| 69 | + ddev start |
| 70 | + 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' |
| 71 | +
|
| 72 | +
|
| 73 | + - name: Clone ${{ env.EXTENSION_NAME }} files |
| 74 | + uses: actions/checkout@v2 |
| 75 | + with: |
| 76 | + path: my-own-modules/${{ env.EXTENSION_PATH }} |
| 77 | + |
| 78 | + - name: Install ${{ env.EXTENSION_NAME }} with composer dependencies |
| 79 | + run: | |
| 80 | + ddev composer install --working-dir ./my-own-modules/${{ env.EXTENSION_PATH }} |
| 81 | +
|
| 82 | + - name: Prepare for playwright test |
| 83 | + run: | |
| 84 | + cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__ |
| 85 | + chmod +x test-init.sh |
| 86 | + ./test-init.sh |
| 87 | + chmod +x run-tests.sh |
| 88 | +
|
| 89 | + - name: Run Plugin activation tests |
| 90 | + run: | |
| 91 | + cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__ |
| 92 | + ./run-tests.sh ci "./__tests__/1-activate-plugin.js" |
| 93 | +
|
| 94 | + - name: Configure CrowdSec and Wordpress bouncer plugin |
| 95 | + run: | |
| 96 | + ddev crowdsec-config |
| 97 | +
|
| 98 | + - name: Run Live mode remediation tests |
| 99 | + run: | |
| 100 | + cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__ |
| 101 | + ./run-tests.sh ci "./__tests__/2-live-mode-remediations.js ./__tests__/3-live-mode-more.js" |
| 102 | +
|
| 103 | + - name: Run Live mode cache tests |
| 104 | + run: | |
| 105 | + cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__ |
| 106 | + ./run-tests.sh ci "./__tests__/4-live-mode-cache.js" |
| 107 | +
|
| 108 | + - name: Run Stream mode tests |
| 109 | + run: | |
| 110 | + cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__ |
| 111 | + ./run-tests.sh ci "./__tests__/5-stream-mode.js" |
| 112 | +
|
| 113 | + - name: Run Redis tests |
| 114 | + run: | |
| 115 | + cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__ |
| 116 | + ./run-tests.sh ci "./__tests__/6-redis.js" |
| 117 | +
|
| 118 | + - name: Run Memcached tests |
| 119 | + run: | |
| 120 | + cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__ |
| 121 | + ./run-tests.sh ci "./__tests__/7-memcached.js" |
| 122 | +
|
| 123 | + - name: Run auto prepend mode test suite |
| 124 | + run: | |
| 125 | + cd ${{ github.workspace }}/.ddev |
| 126 | + ddev crowdsec-prepend-nginx |
| 127 | + cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__ |
| 128 | + ./run-tests.sh ci "./__tests__/2-live-mode-remediations.js ./__tests__/3-live-mode-more.js ./__tests__/4-live-mode-cache.js ./__tests__/5-stream-mode.js ./__tests__/6-redis.js ./__tests__/7-memcached.js" |
0 commit comments