1010permissions :
1111 contents : read
1212
13+ env :
14+ # Allow ddev get to use a GitHub token to prevent rate limiting by tests
15+ DDEV_GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
16+
1317jobs :
1418 end-to-end-auto-prepend-file-mode-test-suite :
1519 strategy :
@@ -36,94 +40,85 @@ jobs:
3640
3741 env :
3842 EXTENSION_NAME : " CrowdSec_Bouncer"
39- EXTENSION_PATH : " crowdsec-bouncer "
43+ EXTENSION_PATH : " wp-content/plugins/crowdsec "
4044
4145 steps :
4246
43- - name : Clone DDEV files
44- uses : actions/checkout@v3
45- with :
46- path : .ddev
47- repository : julienloizelet/ddev-wp
48-
4947 - name : Install DDEV
50- env :
51- DDEV_VERSION : v1.21.4
48+ # @see https://ddev.readthedocs.io/en/stable/#installationupgrade-script-linux-and-macos-armarm64-and-amd64-architectures
5249 run : |
53- # @see https://ddev.readthedocs .io/en/stable/#installationupgrade-script-linux-and-macos-armarm64-and-amd64-architectures
54- sudo apt-get -qq update
55- sudo apt-get -qq -y install libnss3-tools
56- curl -LO https://raw.githubusercontent.com/drud/ ddev/master/scripts/install_ddev.sh
57- bash install_ddev.sh ${{ env.DDEV_VERSION }}
50+ curl -fsSL https://apt.fury .io/drud/gpg.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/ddev.gpg > /dev/null
51+ 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
52+ sudo apt-get -q update
53+ sudo apt-get -q -y install libnss3-tools ddev
54+ mkcert -install
5855 ddev config global --instrumentation-opt-in=false --omit-containers=dba,ddev-ssh-agent
59- rm install_ddev.sh
56+
6057
6158 - name : Set WP_VERSION_CODE env
6259 # used in some directory path and conventional file naming
6360 # Example : 5.6.5 => wp565
6461 run : |
6562 echo "WP_VERSION_CODE=$(echo wp${{ matrix.wp-version }} | sed 's/\.//g' )" >> $GITHUB_ENV
6663
64+ - name : Create empty WordPress DDEV project
65+ run : ddev config --project-type=wordpress --project-name=${{ env.WP_VERSION_CODE }}
6766
68- - name : Start DDEV for ${{ matrix.wp-version }} with PHP ${{ matrix.php- version }}
67+ - name : Handle PHP version
6968 run : |
70- cp .ddev/config_overrides/config.${{ env.WP_VERSION_CODE }}.yaml .ddev/config.${{ env.WP_VERSION_CODE }}.yaml
71- cp .ddev/additional_docker_compose/docker-compose.crowdsec.yaml .ddev/docker-compose.crowdsec.yaml
72- cp .ddev/additional_docker_compose/docker-compose.playwright.yaml .ddev/docker-compose.playwright.yaml
73- sed -i -e 's/^php_version:.*/php_version: ${{ matrix.php-version }}/g' .ddev/config.${{ env.WP_VERSION_CODE }}.yaml
74- mkdir wp-content
75- ddev start
76- sudo chmod -R 777 ${{ github.workspace }}/wp-content
77- sudo chmod -R 777 ${{ github.workspace }}/my-own-modules
69+ sed -i -e 's/^php_version:.*/php_version: "${{ matrix.php-version }}"/g' .ddev/config.yaml
7870
79- - name : Some DEBUG information
71+ - name : Add Redis, Memcached, Crowdsec and Playwright
8072 run : |
81- ddev --version
82- ddev exec php -v
83- ddev exec -s crowdsec crowdsec -version
73+ ddev get ddev/ddev-redis
74+ ddev get ddev/ddev-memcached
75+ ddev get julienloizelet/ddev-playwright
76+ # override redis.conf
77+ ddev get julienloizelet/ddev-tools
78+ ddev get julienloizelet/ddev-crowdsec-php
8479
85- - name : Install WordPress ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }}
86- run : |
87- wget https://wordpress.org/wordpress-${{ matrix.wp-version }}.tar.gz
88- tar -xf wordpress-${{ matrix.wp-version }}.tar.gz wordpress
89- cp -r wordpress/. ${{ github.workspace }}
90- rm -rf wordpress
91- rm wordpress-${{ matrix.wp-version }}.tar.gz
80+ - name : Start DDEV
81+ run : ddev start
82+
83+ - name : Download WordPress
84+ run : ddev wp core download --version=${{ matrix.wp-version }}
9285
9386 - name : Setup WordPress ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }}
9487 run : |
95- 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'
96-
88+ 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'
9789
9890 - name : Clone ${{ env.EXTENSION_NAME }} files
9991 uses : actions/checkout@v3
10092 with :
101- path : my-own-modules/ ${{ env.EXTENSION_PATH }}
93+ path : ${{ env.EXTENSION_PATH }}
10294
10395 - name : Prepare for playwright test
10496 run : |
105- cd ${{ github.workspace }}
106- cp .ddev/custom_files/crowdsec/php/cache-actions.php cache-actions.php
107- cp -r .ddev/custom_files/crowdsec/cfssl/* my-own-modules/${{ env.EXTENSION_PATH }}/tls
108- cd my-own-modules/${{ env.EXTENSION_PATH }}
109- docker cp "tls" ddev-${{ env.WP_VERSION_CODE }}-playwright://var/www/html/wp-content/plugins/crowdsec
110- ddev maxmind-download DEFAULT GeoLite2-City /var/www/html/my-own-modules/${{ env.EXTENSION_PATH }}/geolocation
111- ddev maxmind-download DEFAULT GeoLite2-Country /var/www/html/my-own-modules/${{ env.EXTENSION_PATH }}/geolocation
112- cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/geolocation
97+ cp .ddev/okaeli-add-on/wordpress/custom_files/crowdsec/php/cache-actions-from-plugin-folder.php cache-actions.php
98+ cp -r .ddev/okaeli-add-on/custom_files/crowdsec/cfssl/* ${{ env.EXTENSION_PATH }}/tls
99+ ddev maxmind-download DEFAULT GeoLite2-City /var/www/html/${{ env.EXTENSION_PATH }}/geolocation
100+ ddev maxmind-download DEFAULT GeoLite2-Country /var/www/html/${{ env.EXTENSION_PATH }}/geolocation
101+ cd ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/geolocation
113102 sha256sum -c GeoLite2-Country.tar.gz.sha256.txt
114103 sha256sum -c GeoLite2-City.tar.gz.sha256.txt
115104 tar -xf GeoLite2-Country.tar.gz
116105 tar -xf GeoLite2-City.tar.gz
117106 rm GeoLite2-Country.tar.gz GeoLite2-Country.tar.gz.sha256.txt GeoLite2-City.tar.gz GeoLite2-City.tar.gz.sha256.txt
118- cd ${{ github.workspace }}/my-own-modules/ ${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
107+ cd ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
119108 chmod +x test-init.sh
120109 ./test-init.sh
121- chmod +x run-tests.sh
110+ chmod +x run-tests.sh
111+
112+ - name : Some DEBUG information
113+ run : |
114+ ddev --version
115+ ddev exec php -v
116+ ddev exec -s crowdsec crowdsec -version
122117
123118 - name : Run Plugin activation tests
124- uses : ./my-own-modules/ crowdsec-bouncer /.github/workflows/end-to-end/run-single-test
119+ uses : ./wp-content/plugins/ crowdsec/.github/workflows/end-to-end/run-single-test
125120 with :
126- test_path : ${{ github.workspace }}/my-own-modules/ ${{ env.EXTENSION_PATH }}/tests/e2e-ddev
121+ test_path : ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
127122 file_path : 1-activate-plugin.js
128123
129124 - name : Configure CrowdSec and Wordpress bouncer plugin
@@ -133,12 +128,12 @@ jobs:
133128 - name : Prepare auto-prepend-file mode test suite
134129 run : |
135130 cd ${{ github.workspace }}/.ddev
136- ddev nginx-config custom_files/crowdsec-prepend-nginx-site.conf
131+ ddev nginx-config okaeli-add-on/wordpress/ custom_files/crowdsec /crowdsec-prepend-nginx-site.conf
137132
138133 - name : Verify auto_prepend_file directive
139134 run : |
140135 cd ${{ github.workspace }}
141- cp .ddev/custom_files/phpinfo.php phpinfo.php
136+ cp .ddev/okaeli-add-on/common/ custom_files/phpinfo.php phpinfo.php
142137 curl -v https://${{ env.WP_VERSION_CODE }}.ddev.site/phpinfo.php
143138 PREPENDVERIF=$(curl https://${{ env.WP_VERSION_CODE }}.ddev.site/phpinfo.php | grep -o -E "auto_prepend_file=(.*)php(.*)" | sed 's/<\/tr>//g; s/<\/td>//g;' | tr '\n' '#')
144139 if [[ $PREPENDVERIF == "auto_prepend_file=/var/www/html/wp-content/plugins/crowdsec/inc/standalone-bounce.php#auto_prepend_file=/var/www/html/wp-content/plugins/crowdsec/inc/standalone-bounce.php#" ]]
@@ -151,47 +146,47 @@ jobs:
151146 fi
152147
153148 - name : Run Live mode remediation tests
154- uses : ./my-own-modules/ crowdsec-bouncer /.github/workflows/end-to-end/run-single-test
149+ uses : ./wp-content/plugins/ crowdsec/.github/workflows/end-to-end/run-single-test
155150 with :
156- test_path : ${{ github.workspace }}/my-own-modules/ ${{ env.EXTENSION_PATH }}/tests/e2e-ddev
151+ test_path : ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
157152 file_path : 2-live-mode-remediations.js
158153
159154 - name : Run more Live mode remediation tests
160- uses : ./my-own-modules/ crowdsec-bouncer /.github/workflows/end-to-end/run-single-test
155+ uses : ./wp-content/plugins/ crowdsec/.github/workflows/end-to-end/run-single-test
161156 with :
162- test_path : ${{ github.workspace }}/my-own-modules/ ${{ env.EXTENSION_PATH }}/tests/e2e-ddev
157+ test_path : ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
163158 file_path : 3-live-mode-more.js
164159
165160 - name : Run Live mode cache tests
166- uses : ./my-own-modules/ crowdsec-bouncer /.github/workflows/end-to-end/run-single-test
161+ uses : ./wp-content/plugins/ crowdsec/.github/workflows/end-to-end/run-single-test
167162 with :
168- test_path : ${{ github.workspace }}/my-own-modules/ ${{ env.EXTENSION_PATH }}/tests/e2e-ddev
163+ test_path : ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
169164 file_path : 4-live-mode-cache.js
170165
171166 - name : Prepare cron usage
172167 run : |
173168 sed -i 's/fastcgi_finish_request/\/\/fastcgi_finish_request/g' wp-cron.php
174169
175170 - name : Run Stream mode tests
176- uses : ./my-own-modules/ crowdsec-bouncer /.github/workflows/end-to-end/run-single-test
171+ uses : ./wp-content/plugins/ crowdsec/.github/workflows/end-to-end/run-single-test
177172 with :
178- test_path : ${{ github.workspace }}/my-own-modules/ ${{ env.EXTENSION_PATH }}/tests/e2e-ddev
173+ test_path : ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
179174 file_path : 5-stream-mode.js
180175
181176 - name : Run Redis tests
182- uses : ./my-own-modules/ crowdsec-bouncer /.github/workflows/end-to-end/run-single-test
177+ uses : ./wp-content/plugins/ crowdsec/.github/workflows/end-to-end/run-single-test
183178 with :
184- test_path : ${{ github.workspace }}/my-own-modules/ ${{ env.EXTENSION_PATH }}/tests/e2e-ddev
179+ test_path : ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
185180 file_path : 6-redis.js
186181
187182 - name : Run Memcached tests
188- uses : ./my-own-modules/ crowdsec-bouncer /.github/workflows/end-to-end/run-single-test
183+ uses : ./wp-content/plugins/ crowdsec/.github/workflows/end-to-end/run-single-test
189184 with :
190- test_path : ${{ github.workspace }}/my-own-modules/ ${{ env.EXTENSION_PATH }}/tests/e2e-ddev
185+ test_path : ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
191186 file_path : 7-memcached.js
192187
193188 - name : Run Geolocation tests
194- uses : ./my-own-modules/ crowdsec-bouncer /.github/workflows/end-to-end/run-single-test
189+ uses : ./wp-content/plugins/ crowdsec/.github/workflows/end-to-end/run-single-test
195190 with :
196- test_path : ${{ github.workspace }}/my-own-modules/ ${{ env.EXTENSION_PATH }}/tests/e2e-ddev
191+ test_path : ${{ github.workspace }}/${{ env.EXTENSION_PATH }}/tests/e2e-ddev
197192 file_path : 8-geolocation.js
0 commit comments