Skip to content

Commit

Permalink
DQA-6930: Toolkit allow to skip abandoned components (#670)
Browse files Browse the repository at this point in the history
  • Loading branch information
joaocsilva authored May 2, 2023
1 parent cef6beb commit 7bafed5
Show file tree
Hide file tree
Showing 7 changed files with 186 additions and 63 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
/.tmp/
/runner.yml
/phpunit.xml
/phpstan.neon
/docker-compose.*.yml
.phpunit.result.cache
*.sql
Expand Down
2 changes: 2 additions & 0 deletions config/runner/toolkit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ toolkit:
components:
outdated:
check: true
abandoned:
check: true
deploy:
config_file: 'config/sync/core.extension.yml'
sequence_file: '.opts.yml'
Expand Down
22 changes: 22 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
parameters:
level: 5
paths:
- src
excludePaths:
- vendor
reportUnmatchedIgnoredErrors: false
ignoreErrors:
- '#^Call to deprecated method toolkitRunGrumphp#'
- '#^Call to an undefined method Robo\\Collection\\CollectionBuilder::task#'
- '#^Call to an undefined method Robo\\Collection\\CollectionBuilder\|Robo\\Task\\Filesystem\\FilesystemStack::task#'
- '#^Call to an undefined method Consolidation\\Config\\ConfigInterface::replace\(\)#'
- '#^Parameter \#2 \$defaultFallback of method Consolidation\\Config\\ConfigInterface::get\(\) expects string\|null, array given#'
- '#^Call to an undefined method DOMNode::getElementsByTagName\(\)#'
- '#^Parameter \#1 \$roboClass of class Robo\\Runner constructor expects string\|null, array<int, string> given\.#'
- '#^Parameter \#1 \$roboClass of class Robo\\Runner constructor expects string\|null, array<int, string> giveasdassan\.#'
-
message: '#^Negated boolean expression is always false\.#'
path: src/TaskRunner/AbstractCommands.php
- '#^Call to deprecated method registerCommandClass\(\) of class Robo\\Runner#'
includes:
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
16 changes: 0 additions & 16 deletions runner.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,3 @@ toolkit:
- toolkit:test-phpmd
- toolkit:lint-php
- toolkit:test-phpstan

test:
phpstan:
level: 5
includes:
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
ignore_errors:
- '#^Call to deprecated method toolkitRunGrumphp#'
- '#^Call to an undefined method Robo\\Collection\\CollectionBuilder::task#'
- '#^Call to an undefined method Robo\\Collection\\CollectionBuilder\|Robo\\Task\\Filesystem\\FilesystemStack::task#'
- '#^Call to an undefined method Consolidation\\Config\\ConfigInterface::replace\(\)#'
- '#^Parameter \#2 \$defaultFallback of method Consolidation\\Config\\ConfigInterface::get\(\) expects string\|null, array given#'
- '#^Call to an undefined method DOMNode::getElementsByTagName\(\)#'
- '#^Parameter \#1 \$roboClass of class Robo\\Runner constructor expects string\|null, array<int, string> given\.#'
- message: '#^Negated boolean expression is always false\.#'
path: src/TaskRunner/AbstractCommands.php
29 changes: 19 additions & 10 deletions src/TaskRunner/Commands/ComponentCheckCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Yaml\Yaml;

/**
* Command class for toolkit:component-check
*
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
*/
class ComponentCheckCommands extends AbstractCommands
{
protected bool $commandFailed = false;
Expand Down Expand Up @@ -59,6 +64,9 @@ public function componentCheck(ConsoleIO $io, array $options = [
if (isset($commitTokens['skipOutdated']) || !$this->getConfig()->get('toolkit.components.outdated.check')) {
$this->skipOutdated = true;
}
if (!$this->getConfig()->get('toolkit.components.abandoned.check')) {
$this->skipAbandoned = true;
}
if (isset($commitTokens['skipInsecure'])) {
$this->skipInsecure = true;
}
Expand Down Expand Up @@ -189,16 +197,17 @@ function ($value) {
$io->success('Components checked, nothing to report.');
} else {
$io->note([
'It is possible to bypass the insecure and outdated check:',
'- Insecure check:',
' - by providing a token in the commit message: [SKIP-INSECURE]',
'- Outdated check:',
' - by providing a token in the commit message: [SKIP-OUTDATED]',
' - Or, update the configuration in the runner.yml.dist as shown below: ',
' toolkit:',
' components:',
' outdated:',
' check: false',
'It is possible to bypass the insecure, outdated and abandoned check:',
'- Using commit message to skip Insecure and/or Outdated check:',
' - Include in the message: [SKIP-INSECURE] and/or [SKIP-OUTDATED]',
'',
'- Using the configuration in the runner.yml.dist as shown below to skip Outdated or Abandoned: ',
' toolkit:',
' components:',
' outdated:',
' check: false',
' abandoned:',
' check: false',
]);
}

Expand Down
163 changes: 141 additions & 22 deletions tests/fixtures/commands/component-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,26 +87,143 @@
https://webgate.ec.europa.eu/fpfis/qa/package-reviews.
! [NOTE] It is possible to bypass the insecure and outdated check:
! [NOTE] It is possible to bypass the insecure, outdated and abandoned check:
!
! - Insecure check:
! - Using commit message to skip Insecure and/or Outdated check:
!
! - by providing a token in the commit message: [SKIP-INSECURE]
! - Include in the message: [SKIP-INSECURE] and/or [SKIP-OUTDATED]
!
! - Outdated check:
!
! - by providing a token in the commit message: [SKIP-OUTDATED]
!
! - Or, update the configuration in the runner.yml.dist as shown
! below:
! - Using the configuration in the runner.yml.dist as shown below to
! skip Outdated or Abandoned:
!
! toolkit:
! toolkit:
!
! components:
! components:
!
! outdated:
! outdated:
!
! check: false
! check: false
!
! abandoned:
!
! check: false
- command: 'toolkit:component-check'
configuration:
toolkit:
project_id: digit-qa
components:
outdated:
check: false
abandoned:
check: false
tokens: ''
resources:
- from: sample-composer.lock
to: composer.lock
expectations:
- contains: |
Checking Mandatory components.
==============================
[Simulator] Running ./vendor/bin/drush status --format=json
> Website not installed, using config/sync/core.extension.yml file.
> Config file not found at config/sync/core.extension.yml.
Package dropsolid_purge is mandatory and is not present on the project.
Package redirect is mandatory and is not present on the project.
Package oe_dashboard_agent is mandatory and is not present on the project.
Checking Recommended components.
================================
Package drupal/redis is recommended but is not present on the project.
> See the list of recommended packages at
https://webgate.ec.europa.eu/fpfis/qa/requirements.
> This step is in reporting mode, skipping.
Checking Insecure components.
=============================
[Simulator] Running ./vendor/bin/drush pm:security --format=json
[Simulator] Running ./vendor/bin/security-checker security:check --no-dev --format=json
> Insecure components check passed.
Checking Outdated components.
=============================
[Simulator] Running composer outdated --no-dev --locked --direct --minor-only --format=json
> Outdated components check passed.
Checking Abandoned components.
==============================
> Abandoned components check passed.
Checking evaluation status components.
======================================
> Evaluation module check passed.
Checking dev components.
========================
> Dev components check passed.
Checking dev components in require section.
===========================================
> Dev components in require section check passed
Checking require section for Drush.
===================================
> Drush require section check passed.
Results:
========
--------------------------------- -------------------
Mandatory module check failed
Recommended module check 1 warning
Insecure module check passed
Outdated module check passed (Skipping)
Abandoned module check passed (Skipping)
Dev module check passed
Evaluation module check passed
Dev module in require-dev check passed
Drush require section check passed
--------------------------------- -------------------
[ERROR] Failed the components check, please verify the report and update the
project.
See the list of packages at
https://webgate.ec.europa.eu/fpfis/qa/package-reviews.
! [NOTE] It is possible to bypass the insecure, outdated and abandoned check:
!
! - Using commit message to skip Insecure and/or Outdated check:
!
! - Include in the message: [SKIP-INSECURE] and/or [SKIP-OUTDATED]
!
!
!
! - Using the configuration in the runner.yml.dist as shown below to
! skip Outdated or Abandoned:
!
! toolkit:
!
! components:
!
! outdated:
!
! check: false
!
! abandoned:
!
! check: false
- command: 'toolkit:component-check --test-command'
configuration:
Expand Down Expand Up @@ -205,26 +322,28 @@
https://webgate.ec.europa.eu/fpfis/qa/package-reviews.
! [NOTE] It is possible to bypass the insecure and outdated check:
! [NOTE] It is possible to bypass the insecure, outdated and abandoned check:
!
! - Using commit message to skip Insecure and/or Outdated check:
!
! - Include in the message: [SKIP-INSECURE] and/or [SKIP-OUTDATED]
!
! - Insecure check:
!
! - by providing a token in the commit message: [SKIP-INSECURE]
!
! - Outdated check:
! - Using the configuration in the runner.yml.dist as shown below to
! skip Outdated or Abandoned:
!
! - by providing a token in the commit message: [SKIP-OUTDATED]
! toolkit:
!
! - Or, update the configuration in the runner.yml.dist as shown
! below:
! components:
!
! toolkit:
! outdated:
!
! components:
! check: false
!
! outdated:
! abandoned:
!
! check: false
! check: false
- command: 'toolkit:component-check'
configuration:
Expand Down
16 changes: 2 additions & 14 deletions tests/fixtures/commands/configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,27 +114,15 @@
- { task: process, source: behat.yml.dist, destination: behat.yml }
resources: []
expectations:
- contains: |
- str_contains: |
Description:
Setup the behat file
Usage:
example:full
full
example:full --simulate
Options:
-h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi|--no-ansi Force (or disable --no-ansi) ANSI output
-n, --no-interaction Do not ask any interactive question
--simulate Run in simulated mode (show what would have happened).
--progress-delay=PROGRESS-DELAY Number of seconds before progress bar is displayed in long-running task collections. Default: 2s. [default: 2]
-D, --define=DEFINE Define a configuration item value. (multiple values allowed)
--working-dir=WORKING-DIR Working directory, defaults to current working directory. [default: "/test/toolkit/tests/sandbox/ConfigurationCommandsTest"]
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
- str_contains: |
Help:
Some help text
Expand Down

0 comments on commit 7bafed5

Please sign in to comment.