7
7
- ' **.md'
8
8
workflow_dispatch :
9
9
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
+
10
17
jobs :
11
18
test-suite :
12
19
strategy :
@@ -18,46 +25,42 @@ jobs:
18
25
runs-on : ubuntu-latest
19
26
if : ${{ !contains(github.event.head_commit.message, 'chore(') }}
20
27
env :
21
- EXTENSION_PATH : " my-own-modules/crowdsec-php-lib"
28
+ EXTENSION_PATH : " my-code/crowdsec-bouncer-lib"
29
+ DDEV_PROJECT : " crowdsec-bouncer-lib"
22
30
JP_TEST_IP : " 210.249.74.42"
23
31
IPV6_TEST_IP : " 2001:0db8:0000:85a3:0000:0000:ac1f:8001"
24
32
IPV6_TEST_PROXY_IP : " 2345:0425:2CA1:0000:0000:0567:5673:23b5"
25
33
26
34
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
-
34
35
- 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
37
37
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
43
43
ddev config global --instrumentation-opt-in=false --omit-containers=dba,ddev-ssh-agent
44
- rm install_ddev.sh
45
44
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
49
49
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
51
60
52
61
53
62
- 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
61
64
62
65
- name : Set BOUNCER_KEY and PROXY_IP env
63
66
run : |
74
77
- name : Clone PHP lib Crowdsec files
75
78
uses : actions/checkout@v3
76
79
with :
77
- path : my-own-modules /crowdsec-php -lib
80
+ path : my-code /crowdsec-bouncer -lib
78
81
79
82
- name : Validate composer.json
80
83
run : ddev composer validate --strict --working-dir ./${{env.EXTENSION_PATH}}
89
92
90
93
- name : Prepare PHP Integration and end-to-end tests
91
94
run : |
95
+ mkdir ${{ github.workspace }}/cfssl
96
+ cp -r .ddev/okaeli-add-on/custom_files/crowdsec/cfssl/* ${{ github.workspace }}/cfssl
92
97
ddev maxmind-download DEFAULT GeoLite2-City /var/www/html/${{env.EXTENSION_PATH}}/tests
93
98
ddev maxmind-download DEFAULT GeoLite2-Country /var/www/html/${{env.EXTENSION_PATH}}/tests
94
99
cd ${{env.EXTENSION_PATH}}/tests
@@ -121,7 +126,7 @@ jobs:
121
126
- name : Prepare Standalone Bouncer end-to-end tests
122
127
run : |
123
128
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
125
130
cd ${{ github.workspace }}
126
131
cp ${{env.EXTENSION_PATH}}/tests/end-to-end/settings/base.php.dist crowdsec-lib-settings.php
127
132
sed -i -e 's/REPLACE_API_KEY/${{ env.BOUNCER_KEY }}/g' crowdsec-lib-settings.php
@@ -137,10 +142,10 @@ jobs:
137
142
- name : Verify auto_prepend_file directive
138
143
run : |
139
144
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#" ]]
144
149
then
145
150
echo "AUTO PREPEND FILE OK"
146
151
else
0 commit comments