Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
# Conflicts:
#	.gitignore
  • Loading branch information
Torsten Freyda committed Mar 30, 2024
2 parents c610801 + d222e00 commit 5bba22c
Show file tree
Hide file tree
Showing 53 changed files with 1,917 additions and 351 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/gitleaks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: gitleaks

on: [push,pull_request]

jobs:
gitleaks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: gitleaks-action
uses: gitleaks/gitleaks-action@v1.6.0
102 changes: 102 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Testing

on:
push:
branches:
- dev
- master
pull_request:
branches:
- dev
- master
workflow_dispatch:

env:
MODULE_NAME: MuckiSearchPlugin
COMPOSER_NAME: muckiware/search-plugin
TEST_DATABASE_URL: "mysql://root:root@127.0.0.1:3306/db_test"

jobs:
ci-current:
name: SW ${{ matrix.shopware-versions }}, PHP ${{ matrix.php-versions }}, MySQL ${{ matrix.mysql-versions }}
runs-on: ubuntu-latest
strategy:
max-parallel: 15
fail-fast: false
matrix:
php-versions: [ '8.1', '8.2' ]
mysql-versions: [ '8.0' ]
shopware-versions: [ 'v6.5.3.0' ]
services:
mysql:
image: mysql:${{ matrix.mysql-versions }}
env:
MYSQL_DATABASE: db_test
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306

steps:
- name: Install PHP
uses: shivammathur/setup-php@master
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, xdebug, curl, dom, fileinfo, gd, iconv, intl, json, xml, mbstring, pdo, phar, zip, sodium, pdo_mysql
tools: composer:2.6.6

- name: "Check PHP Version"
run: php -v

- name: "Check Composer Version"
run: composer -V

- name: "Check PHP Extensions"
run: php -m

- name: "checkout Shopware"
uses: actions/checkout@v3
with:
repository: shopware/production
ref: 'flex'

- name: "Checkout ${{ env.COMPOSER_NAME }}"
uses: actions/checkout@v3
with:
path: custom/plugins/${{ env.MODULE_NAME }}

- name: "Get composer cache directory"
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: "Cache Composer dependencies"
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ matrix.operating-system }}-${{ matrix.php-versions }}-${{ matrix.shopware-versions }}-${{ hashFiles('**/composer.lock') }}

- name: "Install Shopware dependencies"
# Install Shopware with --no-dev to prevent that dev-tools of the module got in conflict with the tools of shopware
run: |
composer req shopware/administration:${{ matrix.shopware-versions }} shopware/core:${{ matrix.shopware-versions }} shopware/elasticsearch:${{ matrix.shopware-versions }} shopware/storefront:${{ matrix.shopware-versions }} --no-update
composer install --no-dev
- name: "Install DEV-Tools"
working-directory: custom/plugins/${{ env.MODULE_NAME }}
run: |
composer remove shopware/* --no-update
composer install
- name: "Install code-Tools"
run: composer req phpunit/phpunit:^9.5 phpstan/phpstan

- name: "Install Shopware"
run: |
echo APP_ENV=dev >> .env
echo APP_URL=http://localhost >> .env
echo DATABASE_URL=${{ env.TEST_DATABASE_URL }} >> .env
echo APP_SECRET=secretf0rt3st >> .env
bin/console system:install --basic-setup
- name: "Run PHPUnit Tests"
run: ./vendor/bin/phpunit --configuration="custom/plugins/${{ env.MODULE_NAME }}"

19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,21 @@ bin/console plugin:install -a MuckiSearchPlugin
- Go to Extensions -> My extensions
- Select the _Configure_-menu item of the Mucki Search Plugin
- Activate the plugin
- Enter the Elasticsearch Server connection host and port. Usually localhost:9200
- Enter the Elasticsearch Server connection host and port. Usually localhost:9200


## Uninstallation
Removes plugin and removes all plugin data
```shell
bin/console plugin:uninstall MuckiSearchPlugin
```
Removes plugin but keeps the plugin data
```shell
bin/console plugin:uninstall MuckiSearchPlugin --keep-user-data
```

## Testing
Start unit test
```shell
./vendor/bin/phpunit --configuration="custom/plugins/MuckiSearchPlugin" --testsuite "migration"
```
11 changes: 11 additions & 0 deletions bin/static-analyze-autoloader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php declare(strict_types=1);

use Symfony\Component\Dotenv\Dotenv;

$projectRoot = $_SERVER['PROJECT_ROOT'] ?? dirname(__DIR__, 4);

require_once $projectRoot . '/vendor/autoload.php';

if (file_exists($projectRoot . '/.env')) {
(new Dotenv())->usePutEnv()->load($projectRoot . '/.env');
}
17 changes: 12 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name" : "muckiware/search-plugin",
"description" : "Muckiware Search Plugin",
"version": "v0.2.1",
"description" : "Shopware 6 search extension plugin for Elasticsearch server integration",
"version": "v0.3.0",
"type" : "shopware-platform-plugin",
"license" : "MIT",
"authors": [
Expand All @@ -13,20 +13,27 @@
"shopware-plugin-class" : "MuckiSearchPlugin\\MuckiSearchPlugin",
"copyright" : "(c) by muckiware",
"label" : {
"de-DE" : "Mucki Search Erweiterung",
"en-GB" : "Mucki Search Plugin"
"de-DE" : "Shopware 6 search extension plugin for Elasticsearch server integration",
"en-GB" : "Shopware 6 search extension plugin for Elasticsearch server integration"
}
},
"require" : {
"php" : ">= 8.1",
"shopware/core": "~6.5.2",
"shopware/core": "^6.5.3",
"shopware/administration": "^6.5.3",
"shopware/storefront": "^6.5.3",
"elasticsearch/elasticsearch": "^8.11"
},
"autoload" : {
"psr-4" : {
"MuckiSearchPlugin\\" : "src/"
}
},
"autoload-dev": {
"psr-4": {
"MuckiSearchPlugin\\": "tests/"
}
},
"config": {
"allow-plugins": {
"symfony/runtime": true
Expand Down
6 changes: 6 additions & 0 deletions phpstan-ignore.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
parameters:
ignoreErrors:
-
message: "#^Class Shopware\\\\Core\\\\Checkout\\\\Payment\\\\Exception\\\\AsyncPaymentProcessException constructor invoked with 3 parameters, 2 required\\.$#"
count: 2
path: src/PaymentHandler/AbstractKlarnaPaymentHandler.php
18 changes: 18 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
parameters:
level: 8
treatPhpDocTypesAsCertain: false
checkMissingIterableValueType: false
inferPrivatePropertyTypeFromConstructor: true
reportUnmatchedIgnoredErrors: false
# This can be useful from Shopware 6.4.15.0, but as long as we support lower versions we ignore it
checkGenericClassInNonGenericObjectType: false
tmpDir: var/cache/phpstan

featureToggles:
disableCheckMissingIterableValueType: false

paths:
- src

bootstrapFiles:
- bin/static-analyze-autoloader.php
24 changes: 24 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="tests/TestBootstrap.php"
executionOrder="random">
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
<php>
<ini name="error_reporting" value="-1"/>
<server name="KERNEL_CLASS" value="Shopware\Core\Kernel"/>
<env name="APP_ENV" value="test"/>
<env name="APP_DEBUG" value="1"/>
<env name="SHELL_VERBOSITY" value="1"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled" />
</php>
<testsuites>
<testsuite name="MuckiSearch Testsuite">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
23 changes: 15 additions & 8 deletions src/Commands/Checkup.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(
parent::__construct(self::$defaultName);
}

public function setContainer(ContainerInterface $container)
public function setContainer(ContainerInterface $container): void
{
$this->container = $container;
}
Expand All @@ -56,16 +56,18 @@ public function setContainer(ContainerInterface $container)
*/
public function getContainer(): ContainerInterface
{
if (!$this->container) {
throw new \LogicException('Cannot retrieve the container from a non-booted kernel.');
}
return $this->container;
}

/**
* @internal
*/
public function configure() {
$this
->setDescription('Checkup Elasticsearch server items')
;
public function configure(): void
{
$this->setDescription('Checkup Elasticsearch server items');
}

/**
Expand All @@ -74,10 +76,15 @@ public function configure() {
* @return int
* @throws \Exception
*/
public function execute(InputInterface $input, OutputInterface $output): int {
public function execute(InputInterface $input, OutputInterface $output): int
{
$serverInfoAsString = $this->searchClientFactory->createSearchClient()->getServerInfoAsString();
if($serverInfoAsString) {

$output->writeln($this->searchClientFactory->createSearchClient()->getServerInfoAsString());
$output->writeln($serverInfoAsString);
return self::SUCCESS;
}

return self::SUCCESS;
return self::FAILURE;
}
}
20 changes: 11 additions & 9 deletions src/Commands/Indexing.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
class Indexing extends Command
{
/**
* @var null
* @var ContainerInterface|null
*/
protected $container = null;
protected ?ContainerInterface $container = null;

public function __construct(
protected PluginSettings $settings,
Expand All @@ -45,7 +45,7 @@ public function __construct(
parent::__construct(self::$defaultName);
}

public function setContainer(ContainerInterface $container)
public function setContainer(ContainerInterface $container): void
{
$this->container = $container;
}
Expand All @@ -55,16 +55,18 @@ public function setContainer(ContainerInterface $container)
*/
public function getContainer(): ContainerInterface
{
if (!$this->container) {
throw new \LogicException('Cannot retrieve the container from a non-booted kernel.');
}
return $this->container;
}

/**
* @internal
*/
public function configure() {
$this
->setDescription('Added shop items into Elasticsearch database')
;
public function configure(): void
{
$this->setDescription('Added shop items into Elasticsearch database');
}

/**
Expand All @@ -73,8 +75,8 @@ public function configure() {
* @return int
* @throws \Exception
*/
public function execute(InputInterface $input, OutputInterface $output): int {

public function execute(InputInterface $input, OutputInterface $output): int
{
$executionStart = microtime(true);

$output->writeln( 'Starting search indexing');
Expand Down
Loading

0 comments on commit 5bba22c

Please sign in to comment.