Skip to content

Commit 4b4974d

Browse files
author
Stanislav Idolov
authored
Merge pull request #10 from magento-commerce/Adding-CI
Added CI using GitHub actions
2 parents 34213bd + 9954e40 commit 4b4974d

27 files changed

+144
-87
lines changed

.github/workflows/php.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
17+
- name: Validate composer
18+
run: composer validate
19+
20+
- name: Cache Composer packages
21+
id: composer-cache
22+
uses: actions/cache@v2
23+
with:
24+
path: vendor
25+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
26+
restore-keys: |
27+
${{ runner.os }}-php-
28+
29+
- name: Install dependencies
30+
if: steps.composer-cache.outputs.cache-hit != 'true'
31+
run: composer install --prefer-source --no-interaction
32+
33+
- name: Run unit tests suite
34+
run: php vendor/bin/phpunit --configuration tests/Unit/phpunit.xml.dist
35+
36+
- name: Run code style suite
37+
run: php vendor/bin/phpcs --standard=psr12 src/ --ignore=*.min.css
38+
39+
- name: Run tests code style
40+
run: php vendor/bin/phpcs --standard=psr12 tests/ --ignore=/_files/ -n

.travis.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

composer.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Analyzer/Factory/MftfAnalyzerFactory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Copyright © Magento, Inc. All rights reserved.
45
* See COPYING.txt for license details.

src/Analyzer/Mftf/AbstractEntityAnalyzer.php

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Copyright © Magento, Inc. All rights reserved.
45
* See COPYING.txt for license details.
@@ -14,7 +15,7 @@
1415
*/
1516
abstract class AbstractEntityAnalyzer
1617
{
17-
const DEFAULT_OPERATION_KEY = '*';
18+
public const DEFAULT_OPERATION_KEY = '*';
1819

1920
/**
2021
* @var Report
@@ -69,8 +70,10 @@ public function findMatchingElementByKeyAndValue($beforeElement, $afterElements,
6970
$beforeFieldKey = $beforeElement['attributes'][$elementIdentifier];
7071
$beforeFieldValue = $beforeElement['value'];
7172
foreach ($afterElements as $afterElement) {
72-
if ($afterElement['attributes'][$elementIdentifier] === $beforeFieldKey
73-
&& $afterElement['value'] === $beforeFieldValue) {
73+
if (
74+
$afterElement['attributes'][$elementIdentifier] === $beforeFieldKey
75+
&& $afterElement['value'] === $beforeFieldValue
76+
) {
7477
return $afterElement;
7578
}
7679
}
@@ -185,19 +188,19 @@ public function findAddedElementsInArray(
185188
$operationClass,
186189
$fullOperationTarget
187190
) {
188-
if (is_array($afterArray) || is_object($afterArray)) {
189-
foreach ($afterArray as $newChild) {
190-
if (!isset($newChild['attributes'][$elementIdentifier])) {
191-
continue;
192-
}
193-
$afterFieldKey = $newChild['attributes'][$elementIdentifier];
194-
$matchingElement = $this->findMatchingElement($newChild, $beforeArray, $elementIdentifier);
195-
if ($matchingElement === null) {
196-
$operation = new $operationClass($filenames, $fullOperationTarget . '/' . $afterFieldKey);
197-
$report->add(MftfReport::MFTF_REPORT_CONTEXT, $operation);
198-
}
191+
if (is_array($afterArray) || is_object($afterArray)) {
192+
foreach ($afterArray as $newChild) {
193+
if (!isset($newChild['attributes'][$elementIdentifier])) {
194+
continue;
195+
}
196+
$afterFieldKey = $newChild['attributes'][$elementIdentifier];
197+
$matchingElement = $this->findMatchingElement($newChild, $beforeArray, $elementIdentifier);
198+
if ($matchingElement === null) {
199+
$operation = new $operationClass($filenames, $fullOperationTarget . '/' . $afterFieldKey);
200+
$report->add(MftfReport::MFTF_REPORT_CONTEXT, $operation);
199201
}
200202
}
203+
}
201204
}
202205
/**
203206
* Finds all added child elements in afterArray, compared to beforeArray, using both key and value for matching

src/Analyzer/Mftf/ActionGroupAnalyzer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Copyright © Magento, Inc. All rights reserved.
45
* See COPYING.txt for license details.
@@ -28,8 +29,8 @@
2829
*/
2930
class ActionGroupAnalyzer extends AbstractEntityAnalyzer implements AnalyzerInterface
3031
{
31-
const MFTF_ARGUMENTS_ELEMENT = "{}arguments";
32-
const MFTF_DATA_TYPE = 'actionGroup';
32+
public const MFTF_ARGUMENTS_ELEMENT = "{}arguments";
33+
public const MFTF_DATA_TYPE = 'actionGroup';
3334

3435
/**
3536
* operations array

src/Analyzer/Mftf/DataAnalyzer.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Copyright © Magento, Inc. All rights reserved.
45
* See COPYING.txt for license details.
@@ -28,11 +29,11 @@
2829
*/
2930
class DataAnalyzer extends AbstractEntityAnalyzer implements AnalyzerInterface
3031
{
31-
const MFTF_DATA_FIELD_ELEMENT = "{}data";
32-
const MFTF_VAR_ELEMENT = "{}var";
33-
const MFTF_REQ_ELEMENT = "{}requiredEntity";
34-
const MFTF_ARRAY_ELEMENT = "{}array";
35-
const MFTF_DATA_TYPE = 'entity';
32+
public const MFTF_DATA_FIELD_ELEMENT = "{}data";
33+
public const MFTF_VAR_ELEMENT = "{}var";
34+
public const MFTF_REQ_ELEMENT = "{}requiredEntity";
35+
public const MFTF_ARRAY_ELEMENT = "{}array";
36+
public const MFTF_DATA_TYPE = 'entity';
3637

3738
/**
3839
* MFTF data.xml analyzer
@@ -67,7 +68,7 @@ public function analyze($registryBefore, $registryAfter)
6768
$operation = new DataEntityRemoved($filenames, $operationTarget);
6869
$this->getReport()->add(MftfReport::MFTF_REPORT_CONTEXT, $operation);
6970
continue;
70-
}
71+
}
7172

7273
// Sort Elements
7374
$beforeDataFields = [];
@@ -132,7 +133,7 @@ public function analyze($registryBefore, $registryAfter)
132133
// Validate <var> fields
133134
foreach ($beforeVarFields as $beforeField) {
134135
$beforeFieldKey = $beforeField['attributes']['key'];
135-
$matchingElement = $this->findMatchingElement($beforeField, $afterVarFields,'key');
136+
$matchingElement = $this->findMatchingElement($beforeField, $afterVarFields, 'key');
136137
if ($matchingElement === null) {
137138
$operation = new DataEntityVarRemoved(
138139
$filenames,

src/Analyzer/Mftf/MetadataAnalyzer.php

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Copyright © Magento, Inc. All rights reserved.
45
* See COPYING.txt for license details.
@@ -22,7 +23,7 @@
2223
*/
2324
class MetadataAnalyzer extends AbstractEntityAnalyzer implements AnalyzerInterface
2425
{
25-
const MFTF_DATA_TYPE = 'operation';
26+
public const MFTF_DATA_TYPE = 'operation';
2627

2728
/**
2829
* MFTF test.xml analyzer
@@ -60,14 +61,14 @@ public function analyze($registryBefore, $registryAfter)
6061
}
6162

6263
// Validate metadata attribute changes
63-
$this->matchAndValidateAttributes(
64-
$beforeEntity['attributes'],
65-
$afterEntities[$module][$entityName]['attributes'],
66-
$this->getReport(),
67-
$filenames,
68-
[AbstractEntityAnalyzer::DEFAULT_OPERATION_KEY => MetadataChanged::class],
69-
$operationTarget
70-
);
64+
$this->matchAndValidateAttributes(
65+
$beforeEntity['attributes'],
66+
$afterEntities[$module][$entityName]['attributes'],
67+
$this->getReport(),
68+
$filenames,
69+
[AbstractEntityAnalyzer::DEFAULT_OPERATION_KEY => MetadataChanged::class],
70+
$operationTarget
71+
);
7172

7273
// Validate child elements removed
7374
$this->recursiveCompare(
@@ -117,8 +118,14 @@ public function analyze($registryBefore, $registryAfter)
117118
* @param Report $report
118119
* @return void
119120
*/
120-
public function recursiveCompare($beforeEntity, $afterEntity, $operationClass, $operationTarget, $filenames, $report)
121-
{
121+
public function recursiveCompare(
122+
$beforeEntity,
123+
$afterEntity,
124+
$operationClass,
125+
$operationTarget,
126+
$filenames,
127+
$report
128+
) {
122129
$beforeChildren = $beforeEntity['value'] ?? [];
123130
$afterChildren = $afterEntity['value'] ?? [];
124131
if (!is_array($beforeChildren)) {

src/Analyzer/Mftf/PageAnalyzer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Copyright © Magento, Inc. All rights reserved.
45
* See COPYING.txt for license details.
@@ -21,8 +22,8 @@
2122
*/
2223
class PageAnalyzer extends AbstractEntityAnalyzer implements AnalyzerInterface
2324
{
24-
const MFTF_SECTION_ELEMENT = "{}section";
25-
const MFTF_DATA_TYPE = 'page';
25+
public const MFTF_SECTION_ELEMENT = "{}section";
26+
public const MFTF_DATA_TYPE = 'page';
2627

2728
/**
2829
* MFTF page.xml analyzer

src/Analyzer/Mftf/SectionAnalyzer.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Copyright © Magento, Inc. All rights reserved.
45
* See COPYING.txt for license details.
@@ -25,9 +26,9 @@
2526
*/
2627
class SectionAnalyzer extends AbstractEntityAnalyzer implements AnalyzerInterface
2728
{
28-
const MFTF_ELEMENT_ELEMENT = "{}element";
29-
const MFTF_DATA_TYPE = 'section';
30-
const MFTF_ELEMENT_PARAM = 'parameterized';
29+
public const MFTF_ELEMENT_ELEMENT = "{}element";
30+
public const MFTF_DATA_TYPE = 'section';
31+
public const MFTF_ELEMENT_PARAM = 'parameterized';
3132

3233
/**
3334
* operations array
@@ -122,7 +123,7 @@ public function analyze($registryBefore, $registryAfter)
122123
if (!isset($beforeAttributes[self::MFTF_ELEMENT_PARAM])) {
123124
$operation = new SectionElementParameterizedChanged(
124125
$filenames,
125-
"$operationTarget/$beforeFieldKey/". self::MFTF_ELEMENT_PARAM
126+
"$operationTarget/$beforeFieldKey/" . self::MFTF_ELEMENT_PARAM
126127
);
127128
$this->getReport()->add(MftfReport::MFTF_REPORT_CONTEXT, $operation);
128129
}

0 commit comments

Comments
 (0)