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
0 commit comments