Skip to content

Commit

Permalink
feat: Add CI
Browse files Browse the repository at this point in the history
  • Loading branch information
devtronic committed Jul 31, 2024
1 parent 2585561 commit d2a5b89
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 19 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: PHP Composer

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Setup PHP with Xdebug
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
coverage: xdebug

- name: Validate composer.json and composer.lock
run: composer validate --strict

- 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
run: composer install --prefer-dist --no-progress

- name: Run test suite
run: composer run-script test

- name: Run SCA
run: composer run-script phpstan

- name: Run CS
run: composer run-script fix-cs:dry-run
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"psr/http-message": "^2.0",
"jms/serializer": "^3.30.0",
"mintware-de/streams": "^3.0",
"ext-json": "*",
"mark-gerarts/auto-mapper-plus": "^1.4",
"ext-json": "*",
"ext-curl": "*"
},
"require-dev": {
Expand Down Expand Up @@ -39,12 +39,12 @@
"minimum-stability": "stable",
"scripts": {
"fix-cs": [
"./vendor/bin/php-cs-fixer fix ./src/ --using-cache=no --rules=@PSR2",
"./vendor/bin/php-cs-fixer fix ./tests/ --using-cache=no --rules=@PSR2"
"./vendor/bin/php-cs-fixer fix ./src/ --using-cache=no --rules=@PSR12",
"./vendor/bin/php-cs-fixer fix ./tests/ --using-cache=no --rules=@PSR12"
],
"fix-cs:dry-run": [
"./vendor/bin/php-cs-fixer fix ./src/ --using-cache=no --rules=@PSR2 --dry-run",
"./vendor/bin/php-cs-fixer fix ./tests/ --using-cache=no --rules=@PSR2 --dry-run"
"./vendor/bin/php-cs-fixer fix ./src/ --using-cache=no --rules=@PSR12 --dry-run",
"./vendor/bin/php-cs-fixer fix ./tests/ --using-cache=no --rules=@PSR12 --dry-run"
],
"phpstan": [
"./vendor/bin/phpstan"
Expand Down
1 change: 1 addition & 0 deletions src/Channel/Contracts/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class Order
#[Serializer\SerializedName('orderDate')]
protected DateTime $orderDate;


#[Serializer\Type("DateTimeInterface<'Y-m-d\TH:i:s'>")]
#[Serializer\SerializedName('payDate')]
protected ?DateTime $payDate = null;
Expand Down
1 change: 0 additions & 1 deletion src/Common/Http/BaseResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*/
class BaseResponse
{

/** @param T $data */
public function __construct(
#[Serializer\SerializedName('data')]
Expand Down
14 changes: 7 additions & 7 deletions src/Http/Abstraction/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,55 +88,55 @@ public function getFragment(): string
}

/** @inheritDoc */
public function withScheme($scheme):self
public function withScheme($scheme): self
{
$uri = clone $this;
$uri->scheme = $scheme;
return $uri;
}

/** @inheritDoc */
public function withUserInfo($user, $password = null):self
public function withUserInfo($user, $password = null): self
{
$uri = clone $this;
$uri->userInfo = implode(':', array_filter([$user, $password]));
return $uri;
}

/** @inheritDoc */
public function withHost($host):self
public function withHost($host): self
{
$uri = clone $this;
$uri->host = $host;
return $uri;
}

/** @inheritDoc */
public function withPort($port):self
public function withPort($port): self
{
$uri = clone $this;
$uri->port = (int)$port;
return $uri;
}

/** @inheritDoc */
public function withPath($path):self
public function withPath($path): self
{
$uri = clone $this;
$uri->path = $path;
return $uri;
}

/** @inheritDoc */
public function withQuery($query):self
public function withQuery($query): self
{
$uri = clone $this;
$uri->query = $query;
return $uri;
}

/** @inheritDoc */
public function withFragment($fragment):self
public function withFragment($fragment): self
{
$uri = clone $this;
$uri->fragment = $fragment;
Expand Down
2 changes: 1 addition & 1 deletion src/Provisioning/Contracts/ProvisioningDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ public function setSubsystems(array $subsystems): ProvisioningDetails
return $this;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@

class RequestToBillbeeFailedException extends Exception
{

}
6 changes: 3 additions & 3 deletions tests/Channel/Http/OrderRequestHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function testCanHandle(string $action, bool $isSupported): void
$mockRequest = self::createMock(Request::class);
Assert::assertEquals($isSupported, $this->handler->canHandle($mockRequest, $action));
}

#[TestWith(['{"action": "GetOrderList", "payload": {"page": 1, "perPage": 10, "startDate": "2024-06-14T15:36:00"}}', 1, 10, "2024-06-14"])]
#[TestWith(['{"action": "GetOrderList", "payload": {"page": 2, "perPage": 20, "startDate": "2023-06-14T15:36:00"}}', 2, 20, "2023-06-14"])]
public function testHandle_GetOrders(string $requestBody, int $page, int $perPage, string $start): void
Expand Down Expand Up @@ -96,8 +96,8 @@ public function testAckOrder(string $requestBody, string $orderId): void
$this->handler->handle($mockRequest, 'AckOrder');
}

#[TestWith(['{"action": "SetOrderState", "payload": {"id": "12345","status": 2,"changeDate": "2024-06-14T10:00:00Z","paidAmount": 99.99}}', "12345"])]
#[TestWith(['{"action": "SetOrderState", "payload": {"id": "5678","status": 2,"changeDate": "2024-06-14T10:00:00Z","paidAmount": 99.99}}', "5678"])]
#[TestWith(['{"action": "SetOrderState", "payload": {"id": "12345","status": 2,"changeDate": "2024-06-14T10:00:00","paidAmount": 99.99}}', "12345"])]
#[TestWith(['{"action": "SetOrderState", "payload": {"id": "5678","status": 2,"changeDate": "2024-06-14T10:00:00","paidAmount": 99.99}}', "5678"])]
public function testSetOrderState(string $requestBody, string $orderId): void
{
$this->mockOrderRepository
Expand Down
2 changes: 1 addition & 1 deletion tests/Channel/Http/ProductRequestHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function testCanHandle(string $action, bool $isSupported): void
$mockRequest = self::createMock(Request::class);
Assert::assertEquals($isSupported, $this->handler->canHandle($mockRequest, $action));
}

#[TestWith(['{"action": "GetProductList", "payload": {"page": 1, "perPage": 10}}', 1, 10])]
#[TestWith(['{"action": "GetProductList", "payload": {"page": 2, "perPage": 20}}', 2, 20])]
public function testHandle_GetProducts(string $requestBody, int $page, int $perPage): void
Expand Down

0 comments on commit d2a5b89

Please sign in to comment.