Skip to content

Commit

Permalink
Merge pull request #124 from julienloizelet/feat/use-cache-tags-configs
Browse files Browse the repository at this point in the history
Feat/use cache tags configs
  • Loading branch information
julienloizelet authored Mar 24, 2023
2 parents 6aa4014 + 232aaba commit 9f22e07
Show file tree
Hide file tree
Showing 13 changed files with 136 additions and 120 deletions.
52 changes: 26 additions & 26 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ on:
description: Generate PHPUNIT Code Coverage report
default: false

permissions:
contents: read

env:
# Allow ddev get to use a GitHub token to prevent rate limiting by tests
DDEV_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
coding-standards:
strategy:
Expand All @@ -23,38 +30,33 @@ jobs:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.head_commit.message, 'chore(') }}
env:
EXTENSION_PATH: "my-own-modules/crowdsec-php-lib"
EXTENSION_PATH: "my-code/crowdsec-bouncer-lib"

steps:
- name: Clone DDEV files
uses: actions/checkout@v3
with:
path: .ddev
repository: julienloizelet/ddev-php
ref: "main"

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

- name: Add Redis, Memcached and Crowdsec
run: |
ddev get ddev/ddev-redis
ddev get ddev/ddev-memcached
# override redis.conf
ddev get julienloizelet/ddev-tools
ddev get julienloizelet/ddev-crowdsec-php
- name: Start DDEV with PHP ${{ matrix.php-version }}
- name: Start DDEV
run: |
cp .ddev/config_overrides/config.${{ env.PHP_VERSION_CODE }}.yaml .ddev/config.${{ env.PHP_VERSION_CODE }}.yaml
ddev start
- name: Some DEBUG information
Expand All @@ -66,7 +68,7 @@ jobs:
- name: Clone PHP lib Crowdsec files
uses: actions/checkout@v3
with:
path: my-own-modules/crowdsec-php-lib
path: my-code/crowdsec-bouncer-lib

- name: Install CrowdSec lib dependencies
run: ddev composer update --working-dir ./${{env.EXTENSION_PATH}}
Expand All @@ -89,10 +91,8 @@ jobs:
- name: Prepare for Code Coverage
if: github.event.inputs.coverage_report == 'true'
run: |
cp .ddev/additional_docker_compose/docker-compose.crowdsec.yaml .ddev/docker-compose.crowdsec.yaml
mkdir ${{ github.workspace }}/cfssl
cp -r .ddev/custom_files/crowdsec/cfssl/* ${{ github.workspace }}/cfssl
ddev restart
cp -r .ddev/okaeli-add-on/custom_files/crowdsec/cfssl/* ${{ github.workspace }}/cfssl
ddev maxmind-download DEFAULT GeoLite2-City /var/www/html/${{env.EXTENSION_PATH}}/tests
ddev maxmind-download DEFAULT GeoLite2-Country /var/www/html/${{env.EXTENSION_PATH}}/tests
cd ${{env.EXTENSION_PATH}}/tests
Expand Down
71 changes: 38 additions & 33 deletions .github/workflows/test-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ on:
- '**.md'
workflow_dispatch:

permissions:
contents: read

env:
# Allow ddev get to use a GitHub token to prevent rate limiting by tests
DDEV_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
test-suite:
strategy:
Expand All @@ -18,46 +25,42 @@ jobs:
runs-on: ubuntu-latest
if: ${{ !contains(github.event.head_commit.message, 'chore(') }}
env:
EXTENSION_PATH: "my-own-modules/crowdsec-php-lib"
EXTENSION_PATH: "my-code/crowdsec-bouncer-lib"
DDEV_PROJECT: "crowdsec-bouncer-lib"
JP_TEST_IP: "210.249.74.42"
IPV6_TEST_IP: "2001:0db8:0000:85a3:0000:0000:ac1f:8001"
IPV6_TEST_PROXY_IP: "2345:0425:2CA1:0000:0000:0567:5673:23b5"

steps:
- name: Clone DDEV files
uses: actions/checkout@v3
with:
path: .ddev
repository: julienloizelet/ddev-php
ref: "main"

- name: Install DDEV
env:
DDEV_VERSION: v1.21.4
# @see https://ddev.readthedocs.io/en/stable/#installationupgrade-script-linux-and-macos-armarm64-and-amd64-architectures
run: |
# @see https://ddev.readthedocs.io/en/stable/#installationupgrade-script-linux-and-macos-armarm64-and-amd64-architectures
sudo apt-get -qq update
sudo apt-get -qq -y install libnss3-tools
curl -LO https://raw.githubusercontent.com/drud/ddev/master/scripts/install_ddev.sh
bash install_ddev.sh ${{env.DDEV_VERSION}}
curl -fsSL https://apt.fury.io/drud/gpg.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/ddev.gpg > /dev/null
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
sudo apt-get -q update
sudo apt-get -q -y install libnss3-tools ddev
mkcert -install
ddev config global --instrumentation-opt-in=false --omit-containers=dba,ddev-ssh-agent
rm install_ddev.sh
- name: Set PHP_VERSION_CODE env
# used in some directory path and conventional file naming
# Example : 7.4 => 74
- name: Create empty PHP DDEV project
run: ddev config --project-type=php --project-name=${{env.DDEV_PROJECT}} --php-version=${{ matrix.php-version }}

- name: Add Redis, Memcached and Crowdsec
run: |
echo "PHP_VERSION_CODE=$(echo php${{ matrix.php-version }} | sed 's/\.//g' )" >> $GITHUB_ENV
ddev get ddev/ddev-redis
ddev get ddev/ddev-memcached
# override redis.conf
ddev get julienloizelet/ddev-tools
ddev get julienloizelet/ddev-crowdsec-php
ddev get julienloizelet/ddev-playwright
- name: Start DDEV
run: |
ddev start
- name: Start DDEV with PHP ${{ matrix.php-version }}
run: |
cp .ddev/config_overrides/config.${{ env.PHP_VERSION_CODE }}.yaml .ddev/config.${{ env.PHP_VERSION_CODE }}.yaml
cp .ddev/additional_docker_compose/docker-compose.crowdsec.yaml .ddev/docker-compose.crowdsec.yaml
cp .ddev/additional_docker_compose/docker-compose.playwright.yaml .ddev/docker-compose.playwright.yaml
mkdir ${{ github.workspace }}/cfssl
cp -r .ddev/custom_files/crowdsec/cfssl/* ${{ github.workspace }}/cfssl
ddev start
run: ddev start

- name: Set BOUNCER_KEY and PROXY_IP env
run: |
Expand All @@ -74,7 +77,7 @@ jobs:
- name: Clone PHP lib Crowdsec files
uses: actions/checkout@v3
with:
path: my-own-modules/crowdsec-php-lib
path: my-code/crowdsec-bouncer-lib

- name: Validate composer.json
run: ddev composer validate --strict --working-dir ./${{env.EXTENSION_PATH}}
Expand All @@ -89,6 +92,8 @@ jobs:
- name: Prepare PHP Integration and end-to-end tests
run: |
mkdir ${{ github.workspace }}/cfssl
cp -r .ddev/okaeli-add-on/custom_files/crowdsec/cfssl/* ${{ github.workspace }}/cfssl
ddev maxmind-download DEFAULT GeoLite2-City /var/www/html/${{env.EXTENSION_PATH}}/tests
ddev maxmind-download DEFAULT GeoLite2-Country /var/www/html/${{env.EXTENSION_PATH}}/tests
cd ${{env.EXTENSION_PATH}}/tests
Expand Down Expand Up @@ -121,7 +126,7 @@ jobs:
- name: Prepare Standalone Bouncer end-to-end tests
run: |
cd ${{ github.workspace }}/.ddev
ddev nginx-config custom_files/crowdsec-prepend-nginx-site.conf
ddev nginx-config okaeli-add-on/native/custom_files/crowdsec/crowdsec-prepend-nginx-site.conf
cd ${{ github.workspace }}
cp ${{env.EXTENSION_PATH}}/tests/end-to-end/settings/base.php.dist crowdsec-lib-settings.php
sed -i -e 's/REPLACE_API_KEY/${{ env.BOUNCER_KEY }}/g' crowdsec-lib-settings.php
Expand All @@ -137,10 +142,10 @@ jobs:
- name: Verify auto_prepend_file directive
run: |
cd ${{ github.workspace }}
cp .ddev/custom_files/phpinfo.php ${{env.EXTENSION_PATH}}/scripts/public/phpinfo.php
curl -v https://${{ env.PHP_VERSION_CODE }}.ddev.site/${{env.EXTENSION_PATH}}/scripts/public/phpinfo.php
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' '#')
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#" ]]
cp .ddev/okaeli-add-on/common/custom_files/phpinfo.php ${{env.EXTENSION_PATH}}/scripts/public/phpinfo.php
curl -v https://${{env.DDEV_PROJECT}}.ddev.site/${{env.EXTENSION_PATH}}/scripts/public/phpinfo.php
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' '#')
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#" ]]
then
echo "AUTO PREPEND FILE OK"
else
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ The [public API](https://semver.org/spec/v2.0.0.html#spec-item-1) of this librar

---

## [1.3.0](https://github.com/crowdsecurity/php-cs-bouncer/releases/tag/v1.3.0) - 2023-03-24
[_Compare with previous release_](https://github.com/crowdsecurity/php-cs-bouncer/compare/v1.2.0...v1.3.0)


### Changed
- Use `crowdsec/remediation-engine` `^3.1.1` instead of `^3.0.0`
- Use Redis and PhpFiles cache without cache tags

---


## [1.2.0](https://github.com/crowdsecurity/php-cs-bouncer/releases/tag/v1.2.0) - 2023-03-09
[_Compare with previous release_](https://github.com/crowdsecurity/php-cs-bouncer/compare/v1.1.1...v1.2.0)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
],
"require": {
"php": ">=7.2.5",
"crowdsec/remediation-engine": "^3.0.0",
"crowdsec/remediation-engine": "^3.1.1",
"symfony/config": "^4.4.27 || ^5.2 || ^6.0",
"twig/twig": "^3.4.2",
"gregwar/captcha": "^1.1",
Expand Down
Loading

0 comments on commit 9f22e07

Please sign in to comment.