mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-11-29 08:26:06 +03:00
Updating workflows and add psalm (#741)
* Updating workflows and add psalm * Normalize composer * Fixed CS
This commit is contained in:
parent
d8ae00d23c
commit
12ed8aae43
16
.github/main.workflow
vendored
16
.github/main.workflow
vendored
@ -1,16 +0,0 @@
|
|||||||
workflow "Main" {
|
|
||||||
on = "push"
|
|
||||||
resolves = ["Roave BC Check", "PHPStan"]
|
|
||||||
}
|
|
||||||
|
|
||||||
action "Roave BC Check" {
|
|
||||||
uses = "docker://nyholm/roave-bc-check-ga"
|
|
||||||
secrets = ["GITHUB_TOKEN"]
|
|
||||||
args = ""
|
|
||||||
}
|
|
||||||
|
|
||||||
action "PHPStan" {
|
|
||||||
uses = "docker://oskarstark/phpstan-ga"
|
|
||||||
secrets = ["GITHUB_TOKEN"]
|
|
||||||
args = "analyse"
|
|
||||||
}
|
|
48
.github/workflows/php.yml
vendored
48
.github/workflows/php.yml
vendored
@ -1,50 +1,54 @@
|
|||||||
name: PHP Composer
|
name: Tests
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push: ~
|
||||||
branches: [ 'master', '2.x' ]
|
pull_request: ~
|
||||||
pull_request:
|
|
||||||
branches: [ 'master', '2.x' ]
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
php:
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
# https://github.com/marketplace/actions/setup-php-action#github-hosted-runners
|
|
||||||
operating-system: [ 'ubuntu-latest' ]
|
|
||||||
php-versions: [ '7.3', '7.4', '8.0' ]
|
php-versions: [ '7.3', '7.4', '8.0' ]
|
||||||
|
|
||||||
runs-on: ${{ matrix.operating-system }}
|
runs-on: 'ubuntu-latest'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Validate composer.json and composer.lock
|
|
||||||
run: composer validate
|
|
||||||
|
|
||||||
- name: Setup PHP
|
- name: Setup PHP
|
||||||
uses: shivammathur/setup-php@v2
|
uses: shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
tools: phpunit, phpstan
|
tools: none
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: composer install --prefer-dist --no-progress --no-suggest
|
run: composer install --prefer-dist --no-progress --no-suggest
|
||||||
|
|
||||||
- name: PHP Unit Tests
|
- name: PHP Unit Tests
|
||||||
run: composer test
|
run: vendor/bin/phpunit
|
||||||
|
|
||||||
- name: PHP Stan
|
lowest:
|
||||||
if: matrix.php-versions == '7.3'
|
name: Lowest deps
|
||||||
run: |
|
runs-on: ubuntu-latest
|
||||||
phpstan --version
|
steps:
|
||||||
phpstan analyse
|
- name: Set up PHP
|
||||||
|
uses: shivammathur/setup-php@2.9.0
|
||||||
|
with:
|
||||||
|
php-version: 7.4
|
||||||
|
coverage: pcov
|
||||||
|
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Download dependencies
|
||||||
|
run: composer update --no-interaction --prefer-dist --optimize-autoloader --prefer-stable --prefer-lowest
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.xml
|
||||||
|
|
||||||
- name: Scrunitizer CI
|
- name: Scrunitizer CI
|
||||||
if: matrix.php-versions == '7.3'
|
|
||||||
run: |
|
run: |
|
||||||
wget https://scrutinizer-ci.com/ocular.phar
|
wget https://scrutinizer-ci.com/ocular.phar
|
||||||
php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml
|
php ocular.phar code-coverage:upload --format=php-clover coverage.xml
|
||||||
|
88
.github/workflows/static.yml
vendored
Normal file
88
.github/workflows/static.yml
vendored
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
name: Static analysis
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request: ~
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
phpstan:
|
||||||
|
name: PHPStan
|
||||||
|
runs-on: Ubuntu-20.04
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Set up PHP
|
||||||
|
uses: shivammathur/setup-php@2.9.0
|
||||||
|
with:
|
||||||
|
php-version: '7.4'
|
||||||
|
coverage: none
|
||||||
|
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Download dependencies
|
||||||
|
run: composer update --no-interaction --prefer-dist
|
||||||
|
|
||||||
|
- name: PHPStan
|
||||||
|
uses: docker://oskarstark/phpstan-ga:0.12.70
|
||||||
|
with:
|
||||||
|
entrypoint: /composer/vendor/bin/phpstan
|
||||||
|
args: analyze --no-progress
|
||||||
|
|
||||||
|
php-cs-fixer:
|
||||||
|
name: PHP-CS-Fixer
|
||||||
|
runs-on: Ubuntu-20.04
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: PHP-CS-Fixer
|
||||||
|
uses: docker://oskarstark/php-cs-fixer-ga:2.18.2
|
||||||
|
with:
|
||||||
|
args: --dry-run --diff-format udiff
|
||||||
|
|
||||||
|
psalm:
|
||||||
|
name: Psalm
|
||||||
|
runs-on: Ubuntu-20.04
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Psalm
|
||||||
|
uses: docker://vimeo/psalm-github-actions:4.4.1
|
||||||
|
with:
|
||||||
|
args: --no-progress --show-info=false --stats
|
||||||
|
|
||||||
|
roave-bc-check:
|
||||||
|
name: Roave BC Check
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Roave BC Check
|
||||||
|
uses: docker://nyholm/roave-bc-check-ga
|
||||||
|
|
||||||
|
composer-normalize:
|
||||||
|
name: Composer Normalize
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up PHP
|
||||||
|
uses: shivammathur/setup-php@2.9.0
|
||||||
|
with:
|
||||||
|
php-version: 7.4
|
||||||
|
coverage: none
|
||||||
|
tools: composer-normalize
|
||||||
|
|
||||||
|
- name: Validate composer.json
|
||||||
|
run: composer validate
|
||||||
|
|
||||||
|
- name: Normalize composer.json
|
||||||
|
run: composer-normalize --dry-run
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -6,3 +6,5 @@ phpunit.phar
|
|||||||
phpunit.xml
|
phpunit.xml
|
||||||
modd.conf
|
modd.conf
|
||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
|
.php_cs.cache
|
||||||
|
.phpunit.result.cache
|
||||||
|
@ -1,19 +1,35 @@
|
|||||||
{
|
{
|
||||||
"name": "mailgun/mailgun-php",
|
"name": "mailgun/mailgun-php",
|
||||||
"description": "The Mailgun SDK provides methods for all API functions.",
|
"description": "The Mailgun SDK provides methods for all API functions.",
|
||||||
|
"license": "MIT",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Travis Swientek",
|
||||||
|
"email": "travis@mailgunhq.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.3 || ^8.0",
|
"php": "^7.3 || ^8.0",
|
||||||
"psr/http-client": "^1.0.1",
|
|
||||||
"php-http/multipart-stream-builder": "^1.1.2",
|
|
||||||
"php-http/client-common": "^2.2.1",
|
"php-http/client-common": "^2.2.1",
|
||||||
"php-http/discovery": "^1.9.1",
|
"php-http/discovery": "^1.9.1",
|
||||||
|
"php-http/multipart-stream-builder": "^1.1.2",
|
||||||
|
"psr/http-client": "^1.0.1",
|
||||||
"webmozart/assert": "^1.9.1"
|
"webmozart/assert": "^1.9.1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^9.3",
|
"nyholm/nsa": "^1.2.1",
|
||||||
"php-http/guzzle7-adapter": "^0.1.1",
|
|
||||||
"nyholm/psr7": "^1.3.1",
|
"nyholm/psr7": "^1.3.1",
|
||||||
"nyholm/nsa": "^1.2.1"
|
"php-http/guzzle7-adapter": "^0.1.1",
|
||||||
|
"phpunit/phpunit": "^9.3"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"guzzlehttp/psr7": "PSR-7 message implementation that also provides common utility methods",
|
||||||
|
"php-http/curl-client": "cURL client for PHP-HTTP"
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "3.0-dev"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
@ -24,25 +40,5 @@
|
|||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Mailgun\\Tests\\": "tests/"
|
"Mailgun\\Tests\\": "tests/"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"suggest": {
|
|
||||||
"php-http/curl-client": "cURL client for PHP-HTTP",
|
|
||||||
"guzzlehttp/psr7": "PSR-7 message implementation that also provides common utility methods"
|
|
||||||
},
|
|
||||||
"license": "MIT",
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Travis Swientek",
|
|
||||||
"email": "travis@mailgunhq.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"scripts": {
|
|
||||||
"test": "vendor/bin/phpunit",
|
|
||||||
"test-coverage": "vendor/bin/phpunit --coverage-text --coverage-clover=build/coverage.xml"
|
|
||||||
},
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "3.0-dev"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
88
psalm.baseline.xml
Normal file
88
psalm.baseline.xml
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<files psalm-version="4.4.1@9fd7a7d885b3a216cff8dec9d8c21a132f275224">
|
||||||
|
<file src="src/Api/Domain.php">
|
||||||
|
<PossiblyUndefinedVariable occurrences="1">
|
||||||
|
<code>$params</code>
|
||||||
|
</PossiblyUndefinedVariable>
|
||||||
|
<RedundantCondition occurrences="5">
|
||||||
|
<code>boolean</code>
|
||||||
|
<code>boolean</code>
|
||||||
|
<code>nullOrString</code>
|
||||||
|
<code>stringNotEmpty</code>
|
||||||
|
<code>stringNotEmpty</code>
|
||||||
|
</RedundantCondition>
|
||||||
|
<TypeDoesNotContainNull occurrences="1">
|
||||||
|
<code>nullOrString</code>
|
||||||
|
</TypeDoesNotContainNull>
|
||||||
|
</file>
|
||||||
|
<file src="src/Api/HttpApi.php">
|
||||||
|
<ParamNameMismatch occurrences="1">
|
||||||
|
<code>$class</code>
|
||||||
|
</ParamNameMismatch>
|
||||||
|
</file>
|
||||||
|
<file src="src/Api/Ip.php">
|
||||||
|
<RedundantCondition occurrences="1">
|
||||||
|
<code>boolean</code>
|
||||||
|
</RedundantCondition>
|
||||||
|
</file>
|
||||||
|
<file src="src/Api/MailingList.php">
|
||||||
|
<PossiblyNullArgument occurrences="1">
|
||||||
|
<code>$this->hydrator</code>
|
||||||
|
</PossiblyNullArgument>
|
||||||
|
<RedundantCondition occurrences="1">
|
||||||
|
<code>isArray</code>
|
||||||
|
</RedundantCondition>
|
||||||
|
</file>
|
||||||
|
<file src="src/Api/MailingList/Member.php">
|
||||||
|
<RedundantCondition occurrences="2">
|
||||||
|
<code>isArray</code>
|
||||||
|
<code>isArray</code>
|
||||||
|
</RedundantCondition>
|
||||||
|
</file>
|
||||||
|
<file src="src/Api/Message.php">
|
||||||
|
<RedundantCondition occurrences="3">
|
||||||
|
<code>nullOrIsArray</code>
|
||||||
|
<code>string</code>
|
||||||
|
<code>string</code>
|
||||||
|
</RedundantCondition>
|
||||||
|
<TypeDoesNotContainNull occurrences="1">
|
||||||
|
<code>nullOrIsArray</code>
|
||||||
|
</TypeDoesNotContainNull>
|
||||||
|
</file>
|
||||||
|
<file src="src/Api/Pagination.php">
|
||||||
|
<PossiblyNullArgument occurrences="4">
|
||||||
|
<code>$response->getFirstUrl()</code>
|
||||||
|
<code>$response->getLastUrl()</code>
|
||||||
|
<code>$response->getNextUrl()</code>
|
||||||
|
<code>$response->getPreviousUrl()</code>
|
||||||
|
</PossiblyNullArgument>
|
||||||
|
</file>
|
||||||
|
<file src="src/Api/Route.php">
|
||||||
|
<RedundantCondition occurrences="1">
|
||||||
|
<code>isArray</code>
|
||||||
|
</RedundantCondition>
|
||||||
|
</file>
|
||||||
|
<file src="src/Api/Suppression/Complaint.php">
|
||||||
|
<PossiblyUndefinedVariable occurrences="1">
|
||||||
|
<code>$params</code>
|
||||||
|
</PossiblyUndefinedVariable>
|
||||||
|
</file>
|
||||||
|
<file src="src/Assert.php">
|
||||||
|
<MissingImmutableAnnotation occurrences="1">
|
||||||
|
<code>protected static function reportInvalidArgument($message)</code>
|
||||||
|
</MissingImmutableAnnotation>
|
||||||
|
</file>
|
||||||
|
<file src="src/HttpClient/Plugin/HistoryTrait.php">
|
||||||
|
<UnrecognizedStatement occurrences="1"/>
|
||||||
|
</file>
|
||||||
|
<file src="src/Mailgun.php">
|
||||||
|
<PossiblyNullArgument occurrences="1">
|
||||||
|
<code>$this->apiKey</code>
|
||||||
|
</PossiblyNullArgument>
|
||||||
|
</file>
|
||||||
|
<file src="src/Message/BatchMessage.php">
|
||||||
|
<PossiblyUndefinedMethod occurrences="1">
|
||||||
|
<code>getId</code>
|
||||||
|
</PossiblyUndefinedMethod>
|
||||||
|
</file>
|
||||||
|
</files>
|
16
psalm.xml
Normal file
16
psalm.xml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<psalm
|
||||||
|
errorLevel="3"
|
||||||
|
resolveFromConfigFile="true"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns="https://getpsalm.org/schema/config"
|
||||||
|
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
|
||||||
|
errorBaseline="psalm.baseline.xml"
|
||||||
|
>
|
||||||
|
<projectFiles>
|
||||||
|
<directory name="src" />
|
||||||
|
<ignoreFiles>
|
||||||
|
<directory name="vendor" />
|
||||||
|
</ignoreFiles>
|
||||||
|
</projectFiles>
|
||||||
|
</psalm>
|
@ -19,7 +19,7 @@ class UnsubscribeTest extends BaseModelTest
|
|||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
*/
|
*/
|
||||||
public function it_gets_empty_list_of_tags_by_default()
|
public function itGetsEmptyListOfTagsByDefault()
|
||||||
{
|
{
|
||||||
$unsubscribe = Unsubscribe::create(['address' => 'dummy@mailgun.net']);
|
$unsubscribe = Unsubscribe::create(['address' => 'dummy@mailgun.net']);
|
||||||
$this->assertEquals([], $unsubscribe->getTags());
|
$this->assertEquals([], $unsubscribe->getTags());
|
||||||
@ -28,7 +28,7 @@ class UnsubscribeTest extends BaseModelTest
|
|||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
*/
|
*/
|
||||||
public function it_gets_tags()
|
public function itGetsTags()
|
||||||
{
|
{
|
||||||
$tags = ['tag1', 'tag2'];
|
$tags = ['tag1', 'tag2'];
|
||||||
$unsubscribe = Unsubscribe::create(['address' => 'dummy@mailgun.net', 'tags' => $tags]);
|
$unsubscribe = Unsubscribe::create(['address' => 'dummy@mailgun.net', 'tags' => $tags]);
|
||||||
|
Loading…
Reference in New Issue
Block a user