Skip to content

Github actions - ease testing and configurable path #27

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

Closed
wants to merge 17 commits into from
Closed
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
9 changes: 9 additions & 0 deletions .github/workflows/phpcompatibility.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: PHPCompatibility
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: 7.0-7.1
run: docker run --rm -v $PWD:/code domw/phpcompatibility phpcs --standard=PHPCompatibility --runtime-set testVersion 7.0-7.1 --colors --ignore=./Test/ ./
9 changes: 9 additions & 0 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: phpcs
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Magento 2 Ruleset
run: docker run --rm -v $PWD:/code domw/phpcs phpcs --colors --standard=Magento2 ./
9 changes: 9 additions & 0 deletions .github/workflows/phpcsfixer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: php-cs-fixer
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: PHP CS Fixer
run: docker run --rm -v $PWD:/code domw/php-cs-fixer php-cs-fixer fix --dry-run --diff --stop-on-violation --allow-risky=yes ./
15 changes: 15 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: PHPStan
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: MilesChou/composer-action@master
with:
args: config http-basic.repo.magento.com 7bdd660a63609d2af9fcbc033a9eae8d 77c0cedb4871620c63acbd82aeb92f38
- uses: MilesChou/composer-action@master
with:
args: install --prefer-dist --ignore-platform-reqs
- name: PHPStan
run: docker run --rm -v $PWD:/code domw/phpstan phpstan analyze ./
15 changes: 15 additions & 0 deletions .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: PHPUnit
on: ["push", "pull_request"]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: MilesChou/composer-action@master
with:
args: config http-basic.repo.magento.com 7bdd660a63609d2af9fcbc033a9eae8d 77c0cedb4871620c63acbd82aeb92f38
- uses: MilesChou/composer-action@master
with:
args: install --prefer-dist --ignore-platform-reqs
- name: PHPUnit
run: vendor/bin/phpunit -c Test/phpunit.xml Test/
23 changes: 23 additions & 0 deletions .github/workflows/xmllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: xmllint
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: MilesChou/composer-action@master
with:
args: config http-basic.repo.magento.com 7bdd660a63609d2af9fcbc033a9eae8d 77c0cedb4871620c63acbd82aeb92f38
- uses: MilesChou/composer-action@master
with:
args: install --prefer-dist --ignore-platform-reqs
- name: XML Lint
run: |
docker run --rm -v $PWD:/code domw/xmllint --noout ./etc/config.xml --schema ./vendor/magento/module-store/etc/config.xsd
docker run --rm -v $PWD:/code domw/xmllint --noout ./etc/adminhtml/menu.xml --schema ./vendor/magento/module-backend/etc/menu.xsd
docker run --rm -v $PWD:/code domw/xmllint --noout ./etc/adminhtml/routes.xml --schema ./vendor/magento/framework/App/etc/routes.xsd
docker run --rm -v $PWD:/code domw/xmllint --noout ./etc/adminhtml/system.xml --schema vendor/magento/module-config/etc/system.xsd
docker run --rm -v $PWD:/code domw/xmllint --noout ./etc/acl.xml --schema ./vendor/magento/framework/Acl/etc/acl.xsd
docker run --rm -v $PWD:/code domw/xmllint --noout ./etc/cron_groups.xml --schema ./vendor/magento/module-cron/etc/cron_groups.xsd
docker run --rm -v $PWD:/code domw/xmllint --noout ./etc/crontab.xml --schema ./vendor/magento/module-cron/etc/crontab.xsd
docker run --rm -v $PWD:/code domw/xmllint --noout ./etc/module.xml --schema ./vendor/magento/framework/Module/etc/module.xsd
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ checkstyle:
checkquality:
vendor/bin/phpstan analyse

xmllint --noout --schema vendor/magento/module-store/etc/config.xsd etc/config.xml
xmllint --noout --schema vendor/magento/module-backend/etc/menu.xsd etc/adminhtml/menu.xml
xmllint --noout --schema vendor/magento/framework/App/etc/routes.xsd etc/adminhtml/routes.xml
xmllint --noout --schema vendor/magento/module-config/etc/system.xsd etc/adminhtml/system.xml
xmllint --noout --schema vendor/magento/framework/Acl/etc/acl.xsd etc/acl.xml
xmllint --noout --schema vendor/magento/module-cron/etc/cron_groups.xsd etc/cron_groups.xml
xmllint --noout --schema vendor/magento/module-cron/etc/crontab.xsd etc/crontab.xml
Expand Down
21 changes: 18 additions & 3 deletions Storage/FileStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,30 @@
namespace Baldwin\UrlDataIntegrityChecker\Storage;

use Baldwin\UrlDataIntegrityChecker\Exception\SerializationException;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Store\Model\ScopeInterface;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Filesystem;

class FileStorage extends AbstractStorage implements StorageInterface
{
const CONFIG_PATH = 'url/checker/path';

private $filesystem;
private $scopeConfig;

public function __construct(
Filesystem $filesystem
Filesystem $filesystem,
ScopeConfigInterface $scopeConfig
) {
$this->filesystem = $filesystem;
$this->scopeConfig = $scopeConfig;
}

public function write(string $identifier, array $data): bool
{
$directory = $this->filesystem->getDirectoryWrite(DirectoryList::TMP);
$directory = $this->filesystem->getDirectoryWrite($this->getPath() ?: DirectoryList::TMP);
$directory->create();
$filename = $this->getFilename($identifier);

Expand All @@ -39,7 +46,7 @@ public function write(string $identifier, array $data): bool

public function read(string $identifier): array
{
$directory = $this->filesystem->getDirectoryRead(DirectoryList::TMP);
$directory = $this->filesystem->getDirectoryRead($this->getPath() ?: DirectoryList::TMP);
$filename = $this->getFilename($identifier);

$data = '';
Expand All @@ -57,4 +64,12 @@ private function getFilename(string $identifier): string
{
return 'baldwin-url-data-integrity-checker-' . $identifier . '.json';
}

private function getPath(): string
{
return $this->scopeConfig->getValue(
self::CONFIG_PATH,
ScopeInterface::SCOPE_STORE
);
}
}
7 changes: 7 additions & 0 deletions etc/acl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
<resource id="Magento_Catalog::catalog">
<resource id="Baldwin_UrlDataIntegrityChecker::catalog_data_integrity" title="Data Integrity Checker" translate="title" sortOrder="100"/>
</resource>
<resource id="Magento_Backend::stores">
<resource id="Magento_Backend::stores_settings">
<resource id="Magento_Config::config">
<resource id="Baldwin_UrlDataIntegrityChecker::config_baldwin_urldataintegritychecker" title="url"/>
</resource>
</resource>
</resource>
</resource>
</resources>
</acl>
Expand Down
20 changes: 20 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="baldwin" translate="label" sortOrder="500">
<label>Baldwin</label>
</tab>
<section id="url" sortOrder="10" showInWebsite="0" showInStore="0" showInDefault="1" translate="label">
<label>Url Data Integrity Checker</label>
<tab>baldwin</tab>
<resource>Baldwin_UrlDataIntegrityChecker::config_baldwin_urldataintegritychecker</resource>
<group id="checker" sortOrder="10" showInWebsite="0" showInStore="0" showInDefault="1" translate="label">
<label>Config</label>
<field id="path" type="text" sortOrder="10" showInWebsite="0" showInStore="0" showInDefault="1" translate="label">
<label>Path</label>
<comment>Path where to store json files eg tmp or media</comment>
</field>
</group>
</section>
</system>
</config>
10 changes: 10 additions & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<url>
<checker>
<path>tmp</path>
</checker>
</url>
</default>
</config>
23 changes: 7 additions & 16 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
parameters:
level: max
inferPrivatePropertyTypeFromConstructor: true
paths:
- .
bootstrapFiles:
- vendor/bitexpert/phpstan-magento/autoload.php
excludes_analyse:
- %currentWorkingDirectory%/vendor/*
- 'vendor'
ignoreErrors:
- '/ has no return typehint specified./'

- message: '/Use service contracts to persist entities in favour of Magento\\Cron\\Model\\Schedule\:\:save\(\) method/'
path: Cron/ScheduleJob.php

- message: '/Call to deprecated method save\(\) of class Magento\\Framework\\Model\\AbstractModel/'
path: Cron/ScheduleJob.php

- message: '/Parameter \#1 \$autoload_function of function spl_autoload_register expects callable\(string\)\: void, array\(Magento\\Framework\\TestFramework\\Unit\\Autoloader\\GeneratedClassesAutoloader/'
path: Test/bootstrap.php
- '#typehint#'
- '#Factory#'
- '#Use service contracts to persist entities#'
- '#Call to deprecated method save#'
- '#Parameter \#1 \$autoload_function of function spl_autoload_register#'
reportUnmatchedIgnoredErrors: false