Skip to content

Commit

Permalink
Simplify docker-compose usage and workflows (#2534)
Browse files Browse the repository at this point in the history
* Remove redundant docker-compose file and remove unused make commands

* Temporarily disable E2E

* Update docker-composer.yml path

* Update docker-composer.yml variables

* Update docker-composer.yml variables

* Enable E2E tests again

* Define network backend

* Update Playwright version

* Remove redundant compose file usage

* Change file permission
  • Loading branch information
candemiralp authored Mar 7, 2024
1 parent 1e55f33 commit 4d1c879
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 168 deletions.
4 changes: 2 additions & 2 deletions .github/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ RUN a2enmod ssl
RUN a2ensite default-ssl.conf #can be removed if not needed
WORKDIR /var/www/html
COPY config/php.ini /usr/local/etc/php/
COPY config/install_magento.sh /tmp/install_magento.sh
COPY scripts/install_magento.sh /tmp/install_magento.sh

RUN if [ -x "$(command -v apache2-foreground)" ]; then a2enmod rewrite; fi

Expand All @@ -55,4 +55,4 @@ ADD "https://github.com/magento/magento2-sample-data/archive/refs/tags/${MAGENTO

RUN chmod +x /tmp/install_magento.sh

CMD ["bash", "/tmp/install_magento.sh"]
CMD ["bash", "/tmp/install_magento.sh"]
43 changes: 1 addition & 42 deletions .github/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,30 +71,15 @@ plugin: install configure flush
fs:
find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
chmod 777 -R var
chown -R www-data:www-data .
chmod u+x bin/magento
echo "memory_limit = -1" > /usr/local/etc/php/conf.d/memory.ini

# Deploy sample data
sampledata:
composer config http-basic.repo.magento.com "${MAGENTO_USERNAME}" "${MAGENTO_PASSWORD}"
composer config repositories.magento composer https://repo.magento.com/
bin/magento sampledata:deploy
bin/magento setup:upgrade

# Production mode
production:
bin/magento deploy:mode:set production

# JavaScript bundling
bundlejs:
bin/magento config:set dev/js/enable_js_bundling 1
bin/magento config:set dev/js/minify_files 1
bin/magento config:set dev/static/sign 1
bin/magento config:set dev/js/merge_files 0
bin/magento setup:static-content:deploy
bin/magento cache:clean config

MAGENTO_ROOT=/var/www/html
GRAPHQL_XML=${MAGENTO_ROOT}/dev/tests/api-functional/phpunit_graphql.xml.dist
GRAPHQL_PHP=/data/extensions/workdir/Test/phpunit_graphql.php
Expand All @@ -112,16 +97,6 @@ restapi:
--configuration ${MAGENTO_ROOT}/dev/tests/api-functional/phpunit_rest.xml.dist \
${MAGENTO_ROOT}/vendor/adyen/module-payment/Test/api-functional/Webapi

# Destroy services
clean:
docker-compose -f workflows/templates/docker-compose.yml down --volumes --rmi local
docker-compose -f docker-compose.yml -f docker-compose.mftf.yml down --volumes --rmi local

# Docker image build
image:
docker-compose -f workflows/templates/docker-compose.yml -f docker-compose.e2e.yml build
docker-compose -f docker-compose.yml -f docker-compose.mftf.yml build

# Setup environment to run functional tests (https://devdocs.magento.com/mftf/docs/getting-started.html)
setup-mftf:
bin/magento config:set currency/options/allow USD,EUR
Expand Down Expand Up @@ -154,19 +129,3 @@ setup-mftf:
# Magento Functional Testing Framework
mftf:
vendor/bin/mftf run:group --remove -- AdyenMagentoSuite || vendor/bin/mftf run:failed

# Simulate a full CI build
ci:
docker-compose -f workflows/templates/docker-compose.yml run --rm web make magento
docker-compose -f workflows/templates/docker-compose.yml up -d web

docker exec magento2-container make fs
docker exec magento2-container make sys-check
docker exec -u www-data magento2-container make plugin
docker exec magento2-container /etc/init.d/cron stop
docker exec -u www-data magento2-container make unit
docker exec magento2-container make graphql
docker exec -u www-data magento2-container make production
docker exec magento2-container make fs

docker-compose -f workflows/templates/docker-compose.yml run --rm playwright /e2e.sh
9 changes: 5 additions & 4 deletions .github/docker-compose.e2e.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '3'
services:
playwright:
image: mcr.microsoft.com/playwright:v1.41.2-focal
image: mcr.microsoft.com/playwright:focal
shm_size: 1gb
ipc: host
cap_add:
Expand All @@ -22,7 +22,8 @@ services:
- GOOGLE_PASSWORD
- WEBHOOK_USERNAME
- WEBHOOK_PASSWORD

volumes:
- ../../scripts/e2e.sh:/e2e.sh
- ../../../test-report:/tmp/test-report
- ./scripts/e2e.sh:/e2e.sh
- ../test-report:/tmp/test-report
networks:
backend:
39 changes: 24 additions & 15 deletions .github/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,40 @@ services:
- PHP_VERSION=${PHP_VERSION}
- MAGENTO_VERSION=${MAGENTO_VERSION}
container_name: magento2-container
extra_hosts:
- "magento2.test.com:127.0.0.1"
networks:
backend:
aliases:
- magento2.test.com
environment:
- DB_SERVER=mariadb
- ELASTICSEARCH_SERVER=elasticsearch
- MAGENTO_HOST=magento2.test.com
- VIRTUAL_HOST=magento2.test.com
- ADMIN_URLEXT=admin
- DONATION_ACCOUNT
- ADMIN_USERNAME
- ADMIN_PASSWORD
- ADYEN_MERCHANT
- ADYEN_API_KEY
- ADYEN_CLIENT_KEY
- PHP_VERSION
- MAGENTO_VERSION
- WEBHOOK_USERNAME
- WEBHOOK_PASSWORD
DB_SERVER: mariadb
ELASTICSEARCH_SERVER: elasticsearch
MAGENTO_HOST: magento2.test.com
VIRTUAL_HOST: magento2.test.com
COMPOSER_MEMORY_LIMIT: -1
DEPLOY_SAMPLEDATA: 1
DONATION_ACCOUNT:
ADMIN_USERNAME:
ADMIN_PASSWORD:
ADYEN_MERCHANT:
ADYEN_API_KEY:
ADYEN_CLIENT_KEY:
PHP_VERSION:
MAGENTO_VERSION:
WEBHOOK_PASSWORD:
WEBHOOK_USERNAME:
depends_on:
- db
- elastic
volumes:
- ../:/data/extensions/workdir
- ./Makefile:/var/www/html/Makefile
- composer:/usr/local/bin
- magento:/var/www/html
- ../app-logs:/var/www/html/var/log
networks:
backend:
volumes:
magento:
composer:
File renamed without changes.
13 changes: 10 additions & 3 deletions .github/workflows/e2e-test-dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ jobs:
- uses: actions/checkout@v3

- name: Install Magento
run: docker-compose -f .github/workflows/templates/docker-compose.yml run --rm web make magento
run: docker-compose -f .github/docker-compose.yml run --rm web make magento

- name: Start web server in background
run: docker-compose -f .github/workflows/templates/docker-compose.yml up -d web
run: docker-compose -f .github/docker-compose.yml up -d web
env:
DONATION_ACCOUNT: ${{secrets.DONATION_ACCOUNT}}
ADYEN_MERCHANT: ${{secrets.ADYEN_MERCHANT}}
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
run: docker exec magento2-container make fs

- name: Run E2E tests
run: docker-compose -f .github/workflows/templates/docker-compose.yml run --rm playwright /e2e.sh ${{inputs.testGroup}}
run: docker-compose -f .github/docker-compose.e2e.yml run --rm playwright /e2e.sh ${{inputs.testGroup}}
env:
INTEGRATION_TESTS_BRANCH: ${{inputs.testBranch}}
MAGENTO_ADMIN_USERNAME: ${{secrets.MAGENTO_ADMIN_USERNAME}}
Expand All @@ -116,3 +116,10 @@ jobs:
with:
name: html-report
path: test-report

- name: Archive application logs
if: always()
uses: actions/upload-artifact@v3
with:
name: app-logs
path: app-logs
6 changes: 3 additions & 3 deletions .github/workflows/e2e-test-express-checkout.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
- uses: actions/checkout@v3

- name: Install Magento
run: docker-compose -f .github/workflows/templates/docker-compose.yml run --rm web make magento
run: docker-compose -f .github/docker-compose.yml run --rm web make magento

- name: Start web server in background
run: docker-compose -f .github/workflows/templates/docker-compose.yml up -d web
run: docker-compose -f .github/docker-compose.yml up -d web
env:
DONATION_ACCOUNT: ${{secrets.DONATION_ACCOUNT}}
ADYEN_MERCHANT: ${{secrets.ADYEN_MERCHANT}}
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
run: docker exec magento2-container make fs

- name: Run E2E tests
run: docker-compose -f .github/workflows/templates/docker-compose.yml run --rm playwright /e2e.sh express-checkout
run: docker-compose -f .github/docker-compose.e2e.yml run --rm playwright /e2e.sh express-checkout
env:
INTEGRATION_TESTS_BRANCH: develop
MAGENTO_ADMIN_USERNAME: ${{secrets.MAGENTO_ADMIN_USERNAME}}
Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
- uses: actions/checkout@v3

- name: Install Magento
run: docker-compose -f .github/workflows/templates/docker-compose.yml run --rm web make magento
run: docker-compose -f .github/docker-compose.yml run --rm web make magento

- name: Start web server in background
run: docker-compose -f .github/workflows/templates/docker-compose.yml up -d web
run: docker-compose -f .github/docker-compose.yml up -d web
env:
DONATION_ACCOUNT: ${{secrets.DONATION_ACCOUNT}}
ADYEN_MERCHANT: ${{secrets.ADYEN_MERCHANT}}
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
run: docker exec magento2-container make fs

- name: Run E2E tests
run: docker-compose -f .github/workflows/templates/docker-compose.yml run --rm playwright /e2e.sh standard
run: docker-compose -f .github/docker-compose.e2e.yml run --rm playwright /e2e.sh standard
env:
INTEGRATION_TESTS_BRANCH: develop
MAGENTO_ADMIN_USERNAME: ${{secrets.MAGENTO_ADMIN_USERNAME}}
Expand All @@ -92,3 +92,10 @@ jobs:
with:
name: html-report
path: test-report

- name: Archive application logs
if: always()
uses: actions/upload-artifact@v3
with:
name: app-logs
path: app-logs
4 changes: 2 additions & 2 deletions .github/workflows/graphql-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
- uses: actions/checkout@v3

- name: Install Magento
run: docker-compose -f .github/workflows/templates/docker-compose.yml run --rm web make magento
run: docker-compose -f .github/docker-compose.yml run --rm web make magento

- name: Start web server in background
run: docker-compose -f .github/workflows/templates/docker-compose.yml up -d web
run: docker-compose -f .github/docker-compose.yml up -d web
env:
DONATION_ACCOUNT: ${{secrets.DONATION_ACCOUNT}}
ADYEN_MERCHANT: ${{secrets.ADYEN_MERCHANT}}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/restapi-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
- uses: actions/checkout@v3

- name: Install Magento
run: docker-compose -f .github/workflows/templates/docker-compose.yml run --rm web make magento
run: docker-compose -f .github/docker-compose.yml run --rm web make magento

- name: Start web server in background
run: docker-compose -f .github/workflows/templates/docker-compose.yml up -d web
run: docker-compose -f .github/docker-compose.yml up -d web
env:
DONATION_ACCOUNT: ${{secrets.DONATION_ACCOUNT}}
ADYEN_MERCHANT: ${{secrets.ADYEN_MERCHANT}}
Expand Down
92 changes: 0 additions & 92 deletions .github/workflows/templates/docker-compose.yml

This file was deleted.

0 comments on commit 4d1c879

Please sign in to comment.