Skip to content

Commit

Permalink
Update to scaffold 0.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
tannguyen04 committed Feb 21, 2024
1 parent 48b5cc2 commit 66511da
Show file tree
Hide file tree
Showing 12 changed files with 174 additions and 73 deletions.
29 changes: 0 additions & 29 deletions .editorconfig

This file was deleted.

16 changes: 16 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## Checklist before requesting a review

- [ ] I have formatted the subject to include ticket number as `[#123] Verb in past tense with dot at the end.`
- [ ] I have added a link to the issue tracker
- [ ] I have provided information in `Changed` section about WHY something was done if this was not a normal implementation
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] I have run new and existing relevant tests locally with my changes, and they passed
- [ ] I have provided screenshots, where applicable

## Changed

1.

## Screenshots
8 changes: 5 additions & 3 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name-template: '$NEXT_MINOR_VERSION'
tag-template: '$NEXT_MINOR_VERSION'
name-template: '$RESOLVED_VERSION'
tag-template: '$RESOLVED_VERSION'
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
version-resolver:
default: minor
template: |
## What's new since $PREVIOUS_TAG
$CHANGES
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...$NEXT_MINOR_VERSION
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...$RESOLVED_VERSION
$CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ permissions:
jobs:
assign-author:
runs-on: ubuntu-latest

steps:
- uses: toshimaru/[email protected]
- name: Assign author
uses: toshimaru/[email protected]
25 changes: 25 additions & 0 deletions .github/workflows/draft-release-notes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Draft release notes

on:
push:
tags:
- '*'
branches:
- main

permissions:
contents: write

jobs:
release-drafter:
permissions:
contents: write
pull-requests: write

runs-on: ubuntu-latest

steps:
- name: Draft release notes
uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34 changes: 18 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,37 @@ on:
push:
tags:
- '*'
branches:
- main

permissions:
contents: write

jobs:
release-drafter:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release-php:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
- name: Checkout code
uses: actions/checkout@v4

- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}
- uses: php-actions/composer@v6
- name: Get Tag Name

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1

- name: Install dependencies
run: composer install


- name: Get tag name
id: get-version
run: echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

- name: Create Release
uses: softprops/action-gh-release@v1
with:
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ docker compose exec phpserver composer install --ansi
docker compose exec phpserver composer lint
```

### Lint fix

```bash
docker compose exec phpserver composer lint-fix
```

### Run tests

```bash
Expand Down
8 changes: 6 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"phpmd/phpmd": "^2.13",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^11.0",
"rector/rector": "^1.0.0",
"squizlabs/php_codesniffer": "^3",
"symfony/process": "^6.4 || ^7.0"
},
Expand All @@ -43,9 +44,12 @@
"scripts": {
"lint": [
"phpcs",
"phpstan"
"phpmd --exclude vendor,tests . text phpmd.xml",
"phpstan",
"rector --clear-cache --dry-run"
],
"lint:fix": [
"lint-fix": [
"rector --clear-cache",
"phpcbf"
],
"test": [
Expand Down
15 changes: 15 additions & 0 deletions phpmd.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0"?>
<ruleset name="Custom PHPMD ruleset."
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">

<rule ref="rulesets/unusedcode.xml"/>
<rule ref="rulesets/codesize.xml"/>
<rule ref="rulesets/cleancode.xml/MissingImport">
<properties>
<property name="ignore-global" value="true"/>
</properties>
</rule>
</ruleset>
66 changes: 66 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

/**
* @file
* Rector configuration.
*
* Usage:
* ./vendor/bin/rector process .
*
* @see https://github.com/palantirnet/drupal-rector/blob/main/rector.php
*/

declare(strict_types=1);

use Rector\CodeQuality\Rector\ClassMethod\InlineArrayReturnAssignRector;
use Rector\CodeQuality\Rector\Empty_\SimplifyEmptyCheckOnEmptyArrayRector;
use Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector;
use Rector\CodingStyle\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector;
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
use Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector;
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector;
use Rector\Set\ValueObject\SetList;
use Rector\Strict\Rector\Empty_\DisallowedEmptyRuleFixerRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/**',
]);

$rectorConfig->sets([
SetList::PHP_80,
SetList::PHP_81,
SetList::CODE_QUALITY,
SetList::CODING_STYLE,
SetList::DEAD_CODE,
SetList::INSTANCEOF,
SetList::TYPE_DECLARATION,
]);

$rectorConfig->skip([
// Rules added by Rector's rule sets.
ArraySpreadInsteadOfArrayMergeRector::class,
CountArrayToEmptyArrayComparisonRector::class,
DisallowedEmptyRuleFixerRector::class,
InlineArrayReturnAssignRector::class,
NewlineAfterStatementRector::class,
NewlineBeforeNewAssignSetRector::class,
PostIncDecToPreIncDecRector::class,
RemoveAlwaysTrueIfConditionRector::class,
SimplifyEmptyCheckOnEmptyArrayRector::class,
// Dependencies.
'*/vendor/*',
'*/node_modules/*',
'*/tests/*',
]);

$rectorConfig->fileExtensions([
'php',
'inc',
]);

$rectorConfig->importNames(TRUE, FALSE);
$rectorConfig->importShortClasses(FALSE);
};
19 changes: 6 additions & 13 deletions src/DrevOps/BehatScreenshotExtension/Context/ScreenshotContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,18 @@ class ScreenshotContext extends RawMinkContext implements SnippetAcceptingContex

/**
* Screenshot directory name.
*
* @var string
*/
private $dir;
private string $dir = '';

/**
* Makes screenshot when fail.
*
* @var bool
*/
private $fail;
private ?bool $fail = null;

/**
* Prefix for failed screenshot files.
*
* @var string
*/
private $failPrefix;
private string $failPrefix = '';

/**
* {@inheritdoc}
Expand Down Expand Up @@ -94,7 +88,6 @@ public function beforeScenarioInit(BeforeScenarioScope $scope): void
/**
* Init values required for snapshot.
*
* @param BeforeStepScope $scope
*
* @BeforeStep
*/
Expand Down Expand Up @@ -141,7 +134,7 @@ public function iSaveScreenshot($fail = false): void

try {
$data = $driver->getContent();
} catch (DriverException $exception) {
} catch (DriverException) {
// Do not do anything if the driver does not have any content - most
// likely the page has not been loaded yet.
return;
Expand All @@ -158,7 +151,7 @@ public function iSaveScreenshot($fail = false): void
// content and screenshot files together by name.
$fileName = substr($fileName, 0, -1 * strlen('html')).'png';
$this->saveScreenshotData($fileName, $data);
} catch (UnsupportedDriverActionException $exception) {
} catch (UnsupportedDriverActionException) {
// Nothing to do here - drivers without support for screenshots
// simply do not have them created.
}
Expand All @@ -177,7 +170,7 @@ public function iSaveSizedScreenshot(string|int $width = 1440, string|int $heigh
{
try {
$this->getSession()->resizeWindow((int) $width, (int) $height, 'current');
} catch (UnsupportedDriverActionException $exception) {
} catch (UnsupportedDriverActionException) {
// Nothing to do here - drivers without resize support may proceed.
}
$this->iSaveScreenshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace DrevOps\BehatScreenshotExtension\ServiceContainer;

use DrevOps\BehatScreenshotExtension\Context\Initializer\ScreenshotContextInitializer;
use Behat\Behat\Context\ServiceContainer\ContextExtension;
use Behat\Testwork\ServiceContainer\Extension as ExtensionInterface;
use Behat\Testwork\ServiceContainer\ExtensionManager;
Expand Down Expand Up @@ -55,22 +56,20 @@ public function initialize(ExtensionManager $extensionManager): void
public function configure(ArrayNodeDefinition $builder): void
{
$definitionChildren = $builder->children();
if ($definitionChildren instanceof NodeBuilder) {
// @phpstan-ignore-next-line
$definitionChildren
->scalarNode('dir')->cannotBeEmpty()->defaultValue('%paths.base%/screenshots')->end()
->scalarNode('fail')->cannotBeEmpty()->defaultValue(true)->end()
->scalarNode('fail_prefix')->cannotBeEmpty()->defaultValue('failed_')->end()
->scalarNode('purge')->cannotBeEmpty()->defaultValue(false)->end();
}
// @phpstan-ignore-next-line
$definitionChildren
->scalarNode('dir')->cannotBeEmpty()->defaultValue('%paths.base%/screenshots')->end()
->scalarNode('fail')->cannotBeEmpty()->defaultValue(true)->end()
->scalarNode('fail_prefix')->cannotBeEmpty()->defaultValue('failed_')->end()
->scalarNode('purge')->cannotBeEmpty()->defaultValue(false)->end();
}

/**
* {@inheritdoc}
*/
public function load(ContainerBuilder $container, array $config): void
{
$definition = new Definition('DrevOps\BehatScreenshotExtension\Context\Initializer\ScreenshotContextInitializer', [
$definition = new Definition(ScreenshotContextInitializer::class, [
$config['dir'],
$config['fail'],
$config['fail_prefix'],
Expand Down

0 comments on commit 66511da

Please sign in to comment.