Skip to content

Commit 9f22e07

Browse files
Merge pull request #124 from julienloizelet/feat/use-cache-tags-configs
Feat/use cache tags configs
2 parents 6aa4014 + 232aaba commit 9f22e07

File tree

13 files changed

+136
-120
lines changed

13 files changed

+136
-120
lines changed

.github/workflows/coding-standards.yml

+26-26
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ on:
1212
description: Generate PHPUNIT Code Coverage report
1313
default: false
1414

15+
permissions:
16+
contents: read
17+
18+
env:
19+
# Allow ddev get to use a GitHub token to prevent rate limiting by tests
20+
DDEV_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
1522
jobs:
1623
coding-standards:
1724
strategy:
@@ -23,38 +30,33 @@ jobs:
2330
runs-on: ubuntu-latest
2431
if: ${{ !contains(github.event.head_commit.message, 'chore(') }}
2532
env:
26-
EXTENSION_PATH: "my-own-modules/crowdsec-php-lib"
33+
EXTENSION_PATH: "my-code/crowdsec-bouncer-lib"
2734

2835
steps:
29-
- name: Clone DDEV files
30-
uses: actions/checkout@v3
31-
with:
32-
path: .ddev
33-
repository: julienloizelet/ddev-php
34-
ref: "main"
3536

3637
- name: Install DDEV
37-
env:
38-
DDEV_VERSION: v1.21.4
38+
# @see https://ddev.readthedocs.io/en/stable/#installationupgrade-script-linux-and-macos-armarm64-and-amd64-architectures
3939
run: |
40-
# @see https://ddev.readthedocs.io/en/stable/#installationupgrade-script-linux-and-macos-armarm64-and-amd64-architectures
41-
sudo apt-get -qq update
42-
sudo apt-get -qq -y install libnss3-tools
43-
curl -LO https://raw.githubusercontent.com/drud/ddev/master/scripts/install_ddev.sh
44-
bash install_ddev.sh ${{env.DDEV_VERSION}}
40+
curl -fsSL https://apt.fury.io/drud/gpg.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/ddev.gpg > /dev/null
41+
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
42+
sudo apt-get -q update
43+
sudo apt-get -q -y install libnss3-tools ddev
44+
mkcert -install
4545
ddev config global --instrumentation-opt-in=false --omit-containers=dba,ddev-ssh-agent
46-
rm install_ddev.sh
4746
48-
- name: Set PHP_VERSION_CODE env
49-
# used in some directory path and conventional file naming
50-
# Example : 7.4 => 74
51-
run: |
52-
echo "PHP_VERSION_CODE=$(echo php${{ matrix.php-version }} | sed 's/\.//g' )" >> $GITHUB_ENV
47+
- name: Create empty PHP DDEV project
48+
run: ddev config --project-type=php --project-name=crowdsec-bouncer-lib --php-version=${{ matrix.php-version }}
5349

50+
- name: Add Redis, Memcached and Crowdsec
51+
run: |
52+
ddev get ddev/ddev-redis
53+
ddev get ddev/ddev-memcached
54+
# override redis.conf
55+
ddev get julienloizelet/ddev-tools
56+
ddev get julienloizelet/ddev-crowdsec-php
5457
55-
- name: Start DDEV with PHP ${{ matrix.php-version }}
58+
- name: Start DDEV
5659
run: |
57-
cp .ddev/config_overrides/config.${{ env.PHP_VERSION_CODE }}.yaml .ddev/config.${{ env.PHP_VERSION_CODE }}.yaml
5860
ddev start
5961
6062
- name: Some DEBUG information
@@ -66,7 +68,7 @@ jobs:
6668
- name: Clone PHP lib Crowdsec files
6769
uses: actions/checkout@v3
6870
with:
69-
path: my-own-modules/crowdsec-php-lib
71+
path: my-code/crowdsec-bouncer-lib
7072

7173
- name: Install CrowdSec lib dependencies
7274
run: ddev composer update --working-dir ./${{env.EXTENSION_PATH}}
@@ -89,10 +91,8 @@ jobs:
8991
- name: Prepare for Code Coverage
9092
if: github.event.inputs.coverage_report == 'true'
9193
run: |
92-
cp .ddev/additional_docker_compose/docker-compose.crowdsec.yaml .ddev/docker-compose.crowdsec.yaml
9394
mkdir ${{ github.workspace }}/cfssl
94-
cp -r .ddev/custom_files/crowdsec/cfssl/* ${{ github.workspace }}/cfssl
95-
ddev restart
95+
cp -r .ddev/okaeli-add-on/custom_files/crowdsec/cfssl/* ${{ github.workspace }}/cfssl
9696
ddev maxmind-download DEFAULT GeoLite2-City /var/www/html/${{env.EXTENSION_PATH}}/tests
9797
ddev maxmind-download DEFAULT GeoLite2-Country /var/www/html/${{env.EXTENSION_PATH}}/tests
9898
cd ${{env.EXTENSION_PATH}}/tests

.github/workflows/test-suite.yml

+38-33
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ on:
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+
1017
jobs:
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: |
@@ -74,7 +77,7 @@ jobs:
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}}
@@ -89,6 +92,8 @@ jobs:
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

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ The [public API](https://semver.org/spec/v2.0.0.html#spec-item-1) of this librar
99

1010
---
1111

12+
## [1.3.0](https://github.com/crowdsecurity/php-cs-bouncer/releases/tag/v1.3.0) - 2023-03-24
13+
[_Compare with previous release_](https://github.com/crowdsecurity/php-cs-bouncer/compare/v1.2.0...v1.3.0)
14+
15+
16+
### Changed
17+
- Use `crowdsec/remediation-engine` `^3.1.1` instead of `^3.0.0`
18+
- Use Redis and PhpFiles cache without cache tags
19+
20+
---
21+
1222

1323
## [1.2.0](https://github.com/crowdsecurity/php-cs-bouncer/releases/tag/v1.2.0) - 2023-03-09
1424
[_Compare with previous release_](https://github.com/crowdsecurity/php-cs-bouncer/compare/v1.1.1...v1.2.0)

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
],
4141
"require": {
4242
"php": ">=7.2.5",
43-
"crowdsec/remediation-engine": "^3.0.0",
43+
"crowdsec/remediation-engine": "^3.1.1",
4444
"symfony/config": "^4.4.27 || ^5.2 || ^6.0",
4545
"twig/twig": "^3.4.2",
4646
"gregwar/captcha": "^1.1",

0 commit comments

Comments
 (0)