Skip to content

Commit

Permalink
Add compliance config and compliance workflow Commands (#12)
Browse files Browse the repository at this point in the history
Signed-off-by: Nathanael Esayeas <nathanael.esayeas@protonmail.com>
  • Loading branch information
ghostwriter committed Jun 7, 2022
2 parents c1d3e69 + 0ff04ab commit 47054e1
Show file tree
Hide file tree
Showing 26 changed files with 377 additions and 282 deletions.
67 changes: 34 additions & 33 deletions .github/workflows/compliance.yml
@@ -1,42 +1,43 @@
name: Compliance

on:
pull_request:
push:
branches:
- "[0-9]+.[0-9]+.x"
- "v[0-9]+"
schedule:
- cron: "0 * * * *" # Runs hourly
pull_request:
push:
branches:
- "main"
- "[0-9]+.[0-9]+.x"
- "v[0-9]+"
schedule:
- cron: "0 * * * *" # Runs hourly

jobs:
matrix:
name: Generate job matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v3
matrix:
name: Generate job matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Determine CI Jobs
id: matrix
uses: ghostwriter/compliance@v1
with:
command: matrix
qa:
name: ${{ matrix.name }} on PHP ${{ matrix.php }} with ${{ matrix.dependency }} dependencies
needs: [matrix]
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.matrix.outputs.matrix) }}
steps:
- name: ${{ matrix.name }} on PHP ${{ matrix.php }}
uses: ghostwriter/laminas-continuous-integration-action@temp
with:
job: '{"php":"${{ matrix.php }}","dependencies":"${{ matrix.dependency }}","extensions":[],"ini":[],"command":"${{ matrix.command }}"}'
- name: Determine CI Jobs
id: matrix
uses: ghostwriter/compliance@v1
with:
command: matrix
qa:
name: ${{ matrix.name }} on PHP ${{ matrix.php }} with ${{ matrix.dependency }} dependencies
needs: [matrix]
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.matrix.outputs.matrix) }}
steps:
- name: ${{ matrix.name }} on PHP ${{ matrix.php }}
uses: ghostwriter/laminas-continuous-integration-action@temp
with:
job: '{"php":"${{ matrix.php }}","dependencies":"${{ matrix.dependency }}","extensions":[],"ini":[],"command":"${{ matrix.command }}"}'
# - name: QA Check ${{ matrix.name }} on PHP ${{ matrix.php }}
# uses: ghostwriter/compliance@qa/test-workflow
# with:
Expand Down
8 changes: 6 additions & 2 deletions README.md
Expand Up @@ -24,7 +24,10 @@ composer require ghostwriter/compliance

```bash
# Create `.github/workflows/compliance.yml` workflow file
compliance init
compliance workflow

# Create `./compliance.php` configuration file
compliance config

# Determine CI Jobs for GitHub Actions
compliance matrix
Expand All @@ -42,7 +45,8 @@ docker pull ghcr.io/ghostwriter/compliance:v1

# Usage from the command line:

docker run -v $(PWD):/app -w=/app ghcr.io/ghostwriter/compliance init
docker run -v $(PWD):/app -w=/app ghcr.io/ghostwriter/compliance workflow
docker run -v $(PWD):/app -w=/app ghcr.io/ghostwriter/compliance config
docker run -v $(PWD):/app -w=/app ghcr.io/ghostwriter/compliance matrix
docker run -v $(PWD):/app -w=/app ghcr.io/ghostwriter/compliance check {job}

Expand Down
17 changes: 1 addition & 16 deletions compliance.php
Expand Up @@ -7,25 +7,10 @@
use Ghostwriter\Compliance\ValueObject\Tool;

return static function (ComplianceConfiguration $complianceConfiguration): void {
// $complianceConfig->phpVersion(PhpVersion::CURRENT_STABLE);
// $complianceConfiguration->phpVersion(PhpVersion::CURRENT_STABLE);
$complianceConfiguration->phpVersion(PhpVersion::CURRENT_LATEST);
$complianceConfiguration->skip([
PhpVersion::PHP_82,
Tool::CODECEPTION => [PhpVersion::PHP_80],
Tool::COMPOSER_REQUIRE_CHECKER => [PhpVersion::PHP_81],
Tool::EASY_CODING_STANDARD => [PhpVersion::PHP_81],
Tool::GRUMPHP => [PhpVersion::PHP_82],
Tool::INFECTION => [PhpVersion::PHP_82],
Tool::MARKDOWNLINT => [PhpVersion::PHP_82],
Tool::PHAN => [PhpVersion::PHP_82],
Tool::PHPBENCH => [PhpVersion::PHP_82],
Tool::PHPCS => [PhpVersion::PHP_82],
Tool::PHP_CS_FIXER => [PhpVersion::PHP_82],
Tool::PHPUNIT => [PhpVersion::PHP_82],
Tool::PSALM => [PhpVersion::PHP_82],
Tool::RECTOR => [PhpVersion::PHP_82],
// Tool::PHP_MESS_DETECTOR => [PhpVersion::PHP_82],
// Tool::PHP_METRICS => [PhpVersion::PHP_82],
// Tool::PHPSTAN => [PhpVersion::PHP_82],
]);
};
11 changes: 4 additions & 7 deletions composer.json
Expand Up @@ -46,30 +46,27 @@
"symfony/process": "^6.1.0"
},
"require-dev": {
"composer/composer": "^2.2 || ^2.3",
"composer/composer": ">=2.2",
"phpbench/phpbench": "^1.2.5",
"phpunit/phpunit": "^9.5.20",
"psalm/plugin-phpunit": "^0.16.1",
"rector/rector": "^0.13.4",
"roave/infection-static-analysis-plugin": "^1.19.0",
"roave/security-advisories": "dev-latest",
"symplify/easy-coding-standard": "^10.2.8",
"symplify/easy-coding-standard": "^10.2.10",
"vimeo/psalm": "^4.23.0"
},
"replace": {},
"minimum-stability": "stable",
"prefer-stable": true,
"autoload": {
"psr-4": {
"Ghostwriter\\Compliance\\": "src/"
},
"files": []
}
},
"autoload-dev": {
"psr-4": {
"Ghostwriter\\Compliance\\Tests\\": "tests/"
},
"files": []
}
},
"bin": [
"bin/compliance"
Expand Down
42 changes: 24 additions & 18 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions src/Command/AbstractCommand.php
Expand Up @@ -4,15 +4,21 @@

namespace Ghostwriter\Compliance\Command;

use Ghostwriter\Compliance\Compliance;
use Ghostwriter\Compliance\Event\OutputEvent;
use Ghostwriter\Container\Contract\ContainerInterface;
use Ghostwriter\EventDispatcher\Contract\DispatcherInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Style\SymfonyStyle;
use Throwable;
use function sprintf;
use function str_replace;
use function strtolower;

abstract class AbstractCommand extends Command
{
public function __construct(
protected ContainerInterface $container,
protected DispatcherInterface $dispatcher,
protected SymfonyStyle $symfonyStyle
) {
Expand All @@ -23,4 +29,20 @@ public static function getDefaultName(): string
{
return strtolower(str_replace([__NAMESPACE__ . '\\', 'Command'], '', static::class));
}

/**
* @throws Throwable
*/
public function write(string $message): void
{
$this->dispatcher->dispatch(
new OutputEvent([
'::echo::on',
sprintf('::group::%s %s', Compliance::NAME, Compliance::BLACK_LIVES_MATTER),
$message,
'::endgroup::',
'::echo::off',
])
);
}
}
41 changes: 0 additions & 41 deletions src/Command/ChangeWorkingDirectory.php

This file was deleted.

0 comments on commit 47054e1

Please sign in to comment.