77 - ' **.md'
88 workflow_dispatch :
99
10+ permissions :
11+ contents : read
12+
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+
1017jobs :
1118 test-suite :
1219 strategy :
@@ -18,46 +25,42 @@ jobs:
1825 runs-on : ubuntu-latest
1926 if : ${{ !contains(github.event.head_commit.message, 'chore(') }}
2027 env :
21- EXTENSION_PATH : " my-own-modules/crowdsec-php-lib"
28+ EXTENSION_PATH : " my-code/crowdsec-bouncer-lib"
29+ DDEV_PROJECT : " crowdsec-bouncer-lib"
2230 JP_TEST_IP : " 210.249.74.42"
2331 IPV6_TEST_IP : " 2001:0db8:0000:85a3:0000:0000:ac1f:8001"
2432 IPV6_TEST_PROXY_IP : " 2345:0425:2CA1:0000:0000:0567:5673:23b5"
2533
2634 steps :
27- - name : Clone DDEV files
28- uses : actions/checkout@v3
29- with :
30- path : .ddev
31- repository : julienloizelet/ddev-php
32- ref : " main"
33-
3435 - name : Install DDEV
35- env :
36- DDEV_VERSION : v1.21.4
36+ # @see https://ddev.readthedocs.io/en/stable/#installationupgrade-script-linux-and-macos-armarm64-and-amd64-architectures
3737 run : |
38- # @see https://ddev.readthedocs .io/en/stable/#installationupgrade-script-linux-and-macos-armarm64-and-amd64-architectures
39- sudo apt-get -qq update
40- sudo apt-get -qq -y install libnss3-tools
41- curl -LO https://raw.githubusercontent.com/drud/ ddev/master/scripts/install_ddev.sh
42- bash install_ddev.sh ${{env.DDEV_VERSION}}
38+ curl -fsSL https://apt.fury .io/drud/gpg.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/ddev.gpg > /dev/null
39+ 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
40+ sudo apt-get -q update
41+ sudo apt-get -q -y install libnss3-tools ddev
42+ mkcert -install
4343 ddev config global --instrumentation-opt-in=false --omit-containers=dba,ddev-ssh-agent
44- rm install_ddev.sh
4544
46- - name : Set PHP_VERSION_CODE env
47- # used in some directory path and conventional file naming
48- # Example : 7.4 => 74
45+ - name : Create empty PHP DDEV project
46+ run : ddev config --project-type=php --project-name=${{env.DDEV_PROJECT}} --php-version=${{ matrix.php-version }}
47+
48+ - name : Add Redis, Memcached and Crowdsec
4949 run : |
50- echo "PHP_VERSION_CODE=$(echo php${{ matrix.php-version }} | sed 's/\.//g' )" >> $GITHUB_ENV
50+ ddev get ddev/ddev-redis
51+ ddev get ddev/ddev-memcached
52+ # override redis.conf
53+ ddev get julienloizelet/ddev-tools
54+ ddev get julienloizelet/ddev-crowdsec-php
55+ ddev get julienloizelet/ddev-playwright
56+
57+ - name : Start DDEV
58+ run : |
59+ ddev start
5160
5261
5362 - name : Start DDEV with PHP ${{ matrix.php-version }}
54- run : |
55- cp .ddev/config_overrides/config.${{ env.PHP_VERSION_CODE }}.yaml .ddev/config.${{ env.PHP_VERSION_CODE }}.yaml
56- cp .ddev/additional_docker_compose/docker-compose.crowdsec.yaml .ddev/docker-compose.crowdsec.yaml
57- cp .ddev/additional_docker_compose/docker-compose.playwright.yaml .ddev/docker-compose.playwright.yaml
58- mkdir ${{ github.workspace }}/cfssl
59- cp -r .ddev/custom_files/crowdsec/cfssl/* ${{ github.workspace }}/cfssl
60- ddev start
63+ run : ddev start
6164
6265 - name : Set BOUNCER_KEY and PROXY_IP env
6366 run : |
7477 - name : Clone PHP lib Crowdsec files
7578 uses : actions/checkout@v3
7679 with :
77- path : my-own-modules /crowdsec-php -lib
80+ path : my-code /crowdsec-bouncer -lib
7881
7982 - name : Validate composer.json
8083 run : ddev composer validate --strict --working-dir ./${{env.EXTENSION_PATH}}
8992
9093 - name : Prepare PHP Integration and end-to-end tests
9194 run : |
95+ mkdir ${{ github.workspace }}/cfssl
96+ cp -r .ddev/okaeli-add-on/custom_files/crowdsec/cfssl/* ${{ github.workspace }}/cfssl
9297 ddev maxmind-download DEFAULT GeoLite2-City /var/www/html/${{env.EXTENSION_PATH}}/tests
9398 ddev maxmind-download DEFAULT GeoLite2-Country /var/www/html/${{env.EXTENSION_PATH}}/tests
9499 cd ${{env.EXTENSION_PATH}}/tests
@@ -121,7 +126,7 @@ jobs:
121126 - name : Prepare Standalone Bouncer end-to-end tests
122127 run : |
123128 cd ${{ github.workspace }}/.ddev
124- ddev nginx-config custom_files/crowdsec-prepend-nginx-site.conf
129+ ddev nginx-config okaeli-add-on/native/ custom_files/crowdsec /crowdsec-prepend-nginx-site.conf
125130 cd ${{ github.workspace }}
126131 cp ${{env.EXTENSION_PATH}}/tests/end-to-end/settings/base.php.dist crowdsec-lib-settings.php
127132 sed -i -e 's/REPLACE_API_KEY/${{ env.BOUNCER_KEY }}/g' crowdsec-lib-settings.php
@@ -137,10 +142,10 @@ jobs:
137142 - name : Verify auto_prepend_file directive
138143 run : |
139144 cd ${{ github.workspace }}
140- cp .ddev/custom_files/phpinfo.php ${{env.EXTENSION_PATH}}/scripts/public/phpinfo.php
141- curl -v https://${{ env.PHP_VERSION_CODE }}.ddev.site/${{env.EXTENSION_PATH}}/scripts/public/phpinfo.php
142- PREPENDVERIF=$(curl https://${{ env.PHP_VERSION_CODE }}.ddev.site/${{env.EXTENSION_PATH}}/scripts/public/phpinfo.php | grep -o -E "auto_prepend_file=(.*)php(.*)" | sed 's/<\/tr>//g; s/<\/td>//g;' | tr '\n' '#')
143- if [[ $PREPENDVERIF == "auto_prepend_file=/var/www/html/${{env.EXTENSION_PATH}}/scripts/auto-prepend/bounce.php#auto_prepend_file=/var/www/html/my-own-modules /crowdsec-php -lib/scripts/auto-prepend/bounce.php#" ]]
145+ cp .ddev/okaeli-add-on/common/ custom_files/phpinfo.php ${{env.EXTENSION_PATH}}/scripts/public/phpinfo.php
146+ curl -v https://${{env.DDEV_PROJECT }}.ddev.site/${{env.EXTENSION_PATH}}/scripts/public/phpinfo.php
147+ PREPENDVERIF=$(curl https://${{env.DDEV_PROJECT }}.ddev.site/${{env.EXTENSION_PATH}}/scripts/public/phpinfo.php | grep -o -E "auto_prepend_file=(.*)php(.*)" | sed 's/<\/tr>//g; s/<\/td>//g;' | tr '\n' '#')
148+ if [[ $PREPENDVERIF == "auto_prepend_file=/var/www/html/${{env.EXTENSION_PATH}}/scripts/auto-prepend/bounce.php#auto_prepend_file=/var/www/html/my-code /crowdsec-bouncer -lib/scripts/auto-prepend/bounce.php#" ]]
144149 then
145150 echo "AUTO PREPEND FILE OK"
146151 else
0 commit comments