Skip to content

Commit bf10b76

Browse files
Merge pull request #57 from crowdsecurity/feature/standalone-fix-and-update
Feature/standalone fix and update
2 parents 8f2d19f + e11adaa commit bf10b76

32 files changed

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

Comments
 (0)