Skip to content

Commit 902f631

Browse files
committed
NEXT-35311 - Use k8s runners
1 parent e6e5f49 commit 902f631

File tree

12 files changed

+110
-82
lines changed

12 files changed

+110
-82
lines changed

.gitlab-ci.yml

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ workflow:
2121
# do not run on push, except on protected branches
2222
- if: '$CI_PIPELINE_SOURCE != "push" || ($CI_PIPELINE_SOURCE != "merge_request_event" && $CI_COMMIT_REF_PROTECTED == "true")'
2323

24+
default:
25+
tags:
26+
- shopware-multi-arch
27+
2428
include:
2529
# include library files
2630
- local: .gitlab/lib/rules.yml

.gitlab/base.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ variables:
4040
- !reference [.rules, run]
4141
- when: always
4242
tags:
43-
- shopware
43+
- shopware-multi-arch
4444
before_script:
4545
- echo -e "\e[0Ksection_start:$(date +%s):base_init[collapsed=true]\r\e[0Kbase initialization"
4646
- >
@@ -105,7 +105,7 @@ variables:
105105
.deploy-job:
106106
extends: .long-running
107107
tags:
108-
-
108+
- shopware-multi-arch
109109
before_script: []
110110
rules:
111111
# only sync on protected branches

.gitlab/stages/11-build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ include:
88
stage: lint
99
context: tar://${CI_PROJECT_DIR}/context.tar.gz
1010
destination-image: "${CI_REGISTRY_IMAGE}/ci-e2e"
11-
destination-tag: "$CI_PIPELINE_ID"
11+
destination-tag: "${CI_PIPELINE_ID}"
1212
additional-tags: "${EXTRA_DEV_BUILD_TAGS}"
1313
dockerfile: .gitlab/docker/dev/Dockerfile
1414
enable-scan: "false"

.gitlab/stages/20-unit.yml

+75-8
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,74 @@ PHP integration:
9494
--testsuite integration
9595
--order-by default
9696

97+
PHP bench:
98+
extends: .base-no-setup
99+
stage: unit
100+
tags:
101+
- shopware-amd64
102+
timeout: 30m
103+
allow_failure: true
104+
needs: []
105+
services:
106+
- name: mariadb:11.0
107+
alias: database
108+
entrypoint: [ "sh", "-c", "docker-entrypoint.sh $MYSQL_CMD" ]
109+
- name: redis:7.0
110+
alias: redis
111+
variables:
112+
APP_ENV: "dev"
113+
REDIS_URL: redis://redis:6379
114+
MYSQL_CMD: 'mariadbd'
115+
rules:
116+
# do not run in merge trains
117+
- if: $CI_MERGE_REQUEST_EVENT_TYPE == "merge_train"
118+
when: never
119+
- !reference [ .rules, skip ]
120+
- !reference [ .rules, run ]
121+
- changes:
122+
- '**/*.php'
123+
- '**/*.xml'
124+
- 'composer.json'
125+
126+
before_script:
127+
- !reference [ .scripts, init, composer ]
128+
- mkdir -p config/jwt || true
129+
script:
130+
- php vendor/bin/phpbench run
131+
--report=compressed
132+
97133
Open Api Schema validation:
98134
extends: .base-no-setup
135+
image: ${CI_REGISTRY}/infrastructure/docker-base/ci-build:${CI_BUILD_IMAGE_TAG}
99136
stage: unit
100-
timeout: 2m
101-
needs: []
102-
services:
103-
- name: swaggerapi/swagger-validator-v2:v2.0.5
104-
alias: swagger
137+
timeout: 10m
138+
allow_failure: true
139+
needs: [build image]
140+
tags:
141+
- shopware-amd64
105142
variables:
106143
APP_ENV: "dev"
144+
TEST_WEB_INSTALLER: 1
145+
DATABASE_URL: mysql://root:app@database:3306/root
146+
services:
147+
- name: mysql:8
148+
alias: database
149+
entrypoint:
150+
[
151+
"sh",
152+
"-c",
153+
"docker-entrypoint.sh mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --default-authentication-plugin=mysql_native_password --sql-require-primary-key=ON",
154+
]
155+
- name: "${CI_REGISTRY_IMAGE}/ci-e2e:$CI_PIPELINE_ID"
156+
alias: shopware.test
157+
entrypoint:
158+
[
159+
"sh",
160+
"-c",
161+
"bin/console system:generate-jwt && /entrypoint"
162+
]
163+
variables:
164+
PROJECT_ROOT: /var/www/html
107165
rules:
108166
# do not run in merge trains
109167
- if: $CI_MERGE_REQUEST_EVENT_TYPE == "merge_train"
@@ -116,9 +174,18 @@ Open Api Schema validation:
116174
- "composer.json"
117175
before_script:
118176
- !reference [.scripts, init, composer]
177+
- composer run init:db
178+
- mkdir -p config/jwt || true
179+
- bin/console system:generate-jwt || true
119180
script:
120-
- php ./bin/console open-api:validate http://swagger:8080/validator/debug
121-
- php ./bin/console open-api:validate --api-type=store-api http://swagger:8080/validator/debug
181+
- export STOREFRONT_ID=$(bin/console sales-channel:list --output json | jq -r '.[] | select(.name == "Storefront") | .id')
182+
- export OPENAPI_ACCESS_KEY=$(mysql -u root -h database -papp root -se "SELECT access_key FROM sales_channel WHERE id = 0x${STOREFRONT_ID}";)
183+
- printf "OPENAPI_JSON_URL=http://shopware.test:8000\nSHOPWARE_ADMIN_USERNAME=admin\nSHOPWARE_ADMIN_PASSWORD=shopware\nOPENAPI_ACCESS_KEY=${OPENAPI_ACCESS_KEY}" > .env
184+
- npx @shopware/api-gen@canary loadSchema --apiType=store --filename=storeApiSchema.json
185+
- npx @shopware/api-gen@canary loadSchema --apiType=admin --filename=adminApiSchema.json
186+
- npm i -g @redocly/cli@latest
187+
- redocly lint --skip-rule operation-4xx-response --skip-rule no-server-example.com ./storeApiSchema.json
188+
- redocly lint --skip-rule operation-4xx-response --skip-rule no-server-example.com ./adminApiSchema.json
122189

123190
PHP unit coverage:
124191
extends: .base-no-setup
@@ -241,7 +308,7 @@ PHP Full:
241308
- "php8.3"
242309
FEATURE_ALL: ["false", "major"]
243310
MYSQL_CMD: "mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --default-authentication-plugin=mysql_native_password --sql-require-primary-key=ON"
244-
- MYSQL_IMAGE: mysql:8.0.17
311+
- MYSQL_IMAGE: mysql:8.0.36
245312
- MYSQL_IMAGE: mariadb:10.11
246313
- MYSQL_IMAGE: mariadb:10.11
247314
PREFER_LOWEST: "prefer lowest"

.gitlab/stages/21-security.yml

+10-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,16 @@ Symfony security check:
88
before_script: []
99
script:
1010
- composer install --no-interaction --no-scripts
11-
- curl --location --output local-php-security-checker https://github.com/fabpot/local-php-security-checker/releases/download/v1.0.0/local-php-security-checker_1.0.0_linux_amd64
12-
- echo 'e5b12488ca78bc07c149e9352278bf10667b88a8461caac10154f9a6f5476369 local-php-security-checker' > local-php-security-checker.sha256
11+
- >
12+
if [[ "$(arch)" == "aarch64" ]]; then
13+
export ARCH=arm64
14+
export SHA256SUM=d2c0bd8b3f6059e55a55ece56461d04728eeaad73ece902a8e8078d287721eb3
15+
else
16+
export ARCH=amd64
17+
export SHA256SUM=e5b12488ca78bc07c149e9352278bf10667b88a8461caac10154f9a6f5476369
18+
fi
19+
- curl --location --output local-php-security-checker https://github.com/fabpot/local-php-security-checker/releases/download/v1.0.0/local-php-security-checker_1.0.0_linux_${ARCH}
20+
- echo "${SHA256SUM} local-php-security-checker" > local-php-security-checker.sha256
1321
- sha256sum --check local-php-security-checker.sha256
1422
- chmod +x local-php-security-checker
1523
- ./local-php-security-checker

.gitlab/stages/30-e2e.yml

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
image: shopware/development:8.2-composer-2
66
extends:
77
- .long-running
8+
tags:
9+
- shopware-amd64
810
needs: [Build, "Jest (Administration)"]
911
dependencies: [Build]
1012
services:
@@ -116,6 +118,8 @@ acceptance:
116118
- .long-running
117119
image: mcr.microsoft.com/playwright:v1.41.1-jammy
118120
needs: [build image]
121+
tags:
122+
- shopware-amd64
119123
stage: E2E
120124
rules:
121125
- !reference [.rules, skip]

.gitlab/stages/50-install-nightly.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Shopware Install (onPrem):
77
- name: mariadb:10.11
88
alias: database
99
tags:
10-
- shopware
10+
- shopware-multi-arch
1111
rules:
1212
- if: $CI_PIPELINE_SOURCE == "schedule"
1313
when: always

.gitlab/stages/51-split.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
.split-base:
44
stage: split
55
tags:
6-
- shopware
6+
- shopware-multi-arch
77
image:
88
name: gitlab.shopware.com:5005/infrastructure/docker-base/ci
99
variables:
10-
SPLITSH_ARCHIVE_URL: 'https://github.com/splitsh/lite/releases/download/v1.0.1/lite_linux_amd64.tar.gz'
1110
GIT_DEPTH: '0'
1211
GIT_STRATEGY: 'clone'
1312
needs: [ ]

.gitlab/stages/60-deploy.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Publish entity-schema-types NPM package:
2323
.push split repositories:
2424
stage: deploy
2525
tags:
26-
- shopware
26+
- shopware-multi-arch
2727
image:
2828
name: gitlab.shopware.com:5005/infrastructure/docker-base/ci
2929
needs:
@@ -70,16 +70,16 @@ push split repositories (gitlab):
7070
GITLAB_TOKEN: "${CI_GITLAB_API_TOKEN}"
7171
CI_COMMENT_MESSAGE: |
7272
The following testing branches have been created for you:
73-
73+
7474
- [administration:tmp-${CI_COMMIT_SHORT_SHA}](https://gitlab.shopware.com/shopware/6/product/many-repositories/administration/-/tree/tmp-${CI_COMMIT_SHORT_SHA})
7575
- [storefront:tmp-${CI_COMMIT_SHORT_SHA}](https://gitlab.shopware.com/shopware/6/product/many-repositories/storefront/-/tree/tmp-${CI_COMMIT_SHORT_SHA})
7676
- [core:tmp-${CI_COMMIT_SHORT_SHA}](https://gitlab.shopware.com/shopware/6/product/many-repositories/core/-/tree/tmp-${CI_COMMIT_SHORT_SHA})
7777
- [elasticsearch:tmp-${CI_COMMIT_SHORT_SHA}](https://gitlab.shopware.com/shopware/6/product/many-repositories/elasticsearch/-/tree/tmp-${CI_COMMIT_SHORT_SHA})
78-
78+
7979
More info on how to use these branches can be found in the [handbook](https://handbook.shopware.com/Product/Guides/Engineering/Platform/PipelineTestSuite/PrivateComposerRegistry#creating-branches-for-testing).
80-
80+
8181
---
82-
82+
8383
```shell
8484
composer require \
8585
"shopware/administration:dev-tmp-${CI_COMMIT_SHORT_SHA} as 6.6.x-dev" \

.gitlab/templates/plugin.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ workflow:
146146
default:
147147
image: $DEV_IMAGE
148148
tags:
149-
- shopware
149+
- shopware-amd64
150150
services:
151151
- name: "$MYSQL_IMAGE"
152152
alias: database
@@ -203,6 +203,7 @@ build and validate zip:
203203
before_script:
204204
- *setup_platform_and_plugin_files
205205
script:
206+
- source /root/.bashrc # Workaround until Gitlab fixes the Gitlab Kubernetes runner
206207
- shopware-cli extension zip "${CI_PROJECT_DIR}/custom/plugins/${PLUGIN_NAME}" --git-commit "${CI_COMMIT_SHA}"
207208
- mv ${PLUGIN_NAME}-${CI_COMMIT_SHA}.zip ${PLUGIN_NAME}.zip
208209
- shopware-cli extension validate "${PLUGIN_NAME}.zip"
@@ -335,6 +336,8 @@ template filled:
335336
image: shopware/development:8.2-node-20.10-composer-2
336337
stage: E2E
337338
needs: []
339+
tags:
340+
- shopware-amd64
338341
script:
339342
- *e2e-prepare
340343
- >

.gitlab/templates/theme.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ default:
128128
alias: database
129129
entrypoint: [ "sh", "-c", "docker-entrypoint.sh $MYSQL8_CMD" ]
130130
tags:
131-
- shopware
131+
- shopware-amd64
132132
before_script:
133133
- *base_env_vars
134134
- zip -rq theme.zip .
@@ -244,6 +244,8 @@ template filled:
244244
cypress:
245245
image: shopware/development:8.2-node-20.10-composer-2
246246
stage: E2E
247+
tags:
248+
- shopware-amd64
247249
needs:
248250
- build zip
249251
rules:

src/Core/Framework/Test/Api/ApiDefinition/Generator/OpenApi3Test.php

-59
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22

33
namespace Shopware\Core\Framework\Test\Api\ApiDefinition\Generator;
44

5-
use GuzzleHttp\Client;
65
use PHPUnit\Framework\Attributes\Group;
76
use PHPUnit\Framework\TestCase;
8-
use Shopware\Core\DevOps\Environment\EnvironmentHelper;
9-
use Shopware\Core\Framework\Api\ApiDefinition\DefinitionService;
10-
use Shopware\Core\Framework\Api\Controller\InfoController;
117
use Shopware\Core\Framework\Test\TestCaseBase\KernelLifecycleManager;
128
use Shopware\Core\Framework\Test\TestCaseBase\KernelTestBehaviour;
139
use Shopware\Core\System\SalesChannel\SalesChannel\StoreApiInfoController;
@@ -16,7 +12,6 @@
1612
/**
1713
* @internal
1814
*/
19-
#[Group('slow')]
2015
#[Group('skip-paratest')]
2116
class OpenApi3Test extends TestCase
2217
{
@@ -49,58 +44,4 @@ public function testRequestOpenApi3Json(): void
4944

5045
static::assertSame(200, $response->getStatusCode(), print_r($response->getContent(), true));
5146
}
52-
53-
public function testValidateStoreApiSchema(): void
54-
{
55-
$infoController = KernelLifecycleManager::getKernel()->getContainer()->get(StoreApiInfoController::class);
56-
57-
$response = $infoController->info(new Request());
58-
$schema = $response->getContent();
59-
static::assertIsString($schema);
60-
61-
$this->assertValidSchema($schema);
62-
}
63-
64-
public function testValidateAdminApiSchema(): void
65-
{
66-
$infoController = KernelLifecycleManager::getKernel()->getContainer()->get(InfoController::class);
67-
68-
$response = $infoController->info(new Request());
69-
$schema = $response->getContent();
70-
static::assertIsString($schema);
71-
72-
$this->assertValidSchema($schema);
73-
}
74-
75-
public function testValidateAdminApiSchemaJson(): void
76-
{
77-
$infoController = KernelLifecycleManager::getKernel()->getContainer()->get(InfoController::class);
78-
79-
$response = $infoController->info(new Request(['type' => DefinitionService::TYPE_JSON]));
80-
$schema = $response->getContent();
81-
static::assertIsString($schema);
82-
83-
$this->assertValidSchema($schema);
84-
}
85-
86-
private function assertValidSchema(string $schema): void
87-
{
88-
$client = new Client();
89-
$validatorURL = EnvironmentHelper::getVariable('SWAGGER_VALIDATOR_URL', 'https://validator.swagger.io/validator/debug');
90-
static::assertIsString($validatorURL);
91-
92-
$response = $client->post($validatorURL, [
93-
'json' => json_decode($schema, true, 512, \JSON_THROW_ON_ERROR),
94-
'headers' => [
95-
'Accept' => 'application/json',
96-
],
97-
]);
98-
$content = json_decode((string) $response->getBody(), true, flags: \JSON_THROW_ON_ERROR);
99-
100-
// The CI validator returns an empty response if the schema is valid
101-
// The public Web validator returns an object with an empty schemaValidationMessages array
102-
$messages = $content['schemaValidationMessages'] ?? [];
103-
104-
static::assertEmpty($messages, (string) json_encode($content, \JSON_PRETTY_PRINT));
105-
}
10647
}

0 commit comments

Comments
 (0)