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

[#89] Updated to scaffold 0.12.1 #90

Merged
merged 7 commits into from
Feb 22, 2024
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
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 }}
39 changes: 0 additions & 39 deletions .github/workflows/release.yml

This file was deleted.

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);
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,56 +18,17 @@
class ScreenshotContextInitializer implements ContextInitializer
{

/**
* Screenshot directory name.
*
* @var string
*/
protected $dir;

/**
* Makes screenshot when fail.
*
* @var bool
*/
protected $fail;

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

/**
* Purge dir before start test.
*
* @var bool
*/
protected $purge;

/**
* Check if need to actually purge.
*
* @var bool
*/
protected $needsPurging;

/**
* ScreenshotContextInitializer constructor.
*
* @param string $dir Screenshot dir.
* @param bool $fail Screenshot when fail.
* @param string $failPrefix File name prefix for a failed test.
* @param bool $purge Purge dir before start script.
* @param string $dir Screenshot dir.
* @param bool $fail Screenshot when fail.
* @param string $failPrefix File name prefix for a failed test.
* @param bool $purge Purge dir before start script.
* @param bool $needsPurging Check if need to actually purge.
*/
public function __construct(string $dir, bool $fail, string $failPrefix, bool $purge)
public function __construct(protected string $dir, protected bool $fail, private readonly string $failPrefix, protected bool $purge, protected bool $needsPurging = true)
{
$this->needsPurging = true;
$this->dir = $dir;
$this->purge = $purge;
$this->fail = $fail;
$this->failPrefix = $failPrefix;
}

/**
Expand Down
23 changes: 8 additions & 15 deletions src/DrevOps/BehatScreenshotExtension/Context/ScreenshotContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,19 @@ class ScreenshotContext extends RawMinkContext implements SnippetAcceptingContex
protected $stepLine;

/**
* Screenshot directory name.
*
* @var string
* Makes screenshot when fail.
*/
private $dir;
private bool $fail = false;

/**
* Makes screenshot when fail.
*
* @var bool
* Screenshot directory name.
*/
private $fail;
private string $dir = '';

/**
* 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
Loading