Skip to content

Commit

Permalink
update QA from travis to Github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
HeahDude committed Apr 18, 2022
1 parent 25e2536 commit 6c3ab43
Show file tree
Hide file tree
Showing 17 changed files with 178 additions and 116 deletions.
119 changes: 119 additions & 0 deletions .github/workflows/qa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Quality and Assurance

on:
push:
pull_request:

jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php-versions: ['7.1', '8.1']

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

- name: Setup PHP, extensions and composer with shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, iconv, intl, pdo, pdo_mysql, dom, filter, gd, iconv, json, mbstring, pdo
env:
update: true

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

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Install Lowest Composer dependencies
if: "matrix.php-versions < '8.1'"
run: composer update --prefer-lowest --no-progress --prefer-dist --optimize-autoloader

- name: Install PHPUnit
run: vendor/bin/simple-phpunit install

- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
php-version: ${{ matrix.php-versions }}

qa:
name: Quality
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php-versions: ['8.1']

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

- name: Setup PHP, extensions and composer with shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, intl, dom, filter
tools: symfony
env:
update: true

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: PHP-CS-Fixer
run: symfony php ./vendor/bin/php-cs-fixer fix --dry-run --using-cache=no --verbose --diff

test:
name: Tests
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php-versions: ['7.1', '8.1']

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

- name: Setup PHP, extensions and composer with shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, xml, ctype, intl, dom, filter
tools: symfony
env:
update: true

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Install Lowest Composer dependencies
if: "matrix.php-versions < '8.1'"
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Execute unit tests
run: symfony php ./vendor/bin/simple-phpunit
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.php_cs.cache
.php-cs-fixer.cache
.phpunit.result.cache
phpunit.xml
composer.lock
Expand Down
1 change: 0 additions & 1 deletion .php-cs-fixer.cache

This file was deleted.

68 changes: 0 additions & 68 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"require": {
"php": "^7.1.3 || ^8.0.0",
"ezyang/htmlpurifier": "~4.0",
"ezyang/htmlpurifier": "~4.14",
"symfony/config": "~4.4 || ^5.0 || ^6.0",
"symfony/dependency-injection": "^4.4 || ^5.0 || ^6.0",
"symfony/http-kernel": "^4.4 || ^5.0 || ^6.0"
Expand Down
7 changes: 3 additions & 4 deletions src/CacheWarmer/SerializerCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ class SerializerCacheWarmer implements CacheWarmerInterface
private $filesystem;

/**
* @param string[] $paths
* @param string[] $profiles
* @param HTMLPurifiersRegistryInterface $registry Used to build cache within bundle runtime
* @param string[] $paths
* @param string[] $profiles
*/
public function __construct(array $paths, array $profiles, HTMLPurifiersRegistryInterface $registry, Filesystem $filesystem)
{
Expand All @@ -41,7 +40,7 @@ public function __construct(array $paths, array $profiles, HTMLPurifiersRegistry
/**
* {@inheritdoc}
*/
public function warmUp(string $cacheDir): array
public function warmUp($cacheDir): array
{
foreach ($this->paths as $path) {
$this->filesystem->remove($path); // clean previous cache
Expand Down
5 changes: 4 additions & 1 deletion src/DependencyInjection/ExerciseHTMLPurifierExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

class ExerciseHTMLPurifierExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container): void
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));

Expand Down
2 changes: 1 addition & 1 deletion src/Form/Listener/HTMLPurifierListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function purifySubmittedData(FormEvent $event): void
return; // because we don't want to handle it here
}

if (0 === strlen($submittedData = trim($data))) {
if (0 === strlen($submittedData = trim((string) $data))) {
if ($submittedData !== $data) {
$event->setData($submittedData);
}
Expand Down
2 changes: 1 addition & 1 deletion src/HTMLPurifierConfigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static function create(
* This build should never happen on runtime, since purifiers cache should
* be generated during warm up.
*/
public static function buildHTMLDefinition(\HTMLPurifier_Definition $def, array $attributes, array $elements, array $blankElements): void
public static function buildHTMLDefinition(\HTMLPurifier_HTMLDefinition $def, array $attributes, array $elements, array $blankElements): void
{
foreach ($attributes as $elementName => $rule) {
foreach ($rule as $attributeName => $definition) {
Expand Down
6 changes: 3 additions & 3 deletions tests/CacheWarmer/SerializerCacheWarmerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

class SerializerCacheWarmerTest extends TestCase
{
public function testShouldBeRequired()
public function testShouldBeRequired(): void
{
$cacheWarmer = new SerializerCacheWarmer([], [], $this->createMock(HTMLPurifiersRegistryInterface::class), new Filesystem());

$this->assertFalse($cacheWarmer->isOptional());
}

public function testWarmUpShouldCreatePaths()
public function testWarmUpShouldCreatePaths(): void
{
$fs = new Filesystem();
$path = sys_get_temp_dir().DIRECTORY_SEPARATOR.'html_purifier';
Expand All @@ -35,7 +35,7 @@ public function testWarmUpShouldCreatePaths()
$fs->remove($path);
}

public function testWarmUpShouldCallPurifyForEachProfile()
public function testWarmUpShouldCallPurifyForEachProfile(): void
{
$purifier = $this->createMock(\HTMLPurifier::class);
$purifier->expects($this->exactly(2))
Expand Down
10 changes: 5 additions & 5 deletions tests/DependencyInjection/Compiler/HTMLPurifierPassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class HTMLPurifierPassTest extends TestCase
{
/** @var ContainerBuilder|MockObject */
/** @var ContainerBuilder|MockObject|null */
private $container;

protected function setUp(): void
Expand All @@ -34,7 +34,7 @@ protected function tearDown(): void
$this->container = null;
}

public function testProcessOnlyIfRegistryInterfaceIsDefined()
public function testProcessOnlyIfRegistryInterfaceIsDefined(): void
{
$this->container->expects($this->once())
->method('hasAlias')
Expand All @@ -50,7 +50,7 @@ public function testProcessOnlyIfRegistryInterfaceIsDefined()
$pass->process($this->container);
}

public function testProcess()
public function testProcess(): void
{
$container = new ContainerBuilder();
$purifier = $container->register(DummyPurifier::class)
Expand All @@ -71,7 +71,7 @@ public function testProcess()
$this->assertSame(DummyPurifier::class, (string) $map['test']->getValues()[0]);
}

public function testProcessDoNothingIfRegistryIsNotDefined()
public function testProcessDoNothingIfRegistryIsNotDefined(): void
{
$this->container
->expects($this->once())
Expand All @@ -94,7 +94,7 @@ public function testProcessDoNothingIfRegistryIsNotDefined()
$pass->process($this->container);
}

public function testProcessFailsIfTaggedServiceMissesProfileName()
public function testProcessFailsIfTaggedServiceMissesProfileName(): void
{
$container = new ContainerBuilder();
$container->register(DummyPurifier::class)
Expand Down
Loading

0 comments on commit 6c3ab43

Please sign in to comment.