Skip to content
This repository has been archived by the owner on Apr 14, 2024. It is now read-only.

Commit

Permalink
switch from travis to githubs actions
Browse files Browse the repository at this point in the history
  • Loading branch information
rodnaph committed Dec 28, 2020
1 parent 6c16b2f commit bd64ce0
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 17 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: "Continuous Integration"

on:
pull_request:
pull_request_target:
push:
branches:
- master

jobs:
ci:
name: "Run Build"
runs-on: ubuntu-latest

strategy:
matrix:
php-version:
- 7.1

services:
gotenberg:
image: thecodingmachine/gotenberg:6
ports:
- 3000:3000

steps:
- name: "Checkout"
uses: actions/checkout@v2

- name: "Install PHP"
uses: shivammathur/setup-php@v2
with:
coverage: none
php-version: ${{ matrix.php-version }}
tools: composer:v2

- name: "Install Dependencies"
run: composer install

- name: "Run csfix"
run: composer run csfix

- name: "Run cscheck"
run: composer run cscheck

- name: "Run phpstan"
run: composer run phpstan

- name: "Run Tests"
run: composer run phpunit
env:
GOTENBERG_API_URL: 'localhost:3000'
10 changes: 0 additions & 10 deletions .travis.yml

This file was deleted.

17 changes: 10 additions & 7 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@

use HTTP\Client\Exception;
use PHPUnit\Framework\TestCase;
use function getenv;

final class ClientTest extends TestCase
{
public const API_URL = 'gotenberg:3000';

/** @var HTMLRequest */
private $HTMLRequest;

Expand All @@ -26,6 +25,9 @@ final class ClientTest extends TestCase
/** @var MergeRequest */
private $mergeRequest;

/** @var string */
private $apiUrl;

/**
* @throws RequestException
*/
Expand All @@ -36,6 +38,7 @@ public function setUp(): void
$this->markdownRequest = $this->createMarkdownRequest();
$this->officeRequest = $this->createOfficeRequest();
$this->mergeRequest = $this->createMergeRequest();
$this->apiUrl = getenv('GOTENBERG_API_URL') ?: 'gotenberg:3000';
}

/**
Expand Down Expand Up @@ -150,7 +153,7 @@ public function createMergeRequest(): MergeRequest
*/
public function testPost(): void
{
$client = new Client(self::API_URL, new \Http\Adapter\Guzzle6\Client());
$client = new Client($this->apiUrl, new \Http\Adapter\Guzzle6\Client());
// case 1: HTML.
$response = $client->post($this->HTMLRequest);
$this->assertEquals($response->getHeaderLine('Content-Type'), 'application/pdf');
Expand Down Expand Up @@ -180,7 +183,7 @@ public function testPost(): void
*/
public function testStore(): void
{
$client = new Client(self::API_URL);
$client = new Client($this->apiUrl);
// case 1: HTML.
$filePath = __DIR__ . '/store/resultHTML.pdf';
$client->store($this->HTMLRequest, $filePath);
Expand Down Expand Up @@ -209,7 +212,7 @@ public function testStore(): void
*/
public function testPageRanges(): void
{
$client = new Client(self::API_URL, new \Http\Adapter\Guzzle6\Client());
$client = new Client($this->apiUrl, new \Http\Adapter\Guzzle6\Client());
// case 1: HTML.
$request = $this->createHTMLRequest();
$request->setPageRanges('1-1');
Expand Down Expand Up @@ -241,7 +244,7 @@ public function testPageRanges(): void
*/
public function testWebhook(): void
{
$client = new Client(self::API_URL, new \Http\Adapter\Guzzle6\Client());
$client = new Client($this->apiUrl, new \Http\Adapter\Guzzle6\Client());
$request = $this->createMergeRequest();
$request->setWebhookURL('https://google.com');
$request->setWebhookURLTimeout(5.0);
Expand All @@ -256,7 +259,7 @@ public function testWebhook(): void
*/
public function testRemoteURLHTTPHeader(): void
{
$client = new Client(self::API_URL, new \Http\Adapter\Guzzle6\Client());
$client = new Client($this->apiUrl, new \Http\Adapter\Guzzle6\Client());
$request = $this->createURLRequest();
$request->addRemoteURLHTTPHeader('A-Header', 'Foo');
$response = $client->post($request);
Expand Down

0 comments on commit bd64ce0

Please sign in to comment.