Skip to content

Commit

Permalink
GH actions setup (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
hassansin committed Jul 13, 2021
1 parent 5c315d2 commit c3d6948
Show file tree
Hide file tree
Showing 72 changed files with 189 additions and 216 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Run specs and generate Code Climate report
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: ['7.3', '7.4']
phpunit-versions: ['latest']
include:
- php-versions: '7.2'
phpunit-versions: '8.5.13'
- php-versions: '7.1'
phpunit-versions: '7.5.20'
steps:
- uses: actions/checkout@v2
- name: Setup PHP ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: phpunit:${{ matrix.phpunit-versions }}
coverage: xdebug
- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
- name: Install dependencies
run: composer update --no-interaction --no-progress --prefer-dist
- name: Set ENV for codeclimate (pull_request)
run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/$GITHUB_HEAD_REF:refs/remotes/origin/$GITHUB_HEAD_REF
echo "GIT_BRANCH=$GITHUB_HEAD_REF" >> $GITHUB_ENV
echo "GIT_COMMIT_SHA=$(git rev-parse origin/$GITHUB_HEAD_REF)" >> $GITHUB_ENV
if: github.event_name == 'pull_request'
- name: Set ENV for codeclimate (push)
run: |
echo "GIT_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "GIT_COMMIT_SHA=$GITHUB_SHA" >> $GITHUB_ENV
if: github.event_name == 'push'
- name: Install Code Climate test report
run: |
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
chmod +x ./cc-test-reporter
./cc-test-reporter before-build
- name: Run tests
run: phpunit --coverage-text --coverage-clover ./build/logs/clover.xml
- name: Send Report to Code Climate
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
if: ${{ matrix.php-versions == '7.4' && success() }}
run: ./cc-test-reporter after-build
coding-guidelines:
name: "Coding Guidelines"
runs-on: "ubuntu-latest"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: cs2pr, php-cs-fixer
- name: "Run php-cs-fixer"
run: php-cs-fixer fix --dry-run src
static-analysis:
name: "Static Analysis"
runs-on: "ubuntu-latest"
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: phpstan, cs2pr
- name: Install dependencies
run: composer update --no-interaction --no-progress --prefer-dist
- name: "Run phpstan"
run: phpstan analyse --error-format=checkstyle -l 4 src | cs2pr
36 changes: 0 additions & 36 deletions .travis.yml

This file was deleted.

6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build:
@docker build --build-arg VERSION=7.2 --tag=chartmogulphp72 .
@docker build --build-arg VERSION=7.3 --tag=chartmogulphp73 .
composer:
@$(RUNNER) "composer $(filter-out $@,$(MAKECMDGOALS))"
$(RUNNER) "composer $(filter-out $@,$(MAKECMDGOALS))"
dependencies:
make -s composer update -- --prefer-dist
test:
Expand All @@ -16,9 +16,5 @@ phpunit:
$(RUNNER) "phpunit $(filter-out $@,$(MAKECMDGOALS))"
php:
$(RUNNER) "php $(filter-out $@,$(MAKECMDGOALS))"
cs:
$(RUNNER) "./vendor/bin/phpcs --standard=PSR2 src/"
cbf:
$(RUNNER) "./vendor/bin/phpcbf --standard=PSR2 src/"
%:
@:
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

<p align="center"><code>chartmogul-php</code> provides convenient PHP bindings for <a href="https://dev.chartmogul.com">ChartMogul's API</a>.</p>
<p align="center">
<a href="https://packagist.org/packages/chartmogul/chartmogul-php"><img src="https://badge.fury.io/ph/chartmogul%2Fchartmogul-php.svg" alt="PHP Package" /></a>
<a href="https://travis-ci.org/chartmogul/chartmogul-php"><img src="https://travis-ci.org/chartmogul/chartmogul-php.svg?branch=main" alt="Build Status"/></a>
<a href="https://packagist.org/packages/chartmogul/chartmogul-php" target="_blank"><img class="badge" src="http://poser.pugx.org/chartmogul/chartmogul-php/v"></a>
<a href="#"><img src="https://github.com/chartmogul/chartmogul-php/actions/workflows/test.yml/badge.svg" alt="Build Status"/></a>
</p>
<hr>

Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"require-dev": {
"php-http/mock-client": "^1.3",
"guzzlehttp/psr7": "^1.0",
"http-interop/http-factory-guzzle": "^1.0",
"squizlabs/php_codesniffer": "^3.5"
"http-interop/http-factory-guzzle": "^1.0"
}
}
7 changes: 3 additions & 4 deletions src/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,20 @@
*/
class Account extends AbstractResource
{

use ShowTrait;

/**
* @ignore
*/
const RESOURCE_PATH = '/v1/account';
public const RESOURCE_PATH = '/v1/account';
/**
* @ignore
*/
const RESOURCE_NAME = 'Account';
public const RESOURCE_NAME = 'Account';
/**
* @ignore
*/
const ROOT_KEY = 'account';
public const ROOT_KEY = 'account';

public $name;
public $currency;
Expand Down
2 changes: 0 additions & 2 deletions src/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace ChartMogul;

const DEFAULT_MAX_RETRIES = 20;
Expand All @@ -11,7 +10,6 @@
*/
class Configuration
{

/**
* @var null|Configuration
*/
Expand Down
11 changes: 4 additions & 7 deletions src/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
*/
class Customer extends AbstractResource
{

use CreateTrait;
use AllTrait;
use GetTrait;
Expand All @@ -41,13 +40,13 @@ class Customer extends AbstractResource
/**
* @ignore
*/
const RESOURCE_NAME = 'Customer';
public const RESOURCE_NAME = 'Customer';
/**
* @ignore
*/
const RESOURCE_PATH = '/v1/customers';
const RESOURCE_ID = 'customer_uuid';
const ROOT_KEY = 'entries';
public const RESOURCE_PATH = '/v1/customers';
public const RESOURCE_ID = 'customer_uuid';
public const ROOT_KEY = 'entries';

protected $id;
protected $uuid;
Expand Down Expand Up @@ -124,7 +123,6 @@ public static function findByExternalId($externalId)
*/
public static function search($email, ClientInterface $client = null)
{

$response = (new static([], $client))
->getClient()
->setResourceKey(static::RESOURCE_NAME)
Expand Down Expand Up @@ -242,7 +240,6 @@ public function removeCustomAttributes($custom)
*/
public function updateCustomAttributes($custom)
{

$data = [];
foreach (func_get_args() as $value) {
$data = array_merge($data, $value);
Expand Down
6 changes: 2 additions & 4 deletions src/CustomerInvoices.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@

class CustomerInvoices extends AbstractResource
{

use \ChartMogul\Service\CreateTrait;
use \ChartMogul\Service\AllTrait;

/**
* @ignore
*/
const RESOURCE_PATH = '/v1/import/customers/:customer_uuid/invoices';
public const RESOURCE_PATH = '/v1/import/customers/:customer_uuid/invoices';
/**
* @ignore
*/
const RESOURCE_NAME = 'Invoices';
public const RESOURCE_NAME = 'Invoices';

public $invoices = [];

Expand All @@ -46,7 +45,6 @@ public static function destroyAll($dataSourceUUID, $customerUUID)

protected function setInvoice($index, $invoice)
{

if ($invoice instanceof \ChartMogul\Invoice) {
$this->invoices[$index] = $invoice;
} elseif (is_array($invoice)) {
Expand Down
7 changes: 3 additions & 4 deletions src/Customers.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ class Customers extends AbstractResource
/**
* @ignore
*/
const RESOURCE_NAME = 'Customers';
public const RESOURCE_NAME = 'Customers';
/**
* @ignore
*/
const RESOURCE_PATH = '/v1/customers';
public const RESOURCE_PATH = '/v1/customers';
/**
* @ignore
*/
const ENTRY_CLASS = Customer::class;
public const ENTRY_CLASS = Customer::class;

protected static function getEntryClass()
{
Expand All @@ -46,7 +46,6 @@ protected static function getEntryClass()
*/
public function __construct(array $attr = [], ClientInterface $client = null)
{

parent::__construct($attr, $client);

$this->setEntries($this->entries);
Expand Down
7 changes: 3 additions & 4 deletions src/DataSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
class DataSource extends AbstractResource
{

use CreateTrait;
use AllTrait;
use DestroyTrait;
Expand All @@ -25,17 +24,17 @@ class DataSource extends AbstractResource
/**
* @ignore
*/
const RESOURCE_PATH = '/v1/data_sources';
public const RESOURCE_PATH = '/v1/data_sources';

/**
* @ignore
*/
const RESOURCE_NAME = 'Data Source';
public const RESOURCE_NAME = 'Data Source';

/**
* @ignore
*/
const ROOT_KEY = 'data_sources';
public const ROOT_KEY = 'data_sources';

protected $uuid;
protected $status;
Expand Down
4 changes: 1 addition & 3 deletions src/Exceptions/ChartMogulException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*/
class ChartMogulException extends \RuntimeException implements ResponseException
{

/**
* @var int
*/
Expand All @@ -30,15 +29,14 @@ class ChartMogulException extends \RuntimeException implements ResponseException
*/
public function __construct($message, ResponseInterface $response = null, \Exception $previous = null)
{

if ($response) {
$response->getBody()->rewind();
$this->statusCode = $response->getStatusCode();

$body = $response->getBody()->getContents();
$json = json_decode($body, true);

$this->response = json_last_error() === JSON_ERROR_NONE? $json : $body;
$this->response = json_last_error() === JSON_ERROR_NONE ? $json : $body;
// Adding body to message to get the whole error message to API user.
$message = $message . " Response:\n " . $body;
}
Expand Down
1 change: 0 additions & 1 deletion src/Exceptions/ForbiddenException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@
*/
class ForbiddenException extends ChartMogulException
{

}
1 change: 0 additions & 1 deletion src/Exceptions/NotAllowedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@
*/
class NotAllowedException extends ChartMogulException
{

}
1 change: 0 additions & 1 deletion src/Exceptions/NotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@
*/
class NotFoundException extends ChartMogulException
{

}
1 change: 0 additions & 1 deletion src/Exceptions/ResourceInvalidException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@
*/
class ResourceInvalidException extends ChartMogulException
{

}
1 change: 0 additions & 1 deletion src/Exceptions/SchemaInvalidException.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@
*/
class SchemaInvalidException extends ChartMogulException
{

}
Loading

0 comments on commit c3d6948

Please sign in to comment.