Skip to content

Commit 28e3a4d

Browse files
committed
ci(git): Copy generic CI/CD files
1 parent 00abd4a commit 28e3a4d

7 files changed

Lines changed: 221 additions & 73 deletions

File tree

.github/workflows/compile.yml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
magento_version: ['2.4.5-p14', '2.4.7-p4', '2.4.7-p7', '2.4.8', '2.4.8-p1', '2.4.8-p2', '2.4.8-p3']
10+
magento_version: ['2.4.7-p7', '2.4.8-p1', '2.4.8-p4', '2.4.9']
1111
container:
1212
image: yireo/magento2installed:${{ matrix.magento_version }}
1313
steps:
@@ -16,44 +16,61 @@ jobs:
1616

1717
- name: Testing for MODULE.json file
1818
run: |
19-
test -f MODULE.json || echo "SKIP_JOB=true" >> $GITHUB_ENV
19+
(test -f MODULE.json || echo "SKIP_JOB=true" >> $GITHUB_ENV) || true
2020
2121
- name: Check Magento version
2222
if: env.SKIP_JOB != 'true'
2323
run: |
2424
jq -e --arg v "${{ matrix.magento_version }}" '.skip_magento_versions[]? | select(. == $v)' MODULE.json && echo "SKIP_JOB=true" >> $GITHUB_ENV || true
2525
26+
- name: Cleanup PHP
27+
if: env.SKIP_JOB != 'true'
28+
run: |
29+
test -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini || true
30+
2631
- name: Setting up module variables
2732
if: env.SKIP_JOB != 'true'
2833
run: |
2934
echo COMPOSER_NAME=`jq '.name' composer.json -r` >> $GITHUB_ENV
3035
echo MAGENTO_MODULE=`jq '.module_name' MODULE.json -r` >> $GITHUB_ENV
3136
32-
- name: Configure Yireo GitLab
37+
- name: Configure GitLab
3338
if: env.SKIP_JOB != 'true'
3439
run: |
3540
test -n "${{ secrets.GITLAB_TOKEN }}" || exit 0
3641
cd /tmp/magento
37-
ls ${GITHUB_WORKSPACE}
38-
test -f ${GITHUB_WORKSPACE}/.github/workflows/composer-additional.sh && source ${GITHUB_WORKSPACE}/.github/workflows/composer-additional.sh
39-
test -f ${GITHUB_WORKSPACE}/.github/workflows/composer-${{ matrix.magento_version }}.sh && source ${GITHUB_WORKSPACE}/.github/workflows/composer-${{ matrix.magento_version }}.sh
4042
composer config gitlab-domains gitlab.yireo.com
41-
composer config --global --auth http-basic.gitlab.yireo.com yireo "${{ secrets.GITLAB_TOKEN }}"
43+
composer config --global --auth gitlab-token.gitlab.yireo.com "${{ secrets.GITLAB_TOKEN }}"
4244
composer config repositories.loki-third-party composer https://gitlab.yireo.com/api/v4/group/loki-third-party/-/packages/composer/packages.json
4345
composer config repositories.loki-checkout composer https://gitlab.yireo.com/api/v4/group/loki-checkout/-/packages/composer/packages.json
46+
composer config repositories.loki-checkout-dev composer https://gitlab.yireo.com/api/v4/group/loki-checkout-dev/-/packages/composer/packages.json
47+
48+
- name: Configure Magento Marketplace
49+
if: env.SKIP_JOB != 'true'
50+
run: |
51+
test -n "${{ secrets.MAGENTO_MARKETPLACE_PUBLIC_KEY }}" || exit 0
52+
composer config --global --auth http-basic.repo.magento.com "${{ secrets.MAGENTO_MARKETPLACE_PUBLIC_KEY }}" "${{ secrets.MAGENTO_MARKETPLACE_PRIVATE_KEY }}"
53+
54+
- name: Configure composer
55+
if: env.SKIP_JOB != 'true'
56+
run: |
57+
cd /tmp/magento
58+
composer config --global --auth github-oauth.github.com "${{ secrets.COMPOSER_GITHUB_TOKEN }}"
59+
test -f $GITHUB_WORKSPACE/.github/workflows/composer-additional.sh && source $GITHUB_WORKSPACE/.github/workflows/composer-additional.sh || true
60+
test -f $GITHUB_WORKSPACE/.github/workflows/composer-${MAGENTO_VERSION}.sh && source $GITHUB_WORKSPACE/.github/workflows/composer-${MAGENTO_VERSION}.sh || true
4461
4562
- name: Add module source
4663
if: env.SKIP_JOB != 'true'
4764
run: |
4865
cp -R ${GITHUB_WORKSPACE} /tmp/magento/package-source
4966
cd /tmp/magento
5067
composer config repositories.local-source path package-source/
51-
composer require --prefer-source ${COMPOSER_NAME}:@dev
68+
composer require -n --prefer-source ${COMPOSER_NAME}:@dev
5269
5370
- name: Run Magento 2 compilation
5471
if: env.SKIP_JOB != 'true'
5572
run: |
5673
cd /tmp/magento
5774
bin/magento module:enable --all
58-
php -dmemory_limit=-1 bin/magento setup:di:compile
75+
php -dzend.enable_gc=0 -drealpath_cache_size=64M -drealpath_cache_ttl=7200 -dopcache.enable_cli=1 -dopcache.memory_consumption=512 -dopcache.interned_strings_buffer=64 -dopcache.max_accelerated_files=100000 -dmemory_limit=-1 bin/magento setup:di:compile
5976

.github/workflows/get-modules.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
// phpcs:ignoreFile
3+
4+
require 'vendor/autoload.php';
5+
use Magento\Framework\Component\ComponentRegistrar;
6+
$moduleNames = array_keys((new ComponentRegistrar)->getPaths('module'));
7+
$disableModules = [];
8+
9+
// @todo PayPal, LoginAsCustomer, Swissup, Magento_SampleData, newrelic
10+
if (in_array('disable-core=true', $argv)) {
11+
foreach ($moduleNames as $moduleName) {
12+
$matches = ['paypal', 'swissup', 'newrelic', 'loginascustomer'];
13+
foreach ($matches as $match) {
14+
if (stristr($moduleName, $match)) {
15+
$disableModules[] = $moduleName;
16+
}
17+
}
18+
}
19+
}
20+
21+
if (in_array('disable-sample-data=true', $argv)) {
22+
foreach ($moduleNames as $moduleName) {
23+
if (stristr($moduleName, 'sampledata')) {
24+
$disableModules[] = $moduleName;
25+
}
26+
}
27+
}
28+
29+
if (in_array('disable-adobe=true', $argv)) {
30+
foreach ($moduleNames as $moduleName) {
31+
if (stristr($moduleName, 'adobe')) {
32+
$disableModules[] = $moduleName;
33+
}
34+
}
35+
}
36+
37+
if (in_array('disable-graphql=true', $argv)) {
38+
foreach ($moduleNames as $moduleName) {
39+
if (stristr($moduleName, 'graphql')) {
40+
$disableModules[] = $moduleName;
41+
}
42+
}
43+
}
44+
45+
if (in_array('disable-inventory=true', $argv)) {
46+
foreach ($moduleNames as $moduleName) {
47+
if (stristr($moduleName, '_inventory')) {
48+
$disableModules[] = $moduleName;
49+
}
50+
}
51+
}
52+
53+
echo implode(',', $disableModules).PHP_EOL;
54+

.github/workflows/integration-tests.yml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,18 @@ jobs:
3333
run: |
3434
test -d $GITHUB_WORKSPACE/Test/Integration || echo "SKIP_JOB=true" >> $GITHUB_ENV
3535
36+
- name: Cleanup PHP
37+
if: env.SKIP_JOB != 'true'
38+
run: |
39+
test -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini || true
40+
3641
- name: Apply patch for reporting memory under Alpine
3742
if: env.SKIP_JOB != 'true'
38-
run: cd /tmp/magento && curl -fsSL https://patch-diff.githubusercontent.com/raw/magento/magento2/pull/39216.diff | git apply
43+
run: cd /tmp/magento && curl -fsSL https://patch-diff.githubusercontent.com/raw/magento/magento2/pull/39216.diff | git apply || true
3944

4045
- name: Apply patch for changing MySQL client configuration
4146
if: env.SKIP_JOB != 'true'
42-
run: cd /tmp/magento && curl -fsSL https://patch-diff.githubusercontent.com/raw/magento/magento2/pull/40410.diff | git apply
47+
run: cd /tmp/magento && curl -fsSL https://patch-diff.githubusercontent.com/raw/magento/magento2/pull/40410.diff | git apply || true
4348

4449
- name: Setting up module variables
4550
if: env.SKIP_JOB != 'true'
@@ -52,18 +57,32 @@ jobs:
5257
run: |
5358
test -n "${{ secrets.GITLAB_TOKEN }}" || exit 0
5459
cd /tmp/magento
55-
test -f $GITHUB_WORKSPACE/.github/workflows/composer-additional.sh && source $GITHUB_WORKSPACE/.github/workflows/composer-additional.sh
56-
test -f $GITHUB_WORKSPACE/.github/workflows/composer-${MAGENTO_VERSION}.sh && source $GITHUB_WORKSPACE/.github/workflows/composer-${MAGENTO_VERSION}.sh
57-
composer config --auth gitlab-token.gitlab.yireo.com ${{ secrets.GITLAB_TOKEN }}
60+
composer config --auth gitlab-token.gitlab.yireo.com "${{ secrets.GITLAB_TOKEN }}"
61+
composer config repositories.loki-third-party composer https://gitlab.yireo.com/api/v4/group/loki-third-party/-/packages/composer/packages.json
5862
composer config repositories.loki-checkout composer https://gitlab.yireo.com/api/v4/group/loki-checkout/-/packages/composer/packages.json
63+
composer config repositories.loki-checkout-dev composer https://gitlab.yireo.com/api/v4/group/loki-checkout-dev/-/packages/composer/packages.json
64+
65+
- name: Configure Magento Marketplace
66+
if: env.SKIP_JOB != 'true'
67+
run: |
68+
test -n "${{ secrets.MAGENTO_MARKETPLACE_PUBLIC_KEY }}" || exit 0
69+
composer config --global --auth http-basic.repo.magento.com "${{ secrets.MAGENTO_MARKETPLACE_PUBLIC_KEY }}" "${{ secrets.MAGENTO_MARKETPLACE_PRIVATE_KEY }}"
70+
71+
- name: Configure composer
72+
if: env.SKIP_JOB != 'true'
73+
run: |
74+
cd /tmp/magento
75+
composer config --global --auth github-oauth.github.com "${{ secrets.COMPOSER_GITHUB_TOKEN }}"
76+
test -f $GITHUB_WORKSPACE/.github/workflows/composer-additional.sh && source $GITHUB_WORKSPACE/.github/workflows/composer-additional.sh || true
77+
test -f $GITHUB_WORKSPACE/.github/workflows/composer-${MAGENTO_VERSION}.sh && source $GITHUB_WORKSPACE/.github/workflows/composer-${MAGENTO_VERSION}.sh || true
5978
6079
- name: Add module source
6180
if: env.SKIP_JOB != 'true'
6281
run: |
6382
cp -R ${GITHUB_WORKSPACE} /tmp/magento/package-source
6483
cd /tmp/magento
6584
composer config repositories.local-source path package-source/
66-
composer require --prefer-source -- ${COMPOSER_NAME}:@dev yireo/magento2-integration-test-helper
85+
composer require -n --prefer-source -- ${COMPOSER_NAME}:@dev yireo/magento2-integration-test-helper
6786
6887
- name: Run Magento 2 Integration Tests
6988
if: env.SKIP_JOB != 'true'
@@ -72,5 +91,5 @@ jobs:
7291
cp -R ${GITHUB_WORKSPACE}/.github/workflows/integration-tests/* .
7392
php ../../../vendor/bin/phpunit --atleast-version 9 && cp phpunit9.xml phpunit.xml
7493
php ../../../vendor/bin/phpunit --atleast-version 10 && cp phpunit10.xml phpunit.xml
75-
php -d memory_limit=4G ../../../vendor/bin/phpunit -c phpunit.xml ../../../vendor/$COMPOSER_NAME/Test/Integration
94+
php -d memory_limit=-1 ../../../vendor/bin/phpunit -c phpunit.xml ../../../vendor/$COMPOSER_NAME/Test/Integration
7695

.github/workflows/magento-install.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ if [ "${ready:-0}" -ne 1 ]; then
3333
echo "OpenSearch NOT OK, exiting"
3434
exit 1
3535
fi
36-
36+
37+
DISABLE_MODULES=`php $GITHUB_WORKSPACE/.github/workflows/get-modules.php disable-graphql=$DISABLE_GRAPHQL disable-inventory=$DISABLE_INVENTORY disable-adobe=$DISABLE_ADOBE`
38+
3739
cd /tmp/magento
3840
php -dmemory_limit=-1 bin/magento setup:install \
3941
--base-url="${MAGENTO_BASE_URL}" \
@@ -58,7 +60,11 @@ php -dmemory_limit=-1 bin/magento setup:install \
5860
--session-save-redis-host=redis \
5961
--session-save-redis-port=6379 \
6062
--cache-backend-redis-server=redis \
61-
--cache-backend-redis-port=6379
63+
--cache-backend-redis-port=6379 \
64+
--disable-modules="$DISABLE_MODULES"
65+
66+
bin/magento deploy:mode:set developer
67+
bin/magento cache:disable full_page
6268

6369
cd /tmp/magento/pub/
6470
nohup php -S 0.0.0.0:8888 >/tmp/php-server.log 2>&1 &

.github/workflows/playwright.yml

Lines changed: 54 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ jobs:
3535
OPENSEARCH_JAVA_OPTS: "-Xms128m -Xmx128m"
3636
OPENSEARCH_INITIAL_ADMIN_PASSWORD: "admin"
3737
MAGENTO_VERSION: "2.4.8-p3"
38+
DISABLE_INVENTORY: true
39+
DISABLE_GRAPHQL: true
40+
DISABLE_ADOBE: true
3841
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }}
3942

4043
services:
@@ -47,22 +50,22 @@ jobs:
4750
MYSQL_ROOT_PASSWORD: root
4851
options: >-
4952
--health-cmd="mysqladmin ping"
50-
--health-interval=10s
53+
--health-interval=1s
5154
--health-timeout=5s
5255
--health-retries=3
5356
5457
redis:
5558
image: redis:latest
5659
options: >-
5760
--health-cmd="redis-cli ping"
58-
--health-interval=10s
61+
--health-interval=1s
5962
--health-timeout=5s
6063
--health-retries=3
6164
6265
opensearch:
6366
image: yireo/opensearch
6467
env:
65-
OPENSEARCH_JAVA_OPTS: "-Xms128m -Xmx128m"
68+
OPENSEARCH_JAVA_OPTS: "-Xms256m -Xmx256m"
6669
OPENSEARCH_INITIAL_ADMIN_PASSWORD: "admin"
6770

6871
steps:
@@ -72,84 +75,93 @@ jobs:
7275
fetch-depth: 1
7376

7477
- name: Detecting Playwright tests
78+
run: test -d $GITHUB_WORKSPACE/Test/Playwright || echo "SKIP_JOB=true" >> $GITHUB_ENV || true
79+
80+
- name: Cleanup PHP
81+
if: env.SKIP_JOB != 'true'
7582
run: |
76-
test -d $GITHUB_WORKSPACE/Test/Playwright || echo "SKIP_JOB=true" >> $GITHUB_ENV
83+
test -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && rm -f /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini || true
84+
85+
- name: Configure Git safe directory
86+
if: env.SKIP_JOB != 'true'
87+
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
7788

7889
- name: Setting up module variables
7990
if: env.SKIP_JOB != 'true'
8091
run: |
8192
echo COMPOSER_NAME=`jq '.name' composer.json -r` >> $GITHUB_ENV
8293
echo MAGENTO_MODULE=`jq '.module_name' MODULE.json -r` >> $GITHUB_ENV
8394
84-
- name: Setup Magento
95+
- name: Configure GitLab
8596
if: env.SKIP_JOB != 'true'
8697
run: |
98+
test -n "${{ secrets.GITLAB_TOKEN }}" || exit 0
8799
cd /tmp/magento
100+
composer config gitlab-domains gitlab.yireo.com
101+
composer config --global --auth gitlab-token.gitlab.yireo.com "${{ secrets.GITLAB_TOKEN }}"
102+
composer config repositories.loki-third-party composer https://gitlab.yireo.com/api/v4/group/loki-third-party/-/packages/composer/packages.json
103+
composer config repositories.loki-checkout composer https://gitlab.yireo.com/api/v4/group/loki-checkout/-/packages/composer/packages.json
104+
composer config repositories.loki-checkout-dev composer https://gitlab.yireo.com/api/v4/group/loki-checkout-dev/-/packages/composer/packages.json
88105
89-
if [ -n "${GITLAB_TOKEN}" ]; then
90-
composer config gitlab-domains gitlab.yireo.com
91-
composer config --global --auth http-basic.gitlab.yireo.com yireo "${GITLAB_TOKEN}"
92-
composer config repositories.loki-third-party composer https://gitlab.yireo.com/api/v4/group/loki-third-party/-/packages/composer/packages.json
93-
composer config repositories.loki-checkout composer https://gitlab.yireo.com/api/v4/group/loki-checkout/-/packages/composer/packages.json
94-
fi
106+
- name: Configure Magento Marketplace
107+
if: env.SKIP_JOB != 'true'
108+
run: |
109+
test -n "${{ secrets.MAGENTO_MARKETPLACE_PUBLIC_KEY }}" || exit 0
110+
composer config --global --auth http-basic.repo.magento.com "${{ secrets.MAGENTO_MARKETPLACE_PUBLIC_KEY }}" "${{ secrets.MAGENTO_MARKETPLACE_PRIVATE_KEY }}"
95111
96-
test -f "$GITHUB_WORKSPACE/.github/workflows/composer-additional.sh" && source "$GITHUB_WORKSPACE/.github/workflows/composer-additional.sh"
97-
test -f "$GITHUB_WORKSPACE/.github/workflows/composer-${MAGENTO_VERSION}.sh" && source "$GITHUB_WORKSPACE/.github/workflows/composer-${MAGENTO_VERSION}.sh"
112+
- name: Configure composer
113+
if: env.SKIP_JOB != 'true'
114+
run: |
115+
cd /tmp/magento
116+
composer config --global --auth github-oauth.github.com "${{ secrets.COMPOSER_GITHUB_TOKEN }}"
117+
test -f $GITHUB_WORKSPACE/.github/workflows/composer-additional.sh && source $GITHUB_WORKSPACE/.github/workflows/composer-additional.sh || true
118+
test -f $GITHUB_WORKSPACE/.github/workflows/composer-${MAGENTO_VERSION}.sh && source $GITHUB_WORKSPACE/.github/workflows/composer-${MAGENTO_VERSION}.sh || true
98119
99-
composer config repositories.local-source "{\"type\": \"path\", \"url\": \"$GITHUB_WORKSPACE\", \"options\": {\"symlink\": false}}"
100-
composer require --prefer-source -- "${COMPOSER_NAME}:@dev" loki-checkout/magento2-core-cli:@dev loki-checkout/magento2-functional-tests:@dev yireo/magento2-enable-module-sequence
120+
- name: Add module source
121+
if: env.SKIP_JOB != 'true'
122+
run: |
123+
cp -R ${GITHUB_WORKSPACE} /tmp/magento/package-source
124+
cd /tmp/magento
125+
composer config repositories.local-source path /tmp/magento/package-source
126+
composer require -n --prefer-source -- "${COMPOSER_NAME}:@dev" loki-checkout/magento2-core-cli:@dev loki-checkout/magento2-sample-data:@dev loki-checkout/magento2-functional-tests:@dev yireo/magento2-enable-module-sequence:@dev
101127
102-
$GITHUB_WORKSPACE/.github/workflows/magento-install.sh
128+
- name: Setup Magento
129+
if: env.SKIP_JOB != 'true'
130+
run: |
131+
cd /tmp/magento
132+
$GITHUB_WORKSPACE/.github/workflows/magento-install.sh || true
103133
104-
bin/magento deploy:mode:set developer
105134
bin/magento module:enable Yireo_EnableModuleSequence
106-
bin/magento module:sequence LokiCheckout_FunctionalTests
107-
bin/magento module:sequence LokiCheckout_CoreCli
108-
bin/magento module:sequence "${MAGENTO_MODULE}"
135+
bin/magento module:sequence LokiCheckout_FunctionalTests LokiCheckout_SampleData LokiCheckout_CoreCli "${MAGENTO_MODULE}"
109136
bin/magento setup:upgrade
137+
bin/magento loki-checkout:sample-data:add-product
110138
bin/magento loki-checkout:modules:dump
111139
112-
magerun2 config:store:set loki_functional_tests/general/token loki -n
113-
114-
echo "Copying Magento to workspace..."
115-
mkdir -p $GITHUB_WORKSPACE/magento/
116-
cp -R /tmp/magento/* $GITHUB_WORKSPACE/magento/
117-
118-
echo "Magento setup complete"
140+
magerun2 config:store:set loki_checkout/functional_tests/token loki -n
119141
120142
- name: Verify Magento installation
121143
if: env.SKIP_JOB != 'true'
122144
run: |
123145
echo "Verifying Magento installation in workspace..."
124-
ls -la $GITHUB_WORKSPACE/magento/
125-
test -f $GITHUB_WORKSPACE/magento/bin/magento || (echo "ERROR: Magento installation verification failed" && exit 1)
146+
test -f /tmp/magento/bin/magento || (echo "ERROR: Magento installation verification failed" && exit 1) || true
126147
echo "Magento installation verified successfully"
127148
128149
- name: Run Playwright tests
129150
if: env.SKIP_JOB != 'true'
130151
run: |
131-
echo "Starting Playwright tests..."
132-
echo "GITHUB_WORKSPACE: $GITHUB_WORKSPACE"
133-
echo "MAGENTO_MODULE: $MAGENTO_MODULE"
134-
135-
if [ ! -d "$GITHUB_WORKSPACE/magento" ]; then
136-
echo "ERROR: magento directory not found"
137-
exit 1
138-
fi
139-
140152
echo "Navigating to Playwright test directory..."
141-
cd $GITHUB_WORKSPACE/magento/vendor/loki-checkout/magento2-functional-tests/Test/Playwright/
153+
cd /tmp/magento/vendor/loki-checkout/magento2-functional-tests/Test/Playwright/
142154
143155
echo "Installing npm dependencies..."
156+
# @todo: Add package-json.lock and run npm ci
144157
npm install
145158
npx playwright install chromium
146159
147160
echo "Creating .env file..."
148161
printf "TEST_URL=http://127.0.0.1:8888\nTEST_TOKEN=loki\n" > .env
149-
cat .env
150162
151-
echo "Running Playwright tests for project: ${MAGENTO_MODULE}"
152-
CI=true MAGENTO_ROOT=$GITWORK_WORKSPACE/magento npx playwright test --project=${MAGENTO_MODULE}
163+
echo "Running Playwright tests for project ${MAGENTO_MODULE}"
164+
CI=true TEST_TOKEN=loki MAGENTO_ROOT=/tmp/magento npx playwright test --project=${MAGENTO_MODULE}
153165
154166
- name: Upload Playwright report
155167
if: ${{ !cancelled() }}

0 commit comments

Comments
 (0)