Skip to content

Commit c50f9bf

Browse files
committed
Copy generic CI/CD files
1 parent ca90d66 commit c50f9bf

4 files changed

Lines changed: 50 additions & 28 deletions

File tree

.github/workflows/integration-tests.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
image: yireo/magento2installed:2.4.8-p3
1111
services:
1212
mysql:
13-
image: mysql:8.0
13+
image: yireo/mariadb:10
1414
env:
1515
MYSQL_ROOT_PASSWORD: root
1616
MYSQL_USER: magento2
@@ -30,8 +30,11 @@ jobs:
3030
- name: Checkout sources
3131
uses: actions/checkout@v4
3232

33-
- name: Enable log_bin_trust_function_creators
34-
run: mysql -h mysql -uroot -proot -e "SET GLOBAL log_bin_trust_function_creators=1;"
33+
- name: Apply patch for reporting memory under Alpine
34+
run: cd /tmp/magento && curl -fsSL https://patch-diff.githubusercontent.com/raw/magento/magento2/pull/39216.diff | git apply
35+
36+
- name: Apply patch for changing MySQL client configuration
37+
run: cd /tmp/magento && curl -fsSL https://patch-diff.githubusercontent.com/raw/magento/magento2/pull/40410.diff | git apply
3538

3639
- name: Configure GitLab
3740
run: |
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
return [
3+
'client-mariadb' => [
4+
'disable-ssl',
5+
],
6+
];
7+

.github/workflows/static-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Run Magento 2 PHPStan Tests
3333
run: |
3434
export COMPOSER_NAME=`cat .module.ini | grep COMPOSER_NAME | cut -f2 -d= | tr -d '"'`
35-
export LEVEL=`echo '<?= json_decode(file_get_contents("MODULE.json"), true)["phpstan_level"];' | php`
35+
export LEVEL=$(jq -r '.phpstan_level // 1' MODULE.json)
3636
test -f /tmp/magento/phpstan.neon || echo 'parameters:' > /tmp/magento/phpstan.neon
3737
php -d memory_limit=4G /tmp/magento/vendor/bin/phpstan analyse --level $LEVEL ${GITHUB_WORKSPACE}
3838

Test/Integration/LokiComponentsTestCase.php

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ protected function getObjectManager(): ObjectManagerInterface
5353
return $this->objectManager;
5454
}
5555

56-
protected function getComponentByBlockName(string $blockName
56+
protected function getComponentByBlockName(
57+
string $blockName
5758
): ComponentInterface {
5859
$layout = $this->getObjectManager()->get(LayoutInterface::class);
5960
$block = $layout->getBlock($blockName);
@@ -65,73 +66,81 @@ protected function getComponentByBlockName(string $blockName
6566
return $component;
6667
}
6768

68-
protected function assertComponentExistsOnPage(string $componentName,
69+
protected function assertComponentExistsOnPage(
70+
string $componentName,
6971
bool $debug = false
7072
) {
7173
$component = $this->getComponent($componentName);
7274
$found = $this->existsComponentOnPage($component);
73-
$msg = 'Component "' . $component->getName() . '" not found';
75+
$msg = 'Component "'.$component->getName().'" not found';
7476

7577
if ($debug) {
76-
$msg .= "\n" . $this->getResponseBody();
78+
$msg .= "\n".$this->getResponseBody();
7779
}
7880

7981
$this->assertTrue($found, $msg);
8082
}
8183

82-
protected function assertComponentNotExistsOnPage(string $componentName,
84+
protected function assertComponentNotExistsOnPage(
85+
string $componentName,
8386
bool $debug = false
8487
) {
8588
$component = $this->getComponent($componentName);
8689
$found = $this->existsComponentOnPage($component);
87-
$msg = 'Component "' . $component->getName() . '" found anyway';
90+
$msg = 'Component "'.$component->getName().'" found anyway';
8891
if ($debug) {
89-
$msg .= "\n" . $this->getResponseBody();
92+
$msg .= "\n".$this->getResponseBody();
9093
}
9194

9295
$this->assertFalse($found, $msg);
9396
}
9497

95-
protected function assertElementIdExistsOnPage(string $elementId,
98+
protected function assertElementIdExistsOnPage(
99+
string $elementId,
96100
bool $debug = false
97101
) {
98102
$found = $this->existsElementIdOnPage($elementId);
99-
$msg = 'Element ID "' . $elementId . '" not found';
103+
$msg = 'Element ID "'.$elementId.'" not found';
100104
if ($debug) {
101-
$msg .= "\n" . $this->getResponseBody();
105+
$msg .= "\n".$this->getResponseBody();
102106
}
103107

104108
$this->assertTrue($found, $msg);
105109
}
106110

107-
protected function assertElementIdNotExistsOnPage(string $elementId,
111+
protected function assertElementIdNotExistsOnPage(
112+
string $elementId,
108113
bool $debug = false
109114
) {
110115
$found = $this->existsElementIdOnPage($elementId);
111-
$msg = 'Element ID "' . $elementId . '" found anyway';
116+
$msg = 'Element ID "'.$elementId.'" found anyway';
112117
if ($debug) {
113-
$msg .= "\n" . $this->getResponseBody();
118+
$msg .= "\n".$this->getResponseBody();
114119
}
115120

116121
$this->assertFalse($found, $msg);
117122
}
118123

119-
protected function assertComponentValidators(array $expectedValidators,
124+
protected function assertComponentValidators(
125+
array $expectedValidators,
120126
ComponentInterface $component
121127
) {
122128
foreach ($expectedValidators as $expectedValidator) {
123129
$this->assertContains(
124-
$expectedValidator, $component->getValidators()
130+
$expectedValidator,
131+
$component->getValidators()
125132
);
126133
}
127134
}
128135

129-
protected function assertComponentNoValidators(array $expectedValidators,
136+
protected function assertComponentNoValidators(
137+
array $expectedValidators,
130138
ComponentInterface $component
131139
) {
132140
foreach ($expectedValidators as $expectedValidator) {
133141
$this->assertNotContains(
134-
$expectedValidator, $component->getValidators()
142+
$expectedValidator,
143+
$component->getValidators()
135144
);
136145
}
137146
}
@@ -147,11 +156,13 @@ protected function assertComponentValidation(
147156

148157
if (true === $expectedResult) {
149158
$this->assertTrue(
150-
$result, 'Validation did not succeed for value: ' . $value
159+
$result,
160+
'Validation did not succeed for value: '.$value
151161
);
152162
} else {
153163
$this->assertFalse(
154-
$result, 'Validation did not fail for value: ' . $value
164+
$result,
165+
'Validation did not fail for value: '.$value
155166
);
156167
}
157168

@@ -167,11 +178,11 @@ protected function assertComponentValidation(
167178
protected function existsElementIdOnPage(string $elementId): bool
168179
{
169180
$body = $this->getResponseBody();
170-
if (false === str_contains($body, ' id="' . $elementId . '"')) {
181+
if (false === str_contains($body, ' id="'.$elementId.'"')) {
171182
return false;
172183
}
173184

174-
if (str_contains($body, 'Not rendered: ' . $elementId)) {
185+
if (str_contains($body, 'Not rendered: '.$elementId)) {
175186
return false;
176187
}
177188

@@ -193,12 +204,13 @@ protected function existsComponentOnPage(ComponentInterface $component
193204
$elementId = $this->getObjectManager()->get(IdConvertor::class)
194205
->toElementId($component->getName());
195206
$body = $this->getResponseBody();
196-
if (false === str_contains($body, ' id="' . $elementId . '"')) {
207+
if (false === str_contains($body, ' id="'.$elementId.'"')) {
197208
return false;
198209
}
199210

200211
if (str_contains(
201-
$body, 'Not rendered: ' . $component->getName() . ' '
212+
$body,
213+
'Not rendered: '.$component->getName().' '
202214
)
203215
) {
204216
return false;
@@ -214,7 +226,6 @@ protected function setAsAjaxRequest(): void
214226
$this->getObjectManager()->get(HttpRequest::class)->setHeaders(
215227
$headers
216228
);
217-
218229
}
219230

220231
protected function getValidator(): Validator
@@ -231,6 +242,7 @@ protected function getResponseBody(): string
231242
{
232243
/** @var Http $response */
233244
$response = $this->getResponse();
245+
234246
return $response->getBody();
235247
}
236248
}

0 commit comments

Comments
 (0)