Skip to content

Commit

Permalink
Feature: Github actions (#11)
Browse files Browse the repository at this point in the history
* Feature: Github actions

* Fix phpcs

* Remove unused classes

* Change codeception

* Disable propel generation

* Fix setting

* Add event behavior

* Fix path

* Disable phpstan

* Remove cycle dependency
  • Loading branch information
sourcecube authored Dec 13, 2022
1 parent c00c81a commit 42b57b9
Show file tree
Hide file tree
Showing 112 changed files with 701 additions and 341 deletions.
3 changes: 0 additions & 3 deletions .coveralls.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ trim_trailing_whitespace = true
[*.bat]
end_of_line = crlf

[*.json]
[{*.json,*.yml}]
indent_style = space
indent_size = 2
indent_size = 2
35 changes: 35 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI

on:
pull_request:
branches: [ master ]

jobs:
continous-integration:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-versions: [ "7.4" ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, dom, fileinfo, pgsql, json
coverage: xdebug #optional
- name: Get composer cache directory
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composercache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies and run ci tasks
run: make install ci
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
The MIT License (MIT)

Copyright (c) 2018 FOND OF GmbH
Copyright (c) 2022 FOND OF GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.PHONY: install
install:
composer install

.PHONY: phpcs
phpcs:
./vendor/bin/phpcs --standard=./vendor/spryker/code-sniffer/Spryker/ruleset.xml ./src/FondOfSpryker/* ./tests/*

.PHONY: phpcbf
phpcbf:
./vendor/bin/phpcbf --standard=./vendor/spryker/code-sniffer/Spryker/ruleset.xml ./src/FondOfSpryker/* ./tests/*

.PHONY: phpstan
phpstan:
./vendor/bin/phpstan --memory-limit=-1 analyse ./src/FondOfSpryker ./tests

.PHONY: codeception
codeception:
./vendor/bin/codecept run --env standalone

.PHONY: ci
ci: phpcs codeception
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# fond-of-spryker/contentful
[![PHP from Travis config](https://img.shields.io/travis/php-v/symfony/symfony.svg)](https://php.net/)
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://packagist.org/packages/fond-of-spryker/contentful)

A Spryker-Contentful connector.
A Spryker-Contentful connector.
Import content from contentful to storage and updates it via cronjob.

## Install
Expand All @@ -26,7 +25,7 @@ $this->application->addRouter((new ContentfulRouter())->setSsl(false));
new ContentfulConsole(),
```

### 4. Add configs to your shop config file or in config/Shared/config_default.php
### 4. Add configs to your shop config file or in config/Shared/config_default.php
Example configuration
```
// API-Key
Expand Down Expand Up @@ -145,4 +144,4 @@ Object (Json)
# Pages
- If the contentful entry has a "Indentifier" field (URL) it will be imported as page with the given route via IdentifierImporterPlugin.
- Add an additional ResourceCreator to add custom logic to a special contentful entry type.
- More documentation soon
- More documentation soon
25 changes: 22 additions & 3 deletions codeception.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
namespace: FondOfSpryker
namespace: fond-of-spryker/contentful
suites:
unit:
path: .

settings:
shuffle: true
lint: true
bootstrap: _bootstrap.php

bootstrap: _bootstrap.php

paths:
tests: tests
Expand All @@ -17,4 +18,22 @@ paths:
coverage:
enabled: true
include:
- src/*.php
- src/FondOfSpryker/*.php

modules:
enabled:
- \FondOfCodeception\Module\Spryker
config:
\FondOfCodeception\Module\Spryker:
generate_transfer: false
generate_map_classes: false
generate_propel_classes: false

env:
standalone:
modules:
config:
\FondOfCodeception\Module\Spryker:
generate_transfer: true
generate_map_classes: true
generate_propel_classes: true
39 changes: 22 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
"description": "A contentful connector for spryker.",
"license": "MIT",
"authors": [
{
"name": "Markus Nörenberg",
"email": "noerenberg.markus@gmail.com"
},
{
"name": "Daniel Rose",
"email": "daniel-rose@gmx.de"
Expand All @@ -21,22 +17,23 @@
}
],
"require": {
"php": ">=7.3",
"spryker/twig": "^3.8.2",
"spryker/storage": "^3.14.0",
"php": ">=7.4",
"ext-json": "*",
"aptoma/twig-markdown": "2.0.0",
"contentful/contentful": "^6.0.0",
"michelf/php-markdown": "1.9",
"spryker/category-storage": "^2.4",
"spryker/event-behavior": "^1.24",
"spryker/key-builder": "^1.1",
"spryker/locale": "^3.3.0",
"spryker/storage": "^3.14.0",
"spryker/store": "^1.12.1",
"contentful/contentful": "^6.0.0",
"aptoma/twig-markdown": "2.0.0",
"michelf/php-markdown": "1.9"
"spryker/twig": "^3.8.2"
},
"require-dev": {
"spryker/code-sniffer": "^0.14.7",
"codeception/codeception": "^2.5",
"mikey179/vfsstream": "^1.6",
"phpro/grumphp": "^0.14",
"sebastian/phpcpd": "^4.1",
"php-coveralls/php-coveralls": "^2.0"
"fond-of-codeception/spryker": "^1.0",
"spryker/code-sniffer": "*",
"spryker-sdk/phpstan-spryker": "*"
},
"suggest": {
"fond-of-spryker/contentful-router": "Allows to route to contentful pages in spryker"
Expand All @@ -50,7 +47,15 @@
},
"autoload-dev": {
"psr-4": {
"FondOfSpryker\\": "tests/FondOfSpryker/"
"FondOfSpryker\\": "tests/FondOfSpryker/",
"Generated\\":"src/Generated/",
"Orm\\Zed\\": "src/Orm/Zed/"
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
14 changes: 0 additions & 14 deletions grumphp.yml

This file was deleted.

7 changes: 7 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
parameters:
level: 5
reportUnmatchedIgnoredErrors: false
scanDirectories:
- src/Orm/Zed
ignoreErrors:
- '#.* on an unknown class Generated\\(Client|Glue|Service|Yves|Zed)\\.*#'
2 changes: 1 addition & 1 deletion src/FondOfSpryker/Client/Contentful/ContentfulClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function getNavigationUrlBy(ContentfulNavigationUrlRequestTransfer $reque
* @param string $url
* @param string $localeName
*
* @return string[]|null
* @return array<string>|null
*/
public function matchUrl(string $url, string $localeName): ?array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function getNavigationUrlBy(ContentfulNavigationUrlRequestTransfer $reque
* @param string $url
* @param string $localeName
*
* @return string[]|null
* @return array<string>|null
*/
public function matchUrl(string $url, string $localeName): ?array;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,24 @@

class ContentfulDependencyProvider extends AbstractDependencyProvider
{
/**
* @var string
*/
public const KV_STORAGE = 'KV_STORAGE';

/**
* @var string
*/
public const CLIENT_SEARCH = 'CLIENT_SEARCH';

/**
* @var string
*/
public const CONTENTFUL_SEARCH_QUERY_PLUGIN = 'CONTENTFUL_SEARCH_QUERY_PLUGIN';

/**
* @var string
*/
public const CONTENTFUL_SEARCH_QUERY_EXPANDER_PLUGINS = 'CONTENTFUL_SEARCH_QUERY_EXPANDER_PLUGINS';

/**
Expand Down
4 changes: 2 additions & 2 deletions src/FondOfSpryker/Client/Contentful/ContentfulFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function createContentfulEntryStorageReader(): ContentfulEntryStorageRead
{
return new ContentfulEntryStorageReader(
$this->getStorage(),
$this->createEntryKeyBuilder()
$this->createEntryKeyBuilder(),
);
}

Expand All @@ -43,7 +43,7 @@ public function createContentfulNavigationStorageReader(): ContentfulNavigationS
{
return new ContentfulNavigationStorageReader(
$this->getStorage(),
$this->createNavigationUrlKeyBuilder()
$this->createNavigationUrlKeyBuilder(),
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/FondOfSpryker/Client/Contentful/Matcher/UrlMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(KeyBuilderInterface $keyBuilder, StorageClientInterf
* @param string $url
* @param string $localeName
*
* @return string[]|null
* @return array<string>|null
*/
public function matchUrl(string $url, string $localeName): ?array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface UrlMatcherInterface
* @param string $url
* @param string $localeName
*
* @return string[]|null
* @return array<string>|null
*/
public function matchUrl(string $url, string $localeName): ?array;
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected function createSearchQuery(): Query
*/
protected function addFulltextSearchToQuery(Query $baseQuery): Query
{
if (!empty($this->searchString)) {
if ($this->searchString) {
$matchQuery = $this->createFulltextSearchQuery($this->searchString);
} else {
$matchQuery = new MatchAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function getEntryBy(ContentfulEntryRequestTransfer $request): ContentfulE
$storageData = $this->storageClient->get($storageKey);

$response = new ContentfulEntryResponseTransfer();
if (empty($storageData)) {
if (!$storageData) {
$response->setSuccessful(false);
$response->setErrorMessage(sprintf('ContentfulEntry not found: "%s"', $storageKey));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function getNavigationUrlBy(ContentfulNavigationUrlRequestTransfer $reque
$storageData = $this->storageClient->get($storageKey);

$response = new ContentfulNavigationUrlResponseTransfer();
if (empty($storageData)) {
if (!$storageData) {
$response->setSuccessful(false);
$response->setErrorMessage(sprintf('Entry not found: "%s"', $storageKey));

Expand Down
Loading

0 comments on commit 42b57b9

Please sign in to comment.