Skip to content

Commit 58eb721

Browse files
ci(auto prepend): Fix action [skip ci]
1 parent 9824d1b commit 58eb721

File tree

1 file changed

+147
-125
lines changed

1 file changed

+147
-125
lines changed
Lines changed: 147 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,152 @@
11
name: End-to-end auto-prepend-file mode test suite
22
on:
3-
push:
4-
branches:
5-
- main
6-
paths-ignore:
7-
- '**.md'
8-
workflow_dispatch:
3+
push:
4+
branches:
5+
- main
6+
paths-ignore:
7+
- '**.md'
8+
workflow_dispatch:
99

1010
jobs:
11-
end-to-end-auto-prepend-file-mode-test-suite:
12-
strategy:
13-
fail-fast: false
14-
matrix:
15-
wp-version: [ "4.9", "5.0", "5.1", "5.2", "5.3", "5.4", "5.5", "5.6", "5.7", "5.8", "5.9" ]
16-
php-version: [ "7.2", "7.4", "8.0" ]
17-
exclude:
18-
- { php-version: "7.4", wp-version: "4.9" }
19-
- { php-version: "7.4", wp-version: "5.0" }
20-
- { php-version: "7.4", wp-version: "5.1" }
21-
- { php-version: "7.4", wp-version: "5.2" }
22-
- { php-version: "8.0", wp-version: "4.9" }
23-
- { php-version: "8.0", wp-version: "5.0" }
24-
- { php-version: "8.0", wp-version: "5.1" }
25-
- { php-version: "8.0", wp-version: "5.2" }
26-
- { php-version: "8.0", wp-version: "5.3" }
27-
- { php-version: "8.0", wp-version: "5.4" }
28-
- { php-version: "8.0", wp-version: "5.5" }
29-
30-
name: End-to-end auto-prepend-file mode test suite
31-
runs-on: ubuntu-latest
32-
if: ${{ !contains(github.event.head_commit.message, 'chore(') }}
33-
11+
end-to-end-auto-prepend-file-mode-test-suite:
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
wp-version: [ "4.9", "5.0", "5.1", "5.2", "5.3", "5.4", "5.5", "5.6", "5.7", "5.8", "5.9" ]
16+
php-version: [ "7.2", "7.4", "8.0" ]
17+
exclude:
18+
- { php-version: "7.4", wp-version: "4.9" }
19+
- { php-version: "7.4", wp-version: "5.0" }
20+
- { php-version: "7.4", wp-version: "5.1" }
21+
- { php-version: "7.4", wp-version: "5.2" }
22+
- { php-version: "8.0", wp-version: "4.9" }
23+
- { php-version: "8.0", wp-version: "5.0" }
24+
- { php-version: "8.0", wp-version: "5.1" }
25+
- { php-version: "8.0", wp-version: "5.2" }
26+
- { php-version: "8.0", wp-version: "5.3" }
27+
- { php-version: "8.0", wp-version: "5.4" }
28+
- { php-version: "8.0", wp-version: "5.5" }
29+
30+
name: End-to-end auto-prepend-file mode test suite
31+
runs-on: ubuntu-latest
32+
if: ${{ !contains(github.event.head_commit.message, 'chore(') }}
33+
34+
env:
35+
EXTENSION_NAME: "CrowdSec_Bouncer"
36+
EXTENSION_PATH: "crowdsec-bouncer"
37+
38+
steps:
39+
40+
- name: Clone DDEV files
41+
uses: actions/checkout@v2
42+
with:
43+
path: .ddev
44+
repository: julienloizelet/ddev-wp
45+
46+
- name: Install DDEV
3447
env:
35-
EXTENSION_NAME: "CrowdSec_Bouncer"
36-
EXTENSION_PATH: "crowdsec-bouncer"
37-
38-
steps:
39-
40-
- name: Clone DDEV files
41-
uses: actions/checkout@v2
42-
with:
43-
path: .ddev
44-
repository: julienloizelet/ddev-wp
45-
46-
- name: Install DDEV
47-
env:
48-
DDEV_VERSION: v1.19.1
49-
run: |
50-
# @see https://ddev.readthedocs.io/en/stable/#installationupgrade-script-linux-and-macos-armarm64-and-amd64-architectures
51-
sudo apt-get -qq update
52-
sudo apt-get -qq -y install libnss3-tools
53-
curl -LO https://raw.githubusercontent.com/drud/ddev/master/scripts/install_ddev.sh
54-
bash install_ddev.sh ${{ env.DDEV_VERSION }}
55-
ddev config global --instrumentation-opt-in=false --omit-containers=dba,ddev-ssh-agent
56-
rm install_ddev.sh
57-
58-
- name: Set WP_VERSION_CODE env
59-
# used in some directory path and conventional file naming
60-
# Example : 5.6.5 => wp565
61-
run: |
62-
echo "WP_VERSION_CODE=$(echo wp${{ matrix.wp-version }} | sed 's/\.//g' )" >> $GITHUB_ENV
63-
64-
65-
- name: Start DDEV for ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }}
66-
run: |
67-
cp .ddev/config_overrides/config.${{ env.WP_VERSION_CODE }}.yaml .ddev/config.${{ env.WP_VERSION_CODE }}.yaml
68-
cp .ddev/additional_docker_compose/docker-compose.crowdsec.yaml .ddev/docker-compose.crowdsec.yaml
69-
cp .ddev/additional_docker_compose/docker-compose.playwright.yaml .ddev/docker-compose.playwright.yaml
70-
sed -i -e 's/^php_version:.*/php_version: ${{ matrix.php-version }}/g' .ddev/config.${{ env.WP_VERSION_CODE }}.yaml
71-
mkdir wp-content
72-
ddev start
73-
sudo chmod -R 777 ${{ github.workspace }}/wp-content
74-
sudo chmod -R 777 ${{ github.workspace }}/my-own-modules
75-
76-
- name: Install WordPress ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }}
77-
run: |
78-
wget https://wordpress.org/wordpress-${{ matrix.wp-version }}.tar.gz
79-
tar -xf wordpress-${{ matrix.wp-version }}.tar.gz wordpress
80-
cp -r wordpress/. ${{ github.workspace }}
81-
rm -rf wordpress
82-
rm wordpress-${{ matrix.wp-version }}.tar.gz
83-
84-
- name: Setup WordPress ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }}
85-
run: |
86-
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'
87-
88-
89-
- name: Clone ${{ env.EXTENSION_NAME }} files
90-
uses: actions/checkout@v2
91-
with:
92-
path: my-own-modules/${{ env.EXTENSION_PATH }}
93-
94-
- name: Prepare for playwright test
95-
run: |
96-
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
97-
chmod +x test-init.sh
98-
./test-init.sh
99-
chmod +x run-tests.sh
100-
101-
- name: Run Plugin activation tests
102-
run: |
103-
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
104-
./run-tests.sh ci "./__tests__/1-activate-plugin.js"
105-
106-
- name: Prepare auto-prepend-file mode test suite
107-
run: |
108-
cd ${{ github.workspace }}/.ddev
109-
ddev create-watcher
110-
ddev nginx-config custom_files/crowdsec-prepend-nginx-site.conf
111-
ddev exec -s crowdsec cscli decisions delete --all
112-
113-
- name: Verify auto_prepend_file directive
114-
run: |
115-
cd ${{ github.workspace }}
116-
cp .ddev/custom_files/phpinfo.php phpinfo.php
117-
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' '#')
118-
if [[ $PREPENDVERIF == "auto_prepend_file=/var/www/html/wp-content/plugins/cs-wordpress-bouncer/inc/standalone-bounce.php#auto_prepend_file=/var/www/html/wp-content/plugins/cs-wordpress-bouncer/inc/standalone-bounce.php#" ]]
119-
then
120-
echo "AUTO PREPEND FILE OK"
121-
else
122-
echo "AUTO PREPEND FILE KO"
123-
echo $PREPENDVERIF
124-
exit 1
125-
fi
126-
127-
- name: Run auto prepend mode test suite
128-
run: |
129-
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
130-
./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"
48+
DDEV_VERSION: v1.19.1
49+
run: |
50+
# @see https://ddev.readthedocs.io/en/stable/#installationupgrade-script-linux-and-macos-armarm64-and-amd64-architectures
51+
sudo apt-get -qq update
52+
sudo apt-get -qq -y install libnss3-tools
53+
curl -LO https://raw.githubusercontent.com/drud/ddev/master/scripts/install_ddev.sh
54+
bash install_ddev.sh ${{ env.DDEV_VERSION }}
55+
ddev config global --instrumentation-opt-in=false --omit-containers=dba,ddev-ssh-agent
56+
rm install_ddev.sh
57+
58+
- name: Set WP_VERSION_CODE env
59+
# used in some directory path and conventional file naming
60+
# Example : 5.6.5 => wp565
61+
run: |
62+
echo "WP_VERSION_CODE=$(echo wp${{ matrix.wp-version }} | sed 's/\.//g' )" >> $GITHUB_ENV
63+
64+
65+
- name: Start DDEV for ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }}
66+
run: |
67+
cp .ddev/config_overrides/config.${{ env.WP_VERSION_CODE }}.yaml .ddev/config.${{ env.WP_VERSION_CODE }}.yaml
68+
cp .ddev/additional_docker_compose/docker-compose.crowdsec.yaml .ddev/docker-compose.crowdsec.yaml
69+
cp .ddev/additional_docker_compose/docker-compose.playwright.yaml .ddev/docker-compose.playwright.yaml
70+
sed -i -e 's/^php_version:.*/php_version: ${{ matrix.php-version }}/g' .ddev/config.${{ env.WP_VERSION_CODE }}.yaml
71+
mkdir wp-content
72+
ddev start
73+
sudo chmod -R 777 ${{ github.workspace }}/wp-content
74+
sudo chmod -R 777 ${{ github.workspace }}/my-own-modules
75+
76+
- name: Install WordPress ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }}
77+
run: |
78+
wget https://wordpress.org/wordpress-${{ matrix.wp-version }}.tar.gz
79+
tar -xf wordpress-${{ matrix.wp-version }}.tar.gz wordpress
80+
cp -r wordpress/. ${{ github.workspace }}
81+
rm -rf wordpress
82+
rm wordpress-${{ matrix.wp-version }}.tar.gz
83+
84+
- name: Setup WordPress ${{ matrix.wp-version }} with PHP ${{ matrix.php-version }}
85+
run: |
86+
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'
87+
88+
89+
- name: Clone ${{ env.EXTENSION_NAME }} files
90+
uses: actions/checkout@v2
91+
with:
92+
path: my-own-modules/${{ env.EXTENSION_PATH }}
93+
94+
- name: Prepare for playwright test
95+
run: |
96+
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
97+
chmod +x test-init.sh
98+
./test-init.sh
99+
chmod +x run-tests.sh
100+
101+
- name: Run Plugin activation tests
102+
run: |
103+
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
104+
./run-tests.sh ci "./__tests__/1-activate-plugin.js"
105+
106+
- name: Configure CrowdSec and Wordpress bouncer plugin
107+
run: |
108+
ddev crowdsec-config
109+
110+
- name: Prepare auto-prepend-file mode test suite
111+
run: |
112+
cd ${{ github.workspace }}/.ddev
113+
ddev nginx-config custom_files/crowdsec-prepend-nginx-site.conf
114+
115+
- name: Verify auto_prepend_file directive
116+
run: |
117+
cd ${{ github.workspace }}
118+
cp .ddev/custom_files/phpinfo.php phpinfo.php
119+
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' '#')
120+
if [[ $PREPENDVERIF == "auto_prepend_file=/var/www/html/wp-content/plugins/cs-wordpress-bouncer/inc/standalone-bounce.php#auto_prepend_file=/var/www/html/wp-content/plugins/cs-wordpress-bouncer/inc/standalone-bounce.php#" ]]
121+
then
122+
echo "AUTO PREPEND FILE OK"
123+
else
124+
echo "AUTO PREPEND FILE KO"
125+
echo $PREPENDVERIF
126+
exit 1
127+
fi
128+
129+
- name: Run Live mode remediation tests
130+
run: |
131+
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
132+
./run-tests.sh ci "./__tests__/2-live-mode-remediations.js ./__tests__/3-live-mode-more.js"
133+
134+
- name: Run Live mode cache tests
135+
run: |
136+
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
137+
./run-tests.sh ci "./__tests__/4-live-mode-cache.js"
138+
139+
- name: Run Stream mode tests
140+
run: |
141+
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
142+
./run-tests.sh ci "./__tests__/5-stream-mode.js"
143+
144+
- name: Run Redis tests
145+
run: |
146+
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
147+
./run-tests.sh ci "./__tests__/6-redis.js"
148+
149+
- name: Run Memcached tests
150+
run: |
151+
cd ${{ github.workspace }}/my-own-modules/${{ env.EXTENSION_PATH }}/tests/e2e-ddev/__scripts__
152+
./run-tests.sh ci "./__tests__/7-memcached.js"

0 commit comments

Comments
 (0)