-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/v0.0.1' into main
- Loading branch information
Showing
40 changed files
with
6,421 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version: 2 | ||
updates: | ||
# Maintain dependencies for GitHub Actions | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Super-Linter | ||
|
||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
super-lint: | ||
name: Lint code base | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Get Composer Cache Directory | ||
id: composer-cache | ||
run: | | ||
echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
- name: Cache Composer Downloads | ||
uses: actions/cache@v2 | ||
with: | ||
path: vendor/ | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
- name: Cache PHP dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: vendor | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
|
||
- name: Install PHP dependencies | ||
uses: php-actions/composer@v4 | ||
|
||
- name: Run Super-Linter | ||
uses: github/super-linter@v3 | ||
env: | ||
FILTER_REGEX_INCLUDE: /tmp/lint/src/.* | ||
DEFAULT_BRANCH: main | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
name: Tests | ||
|
||
on: | ||
pull_request: | ||
# push: TODO P3 No tests on push because it causes an unresolved bug (no space left on device). This Smell a race condition. | ||
|
||
jobs: | ||
|
||
integration: | ||
name: Integration | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
php: ['7.2', '7.3', '7.4'] | ||
# TODO P2 PHP 8 Compatibility: Fix: Error: Class "Memcached" not found (https://github.com/crowdsecurity/php-cs-bouncer/runs/1491476055?check_suite_focus=true) | ||
|
||
services: | ||
redis: | ||
image: redis:6.0.0 | ||
ports: | ||
- 6379:6379 | ||
memcached: | ||
image: memcached:1.6.5 | ||
ports: | ||
- 11211:11211 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
# In this step, this action saves a list of existing images, | ||
# the cache is created without them in the post run. | ||
# It also restores the cache if it exists. | ||
- uses: satackey/[email protected] | ||
# Ignore the failure of a step and avoid terminating the job. | ||
continue-on-error: true | ||
|
||
- name: Checkout Crowdsec | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: crowdsecurity/crowdsec | ||
ref: v1.0.0-rc4 | ||
path: ./var/.tmp-crowdsec | ||
|
||
- name: Build Crowdsec 1.0.0 (RC4) Docker image | ||
run: docker build -t crowdsec:v1.0.0-rc4 ./var/.tmp-crowdsec | ||
|
||
- name: Run the crowdsec container | ||
run: docker run -d --name crowdsec -p 8080:8080 -e "DISABLE_AGENT=true" crowdsec:v1.0.0-rc4 | ||
|
||
- name: Add a bouncer to run phpunit tests | ||
run: docker exec crowdsec cscli bouncers add bouncer-php-library -o raw > .bouncer-key | ||
|
||
# TODO P2 Move values to env vars | ||
- name: Add a machine to pilot crowdsec state | ||
run: docker exec crowdsec cscli machines add PhpUnitTestMachine --password PhpUnitTestMachinePassword | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
coverage: "none" | ||
extensions: "json,memcached,redis,xsl,ldap" | ||
ini-values: "memory_limit=-1" | ||
php-version: "${{ matrix.php }}" | ||
tools: pecl | ||
|
||
- name: Display versions | ||
run: | | ||
php -r 'foreach (get_loaded_extensions() as $extension) echo $extension . " " . phpversion($extension) . PHP_EOL;' | ||
php -i | ||
- name: Get Composer Cache Directory | ||
id: composer-cache | ||
run: | | ||
echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
- name: Cache Composer Downloads | ||
uses: actions/cache@v2 | ||
with: | ||
path: vendor/ | ||
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }} | ||
- name: Cache PHP dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: vendor | ||
key: ${{ runner.os }}-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }} | ||
|
||
- name: Install PHP dependencies | ||
uses: php-actions/composer@v4 | ||
|
||
- name: Run tests | ||
run: ./vendor/bin/phpunit --testdox --colors --exclude-group ignore --group integration -v tests/IpVerificationTest.php | ||
env: | ||
LAPI_URL: http://localhost:8080 | ||
MEMCACHED_DSN: memcached://localhost:11211 | ||
REDIS_DSN: redis://localhost:6379 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Composer | ||
/vendor/ | ||
|
||
# Systems | ||
.DS_Store | ||
|
||
# App | ||
/var/ | ||
.bouncer-key | ||
.phpdoc | ||
TODO.md | ||
.php_cs.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
if (!file_exists(__DIR__.'/src')) { | ||
exit(0); | ||
} | ||
|
||
return PhpCsFixer\Config::create() | ||
->setRules([ | ||
'@Symfony' => true, | ||
'@Symfony:risky' => true, | ||
'@PHPUnit75Migration:risky' => true, | ||
'php_unit_dedicate_assert' => ['target' => '5.6'], | ||
'array_syntax' => ['syntax' => 'short'], | ||
'fopen_flags' => false, | ||
'protected_to_private' => false, | ||
'native_constant_invocation' => true, | ||
'combine_nested_dirname' => true, | ||
'list_syntax' => ['syntax' => 'short'], | ||
]) | ||
->setRiskyAllowed(true) | ||
->setFinder( | ||
PhpCsFixer\Finder::create() | ||
->in(__DIR__.'/src') | ||
) | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "crowdsec/bouncer-php-library", | ||
"description": "The official PHP client for the CrowdSec LAPI/CAPI", | ||
"type": "library", | ||
"license": "MIT License", | ||
"minimum-stability": "stable", | ||
"autoload": { | ||
"psr-4": { | ||
"CrowdSecBouncer\\": "src/" | ||
} | ||
}, | ||
"require-dev": { | ||
"symfony/var-dumper": "^5.1", | ||
"phpunit/phpunit": "^8.5", | ||
"predis/predis": "^1.1", | ||
"friendsofphp/php-cs-fixer": "^2.16", | ||
"phpstan/phpstan": "^0.12.58" | ||
}, | ||
"require": { | ||
"symfony/config": "^5.1", | ||
"symfony/cache": "^5.1" | ||
}, | ||
"scripts": { | ||
"lintfix":"vendor/bin/php-cs-fixer fix --verbose --show-progress=estimating --config=.php_cs ./src", | ||
"phpstan":"vendor/bin/phpstan analyse" | ||
} | ||
} |
Oops, something went wrong.