Skip to content

Commit

Permalink
Use multi-tester GitHub Actions auto-detect for pug-php/pug
Browse files Browse the repository at this point in the history
  • Loading branch information
kylekatarnls committed Sep 19, 2023
1 parent d8e0a30 commit 2679d87
Show file tree
Hide file tree
Showing 58 changed files with 438 additions and 47 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.4']
php: ['8.2']
setup: ['stable']

name: PHP
Expand All @@ -25,17 +25,19 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
ini-values: memory_limit=-1, zend.enable_gc=0, xdebug.mode=coverage
tools: composer:v2
extensions: pcntl
coverage: xdebug

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-${{ matrix.setup }}-v2-php-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
key: ${{ runner.os }}-${{ matrix.setup }}-coverage-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.setup }}-v2-php-${{ matrix.php }}-
${{ runner.os }}-${{ matrix.setup }}-coverage-${{ matrix.php }}-
- name: Code Climate Test Reporter Preparation
run: |
Expand All @@ -49,8 +51,8 @@ jobs:
if: steps.composer-cache.outputs.cache-hit != 'true'
run: |
composer config version 1.9.0
${{ matrix.php >= 8 && 'composer require --no-update phpunit/phpunit:^8.5.14 --no-interaction;' || '' }}
composer update --prefer-dist ${{ matrix.setup != 'next' && format('--prefer-{0}', matrix.setup) || '' }} --no-progress ${{ matrix.php >= 8.1 && '--ignore-platform-req=php' || '' }}
composer require --no-update phpunit/phpunit:^9.6.12 phpunit/php-code-coverage:^9.2.28 --dev --no-interaction
composer update --prefer-dist ${{ matrix.setup != 'next' && format('--prefer-{0}', matrix.setup) || '' }} --no-progress --no-interaction
- name: Run test suite
run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.xml
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Multitest
name: Multi-test

on:
push:
Expand All @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
php: ['7.4', '8.0']
php: ['7.4', '8.2']
setup: ['stable']

name: PHP ${{ matrix.php }}
Expand All @@ -31,15 +31,15 @@ jobs:
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-multi-v2-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
key: ${{ runner.os }}-multi-test-v2-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-multi-v2-${{ matrix.php }}-
${{ runner.os }}-multi-test-v2-${{ matrix.php }}-
- name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true'
run: |
composer config version 1.9.0
composer require kylekatarnls/multi-tester:^2.3 --no-update --no-interaction
composer require kylekatarnls/multi-tester:^2.5.2 --dev --no-update --no-interaction
composer update --prefer-dist --prefer-${{ matrix.setup }} --no-progress --no-interaction
- name: Run test suites
Expand Down
19 changes: 12 additions & 7 deletions .multi-tester.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
pug-php/pug:
install:
- composer config --no-plugins allow-plugins.nodejs-php-fallback/nodejs-php-fallback true
- composer install --no-interaction
success_only: true
source:
url: https://github.com/pug-php/pug.git
reference: master
install: github
script: github

pug/bemto:
autoload:
Expand Down Expand Up @@ -39,10 +42,12 @@ ci-pug/ci-pug:
- composer install --no-interaction

bkwld/laravel-pug:
install:
- composer config --no-plugins allow-plugins.pug/installer true
- composer config --no-plugins allow-plugins.nodejs-php-fallback/nodejs-php-fallback true
- composer install --no-interaction
success_only: true
source:
url: https://github.com/BKWLD/laravel-pug.git
reference: multi-tester-labels
install: github
script: github

pug/yii2:
install:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"nodejs-php-fallback/uglify": "^1.0.4",
"nodejs-php-fallback/stylus": "^1.0.4",
"cebe/markdown": "^1.1",
"kylekatarnls/multi-tester": "^2.3"
"kylekatarnls/multi-tester": "^2.5.2"
},
"replace": {
"phug/ast": "self.version",
Expand Down
2 changes: 1 addition & 1 deletion release.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* php release.php minor stable message.md
* ```.
*
* Put release notes in message.md as markdown format.
* Put release notes in message.md as Markdown format.
*/
$settings = parse_ini_file('.env');

Expand Down
8 changes: 1 addition & 7 deletions src/Phug/Formatter/Formatter/Partial/MagicAccessorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ trait MagicAccessorTrait
{
private function getMethod($prefix, $name)
{
switch ($name) {
case 'nodes':
$name = 'children';
break;
}

return $prefix.ucfirst($name);
return $prefix.ucfirst($name === 'nodes' ? 'children' : $name);
}

public function __get($name)
Expand Down
5 changes: 5 additions & 0 deletions tests/Phug/Adapter/FileAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Phug\Renderer\Adapter\FileAdapter;
use Phug\Renderer\Adapter\StreamAdapter;
use Phug\Test\AbstractRendererTest;
use Phug\Test\Utils\ExceptionAnnotationReader;

/**
* @coversDefaultClass \Phug\Renderer\Adapter\FileAdapter
Expand Down Expand Up @@ -603,6 +604,8 @@ public function testMissingDirectory()
*/
public function testReadOnlyDirectory()
{
ExceptionAnnotationReader::read($this, __METHOD__);

$renderer = new Renderer([
'exit_on_error' => false,
'cache_dir' => static::getReadOnlyDirectory(),
Expand Down Expand Up @@ -755,6 +758,8 @@ public function testCacheDirectoryPreserveRendererDependencies()
}
/**
* @coversNothing
*
* Test cacheDirectory method dependencies.
*/
public function testCacheDirectoryPreserveCompilerDependencies()
Expand Down
11 changes: 11 additions & 0 deletions tests/Phug/Ast/NodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Phug\Ast\Node;
use Phug\Ast\NodeInterface;
use Phug\Test\Utils\ExceptionAnnotationReader;
use Phug\Util\TestCase;

//@codingStandardsIgnoreStart
Expand Down Expand Up @@ -287,6 +288,8 @@ public function testGetChildAt()
*/
public function testGetChildAtWithInvalidOffset()
{
ExceptionAnnotationReader::read($this, __METHOD__);

$a = new A();
$a->getChildAt(3);
}
Expand Down Expand Up @@ -315,6 +318,8 @@ public function testRemoveChildAt()
*/
public function testRemoveChildAtWithInvalidOffset()
{
ExceptionAnnotationReader::read($this, __METHOD__);

$a = new A();
$a->removeChildAt(3);
}
Expand Down Expand Up @@ -456,6 +461,8 @@ public function testFindChildren()
*/
public function testInsertBeforeWithBadSibling()
{
ExceptionAnnotationReader::read($this, __METHOD__);

$a = new A();
$a->insertBefore(new C(), new B());
}
Expand Down Expand Up @@ -492,6 +499,8 @@ public function testInsertBefore()
*/
public function testInsertAfterWithBadSibling()
{
ExceptionAnnotationReader::read($this, __METHOD__);

$a = new A();
$a->insertAfter(new C(), new B());
}
Expand Down Expand Up @@ -575,6 +584,8 @@ public function testGetIterator()
*/
public function testOffsetSetInvalidArgument()
{
ExceptionAnnotationReader::read($this, __METHOD__);

$a = new A();
$a[0] = 'foo';
}
Expand Down
2 changes: 2 additions & 0 deletions tests/Phug/CasesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public function testRender($expected, $actual, $message)
}

/**
* @coversNothing
*
* @group update
*/
public function testIfCasesAreUpToDate()
Expand Down
2 changes: 2 additions & 0 deletions tests/Phug/Compiler/NodeCompiler/ImportNodeCompilerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ public function testCompileIntoElementException()
}

/**
* @coversNothing
*
* @expectedException \Phug\CompilerException
*/
public function testFileNotFoundException()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ public function testOuterNodes()
}

/**
* @coversNothing
*
* @group mixins
*/
public function testMissingMixin()
Expand Down
25 changes: 25 additions & 0 deletions tests/Phug/CompilerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Phug\Formatter\Element\TextElement;
use Phug\Parser;
use Phug\Parser\Node\ElementNode;
use Phug\Test\Utils\ExceptionAnnotationReader;
use Phug\Test\Utils\MutedExceptionCompiler;
use Phug\Test\Utils\SuffixLocator;
use Phug\Test\Utils\UnknownNode;
Expand Down Expand Up @@ -167,6 +168,8 @@ public function testGetCompiledChildren()
*/
public function testParserClassException()
{
ExceptionAnnotationReader::read($this, __METHOD__);

$this->expectMessageToBeThrown(
'Passed parser class '.
'Phug\Parser\Node\ElementNode '.
Expand All @@ -186,6 +189,8 @@ public function testParserClassException()
*/
public function testFormatterClassException()
{
ExceptionAnnotationReader::read($this, __METHOD__);

$this->expectMessageToBeThrown(
'Passed formatter class '.
'Phug\Parser\Node\ElementNode '.
Expand All @@ -205,6 +210,8 @@ public function testFormatterClassException()
*/
public function testLocatorClassException()
{
ExceptionAnnotationReader::read($this, __METHOD__);

$this->expectMessageToBeThrown(
'Passed locator class Phug\Parser\Node\ElementNode is not a valid Phug\Compiler\LocatorInterface'
);
Expand All @@ -221,6 +228,8 @@ public function testLocatorClassException()
*/
public function testSetNodeCompilerException()
{
ExceptionAnnotationReader::read($this, __METHOD__);

$this->expectMessageToBeThrown(
'Passed node compiler needs to implement '.
'Phug\Compiler\NodeCompilerInterface. Phug\Parser\Node\ElementNode given.'
Expand All @@ -237,6 +246,8 @@ public function testSetNodeCompilerException()
*/
public function testCompileNodeException()
{
ExceptionAnnotationReader::read($this, __METHOD__);

$this->expectMessageToBeThrown(
'No compiler found able to compile '.
'Phug\Test\TestNode'
Expand All @@ -256,6 +267,8 @@ public function testCompileNodeException()
*/
public function testAbsolutePathWithoutPaths()
{
ExceptionAnnotationReader::read($this, __METHOD__);

$this->expectMessageToBeThrown(
'Either the "basedir" or "paths" option is required'.
' to use includes and extends with "absolute" paths'
Expand Down Expand Up @@ -296,6 +309,8 @@ public function testResolve()
*/
public function testResolveNotFoundException()
{
ExceptionAnnotationReader::read($this, __METHOD__);

$compiler = new Compiler(['paths' => [__DIR__.'/../templates/example-structure/views']]);
$compiler->resolve('not-existent');
}
Expand Down Expand Up @@ -423,6 +438,8 @@ function ($name) {
*/
public function testThrowException()
{
ExceptionAnnotationReader::read($this, __METHOD__);

$compiler = new Compiler();
$compiler->throwException('Test Exception');
}
Expand All @@ -436,6 +453,8 @@ public function testThrowException()
*/
public function testThrowExceptionFileName()
{
ExceptionAnnotationReader::read($this, __METHOD__);

$compiler = new Compiler([
'filename' => 'foobar.pug',
]);
Expand All @@ -458,6 +477,8 @@ public function testAssertSuccess()
*/
public function testAssertFailure()
{
ExceptionAnnotationReader::read($this, __METHOD__);

$compiler = new Compiler();
$compiler->assert(false, 'Test Exception');
}
Expand All @@ -471,6 +492,8 @@ public function testAssertFailure()
*/
public function testInitializeFormatterException()
{
ExceptionAnnotationReader::read($this, __METHOD__);

$compiler = new Compiler([
'debug' => false,
]);
Expand Down Expand Up @@ -616,6 +639,8 @@ public function testUpperLocator()
*/
public function testUnknownNodeThrowException()
{
ExceptionAnnotationReader::read($this, __METHOD__);

include_once __DIR__.'/Utils/UnknownNode.php';

$compiler = new Compiler();
Expand Down
Loading

0 comments on commit 2679d87

Please sign in to comment.