Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to GA workflow for CI #306

Merged
merged 6 commits into from
Dec 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: CI

on:
push:
branches:
- master
pull_request:
branches:
- '*'

jobs:
testsuite:
runs-on: ubuntu-18.04
strategy:
fail-fast: false
matrix:
php-version: ['7.2', '7.4', '8.0']
prefer-lowest: ['']
include:
- php-version: '7.2'
prefer-lowest: 'prefer-lowest'

steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
coverage: pcov

- name: Composer install
run: |
if ${{ matrix.prefer-lowest == 'prefer-lowest' }}; then
composer update --prefer-lowest --prefer-stable
elif [[ ${{ matrix.php-version }} == '8.0' ]]; then
composer remove --dev mpdf/mpdf dompdf/dompdf
composer install
else
composer install
fi

- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Run PHPUnit
run: |
if [[ ${{ matrix.php-version }} == '7.4' ]]; then
vendor/bin/phpunit --coverage-clover=coverage.xml
else
vendor/bin/phpunit
fi

- name: Code Coverage Report
if: matrix.php-version == '7.4'
uses: codecov/codecov-action@v1

cs-stan:
name: Coding Standard & Static Analysis
runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: mbstring, intl
coverage: none
tools: cs2pr, psalm:^4.3, phpstan:^0.12

- name: Composer Install
run: composer install

- name: Run phpcs
run: vendor/bin/phpcs -q --report=checkstyle --standard=vendor/cakephp/cakephp-codesniffer/CakePHP src/ tests/ | cs2pr

- name: Run psalm
if: success() || failure()
run: psalm --output-format=github

- name: Run phpstan
if: success() || failure()
run: phpstan analyse
55 changes: 0 additions & 55 deletions .travis.yml

This file was deleted.

3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# CakePdf plugin


[![Build Status](https://img.shields.io/travis/FriendsOfCake/CakePdf/master.svg?style=flat-square)](https://travis-ci.org/FriendsOfCake/CakePdf)
[![Build Status](https://img.shields.io/github/workflow/status/FriendsOfCake/CakePdf/CI/master?style=flat-square)](https://github.com/FriendsOfCake/CakePdf/actions?query=workflow%3ACI+branch%3Amaster)
[![Total Downloads](https://img.shields.io/packagist/dt/friendsofcake/CakePdf.svg?style=flat-square)](https://packagist.org/packages/friendsofcake/CakePdf)
[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://packagist.org/packages/friendsofcake/CakePdf)

Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
"cakephp/cakephp": "^4.0"
},
"require-dev": {
"phpunit/phpunit": "~8.5.0",
"dompdf/dompdf": "^0.8",
"phpunit/phpunit": "~8.5.0 || ^9.3",
"dompdf/dompdf": "^0.8.6",
"mpdf/mpdf": "^8.0.4",
"tecnickcom/tcpdf": "^6.3"
"tecnickcom/tcpdf": "^6.3",
"cakephp/cakephp-codesniffer": "^4.2"
},
"suggest": {
"dompdf/dompdf": "If you wish to use the DomPdf engine",
Expand Down
2 changes: 2 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@

<DocblockTypeContradiction errorLevel="info" />
<RedundantConditionGivenDocblockType errorLevel="info" />

<UnsafeInstantiation errorLevel="info" />
</issueHandlers>
</psalm>
4 changes: 2 additions & 2 deletions src/Pdf/CakePdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ public function viewVars(?array $viewVars = null)
if ($viewVars === null) {
return $this->_viewVars;
}
$this->_viewVars = array_merge($this->_viewVars, (array)$viewVars);
$this->_viewVars = array_merge($this->_viewVars, $viewVars);

return $this;
}
Expand Down Expand Up @@ -936,7 +936,7 @@ public function helpers(?array $helpers = null)
if ($helpers === null) {
return $this->_helpers;
}
$this->_helpers = (array)$helpers;
$this->_helpers = $helpers;

return $this;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Pdf/Crypto/PdftkCrypto.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function encrypt(string $data): string
$exitcode = proc_close($prochandle);

if ($exitcode !== 0) {
throw new Exception(sprintf('Crypto: Unknown error (exit code %d)', $exitcode));
throw new Exception(sprintf("Crypto: (exit code %d)\n%s", $exitcode, $stderr));
}

return (string)$stdout;
Expand Down
6 changes: 3 additions & 3 deletions src/View/PdfView.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ public function renderer(?array $config = null): ?CakePdf
/**
* Render a Pdf view.
*
* @param string $view The view being rendered.
* @param string $template The view being rendered.
* @param false|null|string $layout The layout being rendered.
* @return string The rendered view.
*/
public function render(?string $view = null, $layout = null): string
public function render(?string $template = null, $layout = null): string
{
$content = parent::render($view, $layout);
$content = parent::render($template, $layout);

$type = $this->response->getType();
if ($type === 'text/html') {
Expand Down
11 changes: 10 additions & 1 deletion tests/TestCase/Pdf/Engine/DomPdfEngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
*/
class DomPdfEngineTest extends TestCase
{
public function setUp(): void
{
parent::setUp();

if (!class_exists(Dompdf::class)) {
$this->markTestSkipped('Dompdf is not loaded');
}
}

/**
* Tests that the engine receives the expected options.
*/
Expand Down Expand Up @@ -96,7 +105,7 @@ public function testOutput()
$Pdf->html('<foo>bar</foo>');

$output = $Pdf->engine()->output();
$this->assertStringStartsWith('%PDF-1.3', $output);
$this->assertStringStartsWith('%PDF-1.7', $output);
$this->assertStringEndsWith("%%EOF\n", $output);
}

Expand Down
9 changes: 9 additions & 0 deletions tests/TestCase/Pdf/Engine/MpdfEngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
*/
class MpdfEngineTest extends TestCase
{
public function setUp(): void
{
parent::setUp();

if (!class_exists(Mpdf::class)) {
$this->markTestSkipped('Mpdf is not loaded');
}
}

/**
* Tests that the engine sets the options properly.
*/
Expand Down