Skip to content

Commit f5bb922

Browse files
Initial commit
0 parents  commit f5bb922

51 files changed

Lines changed: 2245 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
name: End-2-End Testing
2+
on:
3+
push:
4+
pull_request:
5+
types:
6+
- opened
7+
- labeled
8+
9+
jobs:
10+
secrets-gate:
11+
if: ${{ github.event.label.name == 'Run E2E tests' || github.event.action != 'labeled' }}
12+
runs-on: ubuntu-latest
13+
outputs:
14+
is-secret-set: ${{ steps.is-secret-set.outputs.has_COLISSIMO_credentials }}
15+
steps:
16+
- id: is-secret-set
17+
env:
18+
COLISSIMO_ACCOUNT_ID: ${{ secrets.COLISSIMO_ACCOUNT_ID }}
19+
COLISSIMO_ACCOUNT_PASSWORD: ${{ secrets.COLISSIMO_ACCOUNT_PASSWORD }}
20+
if: "${{ env.COLISSIMO_ACCOUNT_ID != '' && env.COLISSIMO_ACCOUNT_PASSWORD != '' }}"
21+
run: echo "has_COLISSIMO_credentials=true" >> $GITHUB_OUTPUT
22+
23+
# Remove flag used to trigger the e2e tests
24+
remove_flag:
25+
if: ${{ contains(github.event.*.labels.*.name, 'Run E2E tests') }}
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Remove "Run E2E tests" label
29+
uses: actions/github-script@v5
30+
with:
31+
script: |
32+
github.rest.issues.removeLabel({
33+
issue_number: ${{ github.event.issue.number || github.event.number }},
34+
owner: context.repo.owner,
35+
repo: context.repo.repo,
36+
name: "Run E2E tests"
37+
})
38+
39+
e2e-tests:
40+
needs:
41+
- secrets-gate
42+
if: needs.secrets-gate.outputs.is-secret-set == 'true'
43+
strategy:
44+
fail-fast: false
45+
matrix:
46+
include:
47+
- PHP_VERSION: php83-fpm
48+
MAGENTO_VERSION: 2.4.8-p3
49+
- PHP_VERSION: php84-fpm
50+
MAGENTO_VERSION: 2.4.8-p3
51+
52+
runs-on: ubuntu-latest
53+
env:
54+
PHP_VERSION: ${{ matrix.PHP_VERSION }}
55+
MAGENTO_VERSION: ${{ matrix.MAGENTO_VERSION }}
56+
COLISSIMO_ACCOUNT_ID: ${{ secrets.COLISSIMO_ACCOUNT_ID }}
57+
COLISSIMO_ACCOUNT_PASSWORD: ${{ secrets.COLISSIMO_ACCOUNT_PASSWORD }}
58+
HYVA_SSH_PRIVATE_KEY: ${{ secrets.HYVA_SSH_PRIVATE_KEY }}
59+
GOOGLE_MAPS_API_KEY: ${{ secrets.GOOGLE_MAPS_API_KEY }}
60+
MAGENTO_COMPOSER_USERNAME: ${{ secrets.MAGENTO_COMPOSER_USERNAME }}
61+
MAGENTO_COMPOSER_PASSWORD: ${{ secrets.MAGENTO_COMPOSER_PASSWORD }}
62+
MAGENTO_URL: http://magento.test
63+
steps:
64+
- uses: actions/checkout@v5
65+
66+
- name: Start Docker containers
67+
run: |
68+
docker compose -f .github/workflows/templates/docker-compose.yaml pull --quiet
69+
docker compose -f .github/workflows/templates/docker-compose.yaml up -d --no-build
70+
until docker exec magento-project-community-edition php bin/magento --version > /dev/null 2>&1; do
71+
echo "Waiting for Magento to be ready..."; sleep 10;
72+
done
73+
74+
- name: Install Hyvä theme and Hyvä Checkout
75+
run: |
76+
docker exec magento-project-community-edition /bin/bash /data/install-hyva.sh
77+
78+
- name: Configure Magento composer credentials and repositories
79+
run: |
80+
docker exec magento-project-community-edition composer config repositories.magento composer https://repo.magento.com
81+
docker exec magento-project-community-edition composer config http-basic.repo.magento.com ${{ env.MAGENTO_COMPOSER_USERNAME }} ${{ env.MAGENTO_COMPOSER_PASSWORD }}
82+
83+
- name: Upload the code into the docker container
84+
run: |
85+
sed -i '/version/d' ./composer.json && \
86+
docker cp $(pwd) magento-project-community-edition:/data/extensions/ && \
87+
docker exec magento-project-community-edition ./install-composer-package -W controlaltdelete/magento2-colissimo-hyva-checkout:@dev
88+
docker exec magento-project-community-edition ./install-composer-package imaginaerum/magento2-language-fr-fr
89+
90+
- name: Activate the extension
91+
run: |
92+
docker exec magento-project-community-edition php /data/merge-config.php
93+
docker exec magento-project-community-edition ./retry "php bin/magento module:enable LaPoste_Colissimo ControlAltDelete_ColissimoHyva"
94+
docker exec magento-project-community-edition ./retry "php bin/magento setup:upgrade --no-interaction --keep-generated"
95+
docker exec magento-project-community-edition ./retry "php bin/magento cache:flush"
96+
97+
- name: Configure Colissimo
98+
run: |
99+
docker exec magento-project-community-edition ./retry "bin/magento config:set --lock-env lpc_advanced/lpc_general/id_webservices ${{ env.COLISSIMO_ACCOUNT_ID }}"
100+
docker exec magento-project-community-edition ./retry "bin/magento config:set --lock-env lpc_advanced/lpc_general/connectionMode login"
101+
docker exec magento-project-community-edition magerun2 config:store:set carriers/colissimo/active 1
102+
docker exec magento-project-community-edition ./retry "bin/magento config:set --lock-env carriers/lpc_group/pr_enable 1"
103+
docker exec magento-project-community-edition ./retry "bin/magento config:set --lock-env carriers/lpc_group/pr_free 1"
104+
docker exec magento-project-community-edition ./retry "bin/magento config:set --lock-env carriers/lpc_group/pr_label 'Colissimo Pickup Retrait'"
105+
docker exec magento-project-community-edition ./retry "bin/magento config:set --lock-env controlaltdelete_colissimo_hyva/google_maps/api_key ${{ env.GOOGLE_MAPS_API_KEY }}"
106+
docker exec magento-project-community-edition ./retry "bin/magento config:set --lock-env shipping/origin/country_id FR"
107+
docker exec magento-project-community-edition ./retry "bin/magento config:set --lock-env general/country/default FR"
108+
docker exec magento-project-community-edition ./retry "bin/magento config:set --lock-env general/locale/code fr_FR"
109+
ENCODED_PASSWORD=$(echo -n "${{ env.COLISSIMO_ACCOUNT_PASSWORD }}" | base64)
110+
docker exec magento-project-community-edition magerun2 config:store:set lpc_advanced/lpc_general/pwd_webservices "$ENCODED_PASSWORD"
111+
112+
- name: Prepare Magento
113+
run: |
114+
sudo echo "127.0.0.1 magento.test" | sudo tee -a /etc/hosts
115+
docker exec magento-project-community-edition /bin/bash ./change-base-url $MAGENTO_URL/
116+
docker exec magento-project-community-edition ./retry "bin/magento config:set admin/security/session_lifetime 1440"
117+
docker exec magento-project-community-edition ./retry "bin/magento config:set web/cookie/cookie_lifetime 86400"
118+
docker exec magento-project-community-edition ./retry "php bin/magento setup:di:compile"
119+
docker exec magento-project-community-edition ./retry "php bin/magento setup:static-content:deploy -f"
120+
docker exec magento-project-community-edition ./retry "php bin/magento indexer:reindex"
121+
122+
- name: Check if we can reach the Magento frontend
123+
run: |
124+
curl --fail-with-body -k -v -w "%{http_code}" $MAGENTO_URL/
125+
126+
- name: Check if we can reach the Magento backend
127+
run: |
128+
curl --fail-with-body -k -v -w "%{http_code}" $MAGENTO_URL/admin/
129+
130+
- name: Install Playwright dependencies
131+
run: |
132+
npm install
133+
npx playwright install --with-deps
134+
135+
- name: Run Playwright tests
136+
id: run_tests
137+
run: |
138+
BASE_URL="$MAGENTO_URL/" npx playwright test
139+
140+
- name: Dump docker-compose logs
141+
if: failure()
142+
run: |
143+
docker compose -f .github/workflows/templates/docker-compose.yaml logs magento > magento.log
144+
145+
- name: Upload artifacts
146+
uses: actions/upload-artifact@v4
147+
if: failure()
148+
with:
149+
name: E2E logs - ${{ matrix.PHP_VERSION }} - ${{ matrix.MAGENTO_VERSION }}
150+
path: |
151+
test-results
152+
playwright-report
153+
magento-logs
154+
magento.log
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: '3'
2+
3+
services:
4+
magento:
5+
image: ghcr.io/controlaltdelete-nl/magento2-in-a-box/magento-project-community-edition:${PHP_VERSION}-magento${MAGENTO_VERSION}-sample-data
6+
container_name: magento-project-community-edition
7+
ports:
8+
- "80:80"
9+
environment:
10+
- COLISSIMO_ACCOUNT_ID
11+
- COLISSIMO_ACCOUNT_PASSWORD
12+
- HYVA_SSH_PRIVATE_KEY
13+
- GOOGLE_MAPS_API_KEY
14+
volumes:
15+
- ../../../magento-logs:/data/var/log
16+
- ./magento/install-hyva.sh:/data/install-hyva.sh
17+
- ./magento/merge-config.php.stub:/data/merge-config.php.stub
18+
- ./magento/merge-config.php:/data/merge-config.php
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
set -x
4+
5+
# Check if $HYVA_SSH_PRIVATE_KEY is set
6+
if [ -z "$HYVA_SSH_PRIVATE_KEY" ]; then
7+
echo "Variable \$HYVA_SSH_PRIVATE_KEY is not set"
8+
exit 1
9+
fi
10+
11+
eval `ssh-agent -s`
12+
mkdir -p ~/.ssh/ && touch ~/.ssh/known_hosts
13+
echo "$HYVA_SSH_PRIVATE_KEY" | ssh-add -
14+
ssh-keyscan -t rsa gitlab.hyva.io >> ~/.ssh/known_hosts
15+
16+
composer config repositories.hyva-themes/magento2-theme-module git git@gitlab.hyva.io:hyva-themes/magento2-theme-module.git
17+
composer config repositories.hyva-themes/magento2-reset-theme git git@gitlab.hyva.io:hyva-themes/magento2-reset-theme.git
18+
composer config repositories.hyva-themes/magento2-email-module git git@gitlab.hyva.io:hyva-themes/magento2-email-module.git
19+
composer config repositories.hyva-themes/magento2-default-theme git git@gitlab.hyva.io:hyva-themes/magento2-default-theme.git
20+
composer config repositories.hyva-themes/magento2-default-theme-csp git git@gitlab.hyva.io:hyva-themes/magento2-default-theme-csp.git
21+
composer config repositories.hyva-themes/magento2-compat-module-fallback git git@gitlab.hyva.io:hyva-themes/magento2-compat-module-fallback.git
22+
composer config repositories.hyva-themes/magento2-order-cancellation-webapi git git@gitlab.hyva.io:hyva-themes/magento2-order-cancellation-webapi.git
23+
composer config repositories.hyva-themes/hyva-checkout git git@gitlab.hyva.io:hyva-checkout/checkout.git
24+
composer config repositories.hyva-themes/hyva-compat/magento2-mollie-theme-bundle git git@gitlab.hyva.io:hyva-themes/hyva-compat/magento2-mollie-theme-bundle.git
25+
composer config repositories.hyva-themes/magento2-base-layout-reset git git@gitlab.hyva.io:hyva-themes/magento2-base-layout-reset.git
26+
27+
composer require hyva-themes/magento2-default-theme-csp hyva-themes/magento2-hyva-checkout
28+
29+
bin/magento setup:upgrade --keep-generated
30+
31+
# Enable CSP
32+
magerun2 config:store:set system/default/csp/policies/storefront/scripts/inline 0
33+
magerun2 config:store:set system/default/csp/policies/storefront/scripts/eval 0
34+
magerun2 config:store:set system/default/csp/mode/storefront/report_only 0
35+
36+
bin/magento config:set general/region/display_all 0
37+
bin/magento config:set hyva_themes_checkout/general/checkout default
38+
39+
bin/magento hyva:config:generate
40+
41+
npm --prefix vendor/hyva-themes/magento2-default-theme-csp/web/tailwind/ ci
42+
npm --prefix vendor/hyva-themes/magento2-default-theme-csp/web/tailwind/ run build
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
$config = require('app/etc/config.php');
4+
$merge = require('merge-config.php.stub');
5+
6+
$merged = $config + $merge;
7+
8+
file_put_contents('app/etc/config.php', '<?php return ' . var_export($merged, true) . ';');
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
<?php
2+
return [
3+
'modules' => [],
4+
'scopes' => [
5+
'websites' => [
6+
'admin' => [
7+
'website_id' => '0',
8+
'code' => 'admin',
9+
'name' => 'Admin',
10+
'sort_order' => '0',
11+
'default_group_id' => '0',
12+
'is_default' => '0',
13+
],
14+
'base' => [
15+
'website_id' => '1',
16+
'code' => 'base',
17+
'name' => 'Main Website',
18+
'sort_order' => '0',
19+
'default_group_id' => '1',
20+
'is_default' => '1',
21+
],
22+
],
23+
'groups' => [
24+
0 => [
25+
'group_id' => '0',
26+
'website_id' => '0',
27+
'name' => 'Default',
28+
'root_category_id' => '0',
29+
'default_store_id' => '0',
30+
'code' => 'default',
31+
],
32+
1 => [
33+
'group_id' => '1',
34+
'website_id' => '1',
35+
'name' => 'Main Website Store',
36+
'root_category_id' => '2',
37+
'default_store_id' => '1',
38+
'code' => 'main_website_store',
39+
],
40+
],
41+
'stores' => [
42+
'admin' => [
43+
'store_id' => '0',
44+
'code' => 'admin',
45+
'website_id' => '0',
46+
'group_id' => '0',
47+
'name' => 'Admin',
48+
'sort_order' => '0',
49+
'is_active' => '1',
50+
],
51+
'hyva_default' => [
52+
'store_id' => '1',
53+
'code' => 'hyva_default',
54+
'website_id' => '1',
55+
'group_id' => '1',
56+
'name' => 'Default Store View',
57+
'sort_order' => '0',
58+
'is_active' => '1',
59+
],
60+
'onepage' => [
61+
'store_id' => '2',
62+
'code' => 'onepage',
63+
'website_id' => '1',
64+
'group_id' => '1',
65+
'name' => 'Onepage Store View',
66+
'sort_order' => '0',
67+
'is_active' => '1',
68+
],
69+
],
70+
],
71+
'themes' => [
72+
'frontend/Magento/blank' => [
73+
'parent_id' => null,
74+
'theme_path' => 'Magento/blank',
75+
'theme_title' => 'Magento Blank',
76+
'is_featured' => '0',
77+
'area' => 'frontend',
78+
'type' => '0',
79+
'code' => 'Magento/blank'
80+
],
81+
'adminhtml/Magento/backend' => [
82+
'parent_id' => null,
83+
'theme_path' => 'Magento/backend',
84+
'theme_title' => 'Magento 2 backend',
85+
'is_featured' => '0',
86+
'area' => 'adminhtml',
87+
'type' => '0',
88+
'code' => 'Magento/backend'
89+
],
90+
'frontend/Magento/luma' => [
91+
'parent_id' => 'Magento/blank',
92+
'theme_path' => 'Magento/luma',
93+
'theme_title' => 'Magento Luma',
94+
'is_featured' => '0',
95+
'area' => 'frontend',
96+
'type' => '0',
97+
'code' => 'Magento/luma'
98+
],
99+
'frontend/Hyva/default' => [
100+
'parent_id' => null,
101+
'theme_path' => 'Hyva/default',
102+
'theme_title' => 'Hyvä Default',
103+
'is_featured' => '0',
104+
'area' => 'frontend',
105+
'type' => '0',
106+
'code' => 'Hyva/default'
107+
],
108+
'frontend/Hyva/default-csp' => [
109+
'parent_id' => null,
110+
'theme_path' => 'Hyva/default-csp',
111+
'theme_title' => 'Hyvä Default CSP',
112+
'is_featured' => '0',
113+
'area' => 'frontend',
114+
'type' => '0',
115+
'code' => 'Hyva/default-csp'
116+
]
117+
],
118+
'system' => [
119+
'default' => [
120+
'general' => [
121+
'country' => [
122+
'default' => 'NL',
123+
],
124+
],
125+
'carriers' => [
126+
'freeshipping' => [
127+
'active' => 1,
128+
],
129+
],
130+
'design' => [
131+
'theme' => [
132+
'theme_id' => 'frontend/Hyva/default-csp',
133+
],
134+
],
135+
'web' => [
136+
'url' => [
137+
'use_store' => '1',
138+
],
139+
],
140+
],
141+
'stores' => [
142+
'default' => [
143+
'design' => [
144+
'theme' => [
145+
'theme_id' => 'frontend/Hyva/default-csp',
146+
],
147+
],
148+
],
149+
'onepage' => [
150+
'hyva_themes_checkout' => [
151+
'general' => [
152+
'checkout' => 'onepage',
153+
],
154+
],
155+
],
156+
],
157+
],
158+
];

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
playwright-report/
2+
test-results/
3+
node_modules/
4+
package-lock.json

0 commit comments

Comments
 (0)