Skip to content

Commit

Permalink
Implement \Closure for exclude (#20)
Browse files Browse the repository at this point in the history
Move log Middleware to separate class instead of Bootstrap inlining
Update dependencies
Replace TravisCI with GitHub Actions
Fix sorting migrations before apply in tests
  • Loading branch information
Horat1us authored Dec 2, 2022
1 parent c6a2107 commit 2036503
Show file tree
Hide file tree
Showing 28 changed files with 1,969 additions and 2,116 deletions.
3 changes: 0 additions & 3 deletions .env.example

This file was deleted.

4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@
/.gitignore export-ignore
/phpstan.neon export-ignore
/yii export-ignore
/LICENSE export-ignore
/.github export-ignore
/phpunit.pgsql.xml export-ignore
/composer.lock export-ignore
81 changes: 81 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: PHP Composer

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ ubuntu-latest ]
php-versions: [ '7.4', '8.1' ]
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
services:
mysql:
image: mysql:5.7
env:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: yii2_guzzle
MYSQL_USER: yii2_guzzle
MYSQL_PASSWORD: 'demo'
MYSQL_ROOT_PASSWORD: 'root_password'
MYSQL_ROOT_HOST: '%'
ports:
- 3311:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
pgsql:
image: postgres:14.1-alpine
env:
POSTGRES_USER: yii2_guzzle
POSTGRES_PASSWORD: yii2_guzzle
ports:
- 5511:5432

steps:
- uses: actions/checkout@v2

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: xdebug

- name: Check PHP Version
run: |
php -v
composer --version
- name: Validate composer.json and composer.lock
run: composer validate

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run PHPCS linter
run: composer run-script lint

- name: Run PHPUnit tests on PostgreSQL
run: composer run-script test-pgsql


- name: Run PHPUnit tests on MySQL with coverage
run: composer run-script cover

- name: Upload coverage to CodeCov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
38 changes: 0 additions & 38 deletions .travis.yml

This file was deleted.

16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Yii2 Guzzle http log
[![Test & Lint](https://github.com/wearesho-team/yii2-guzzle/actions/workflows/php.yml/badge.svg?branch=master)](https://github.com/wearesho-team/yii2-guzzle/actions/workflows/php.yml)
[![Latest Stable Version](https://poser.pugx.org/wearesho-team/yii2-guzzle/v/stable.png)](https://packagist.org/packages/wearesho-team/yii2-guzzle)
[![Total Downloads](https://poser.pugx.org/wearesho-team/yii2-guzzle/downloads.png)](https://packagist.org/packages/wearesho-team/yii2-guzzle)
[![codecov](https://codecov.io/gh/wearesho-team/yii2-guzzle/branch/master/graph/badge.svg)](https://codecov.io/gh/wearesho-team/yii2-guzzle)

Library for storing http queries into database

Expand All @@ -13,13 +17,19 @@ composer require wearesho-team/yii2-guzzle
<?php

use Wearesho\Yii\Guzzle;
use Psr\Http\Message\RequestInterface;

return [
'bootstrap' => [
'http-log' => [
'class' => Guzzle\Bootstrap::class,
// Add regular expression if you need exclude their from logging
'exclude' => ['/^.*(google).*$/iu'],
// Logs exclude rules
'exclude' => [
// url regular expression
'/^.*(google).*$/iu',
// or closure (return true if you don't need to log request)
fn(Message\RequestInterface $request): bool => $request->getUri()->getHost() === 'zsu.gov.ua/'
],
// Guzzle client configuration settings
'config' => [
'timeout' => 10,
Expand All @@ -32,7 +42,7 @@ return [
3. Use [Guzzle\Log\Request](./src/Log/Request.php), [Guzzle\Log\Response](./src/Log/Response.php), [Guzzle\Log\Exception](./src/Log/Exception.php) to find logs

Note: for not UTF-8 request or response body (for example, files)
`(invalid UTF-8 bytes)` will be saved.
`(invalid UTF-8 bytes)` will be saved.

## Contributors
- [Alexander <horat1us> Letnikow](mailto:[email protected])
Expand Down
30 changes: 18 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
"description": "Container configuration with requests logs for Yii2",
"type": "library",
"require": {
"php": ">=7.4",
"guzzlehttp/guzzle": "^6.3",
"horat1us/yii2-carbon-behavior": "^1.0",
"horat1us/yii2-migration-bootstrap": "^1.2",
"horat1us/yii2-validation-exception": "^1.0",
"yiisoft/yii2": "^2.0.15"
"php": "^7.4 | ^8.0",
"guzzlehttp/guzzle": "^6.5.8 || ^7.4.5",
"horat1us/yii2-carbon-behavior": "^1.2",
"horat1us/yii2-migration-bootstrap": "^1.3",
"horat1us/yii2-validation-exception": "^1.1",
"yiisoft/yii2": "^2.0.47"
},
"require-dev": {
"ext-json": "*",
"horat1us/yii2-asset-free": "^1.0",
"horat1us/yii2-phpunit": "0.0.5",
"squizlabs/php_codesniffer": "^3.5"
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.7"
},
"license": "MIT",
"authors": [
Expand All @@ -28,13 +29,18 @@
"sort-packages": true,
"platform": {
"php": "7.4"
},
"allow-plugins": {
"yiisoft/yii2-composer": true
}
},
"scripts": {
"lint": "./vendor/bin/phpcs --standard=PSR2 ./src ./tests",
"phpcbf": "./vendor/bin/phpcbf --standard=PSR2 ./src ./tests",
"test": "./vendor/bin/phpunit",
"cover": "./vendor/bin/phpunit --coverage-clover=coverage.xml"
"lint": "./vendor/bin/phpcs --standard=PSR12 ./src ./tests",
"phpcbf": "./vendor/bin/phpcbf --standard=PSR12 ./src ./tests",
"cover": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-clover coverage.xml",
"test-mysql": "./vendor/bin/phpunit --configuration phpunit.xml",
"test-pgsql": "./vendor/bin/phpunit --configuration phpunit.pgsql.xml",
"test": "composer run-script test-mysql && composer run-script test-pgsql"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit 2036503

Please sign in to comment.