Skip to content

Commit

Permalink
Update Git Action tests
Browse files Browse the repository at this point in the history
  • Loading branch information
uryvskiy-dima committed Sep 24, 2023
1 parent c531f9b commit 9af0849
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 70 deletions.
16 changes: 3 additions & 13 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
FROM php:7.2-fpm

RUN apt-get update

RUN apt-get install -y zlib1g-dev libpq-dev git libicu-dev libxml2-dev libpng-dev libjpeg-dev libmcrypt-dev libxslt-dev libfreetype6-dev unzip\
RUN apt-get update && apt-get install -y zlib1g-dev libpq-dev git libicu-dev libxml2-dev libpng-dev libjpeg-dev libmcrypt-dev libxslt-dev libfreetype6-dev unzip nano\
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl \
&& docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
&& docker-php-ext-install mysqli pdo pdo_mysql \
&& docker-php-ext-install zip \
&& docker-php-ext-install xml \
Expand All @@ -18,14 +15,7 @@ RUN apt-get install -y zlib1g-dev libpq-dev git libicu-dev libxml2-dev libpng-de
&& pecl install mcrypt-1.0.1 \
&& docker-php-ext-enable mcrypt

RUN apt-get install -y wget

RUN wget -O /usr/bin/phpunit https://phar.phpunit.de/phpunit-6.phar && chmod +x /usr/bin/phpunit
RUN curl --insecure https://getcomposer.org/composer.phar -o /usr/bin/composer && chmod +x /usr/bin/composer

# Set timezone
RUN rm /etc/localtime
RUN ln -s /usr/share/zoneinfo/Europe/Moscow /etc/localtime
RUN "date"
RUN curl -sSL https://phar.phpunit.de/phpunit-6.phar -o /usr/bin/phpunit && chmod +x /usr/bin/phpunit \
&& curl -sSL https://getcomposer.org/composer.phar -o /usr/bin/composer && chmod +x /usr/bin/composer

WORKDIR /code
18 changes: 17 additions & 1 deletion .github/workflows/presta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ jobs:
- php-version: '7.2'
branch: '1.7.7.0'
composerv1: 1
- php-version: '7.3'
branch: '1.7.7.0'
composerv1: 1
phpunit-version: 'phpunit:6.4.3'
- php-version: '7.4'
branch: '1.7.7.0'
composerv1: 1
phpunit-version: 'phpunit:6.4.3'
- php-version: '7.1'
branch: '1.7.7.8'
Expand All @@ -31,6 +38,15 @@ jobs:
composerv1: 1
coverage: 1
phpunit-version: 'phpunit:6.4.3'
- php-version: '7.3'
branch: '1.7.7.8'
composerv1: 1
phpunit-version: 'phpunit:6.4.3'
- php-version: '7.4'
branch: '1.7.7.8'
composerv1: 1
coverage: 1
phpunit-version: 'phpunit:6.4.3'

services:
mysql:
Expand Down Expand Up @@ -60,7 +76,7 @@ jobs:
BRANCH: ${{ matrix.branch }}
COMPOSERV1: ${{ matrix.composerv1 }}
MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }}
run: make before_script
run: make install_prestashop
- name: Run tests
env:
BRANCH: ${{ matrix.branch }}
Expand Down
70 changes: 22 additions & 48 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
include .env

ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
PRESTASHOP_DIR=$(ROOT_DIR)/../PrestaShop
FILE = $(ROOT_DIR)/VERSION
Expand All @@ -14,74 +16,46 @@ delete_archive:
rm -f $(ARCHIVE_NAME)
rm -f /tmp/retailcrm.zip

composer: clone_prestashop clone_composer fix-version-lang-bugs
ifeq ($(COMPOSERV1),1)
cd $(PRESTASHOP_DIR) && php composer.phar install --prefer-dist --no-interaction --no-progress
else
cd $(PRESTASHOP_DIR)/tests && composer install
endif

clone_prestashop:
cd $(ROOT_DIR)/../ && git clone https://github.com/PrestaShop/PrestaShop
cd $(PRESTASHOP_DIR) && git checkout $(BRANCH)

clone_composer:
# Required for versions 1.7.7.x - 1.7.8.x
# Only this command work in Makefile for replace $sfContainer->get('translator')
# sed -i 's/$$sfContainer->get('"'"'translator'"'"')/Context::getContext()->getTranslator()/g' classes/Language.php
fix_lang_bugs:
cd $(PRESTASHOP_DIR) && sed -i \
-e "s/throw new Exception/#throw new Exception/g" \
-e "s/SymfonyContainer::getInstance()->get('translator')/Context::getContext()->getTranslator()/g" \
-e 's/$$sfContainer->get('"'"'translator'"'"')/Context::getContext()->getTranslator()/g' \
src/PrestaShopBundle/Install/DatabaseDump.php classes/lang/DataLang.php classes/Language.php

install_composer:
# Required for versions 1.7.7.x
ifeq ($(COMPOSERV1),1)
cd $(PRESTASHOP_DIR) \
&& php -r "copy('https://getcomposer.org/download/1.10.17/composer.phar', 'composer.phar');"
composer self-update --1
endif
cd $(PRESTASHOP_DIR) && composer install

before_script: composer
ifneq ("$(wildcard $(PRESTASHOP_DIR)/travis-scripts/install-prestashop)","")
ifeq ($(COMPOSERV1),1)
cd $(PRESTASHOP_DIR) \
&& sed -i 's/mysql -u root/mysql -u root --port $(MYSQL_PORT)/g' travis-scripts/install-prestashop \
&& sed -i 's/--db_server=127.0.0.1 --db_name=prestashop/--db_server=127.0.0.1:$(MYSQL_PORT) --db_name=prestashop --db_user=root/g' travis-scripts/install-prestashop \
&& bash travis-scripts/install-prestashop
else
cd $(PRESTASHOP_DIR) \
&& sed -i 's/mysql -u root/mysql -u root -proot --port $(MYSQL_PORT)/g' travis-scripts/install-prestashop.sh \
&& sed -i 's/--db_server=127.0.0.1 --db_name=prestashop/--db_server=127.0.0.1:$(MYSQL_PORT) --db_name=prestashop --db_user=root/g' travis-scripts/install-prestashop.sh \
&& bash travis-scripts/install-prestashop.sh
endif
else
rm -rf var/cache/*
echo "* Installing PrestaShop, this may take a while ...";

install_prestashop: clone_prestashop fix_lang_bugs install_composer
ifeq ($(LOCAL_TEST),1)
cd $(PRESTASHOP_DIR) && php install-dev/index_cli.php --db_server=db --db_user=root --db_create=1
else
mkdir coverage
cd $(PRESTASHOP_DIR) && php install-dev/index_cli.php --db_server=127.0.0.1:$(MYSQL_PORT) --db_user=root --db_create=1
mkdir coverage
endif
endif

# Required for versions 1.7.7.x
fix-version-lang-bugs:
ifeq ($(COMPOSERV1),1)
cd $(PRESTASHOP_DIR) \
&& sed -i 's/throw new Exception/#throw new Exception/g' src/PrestaShopBundle/Install/DatabaseDump.php
endif

cd $(PRESTASHOP_DIR) \
&& sed -i "s/SymfonyContainer::getInstance()->get('translator')/\\\\Context::getContext()->getTranslator()/g" classes/lang/DataLang.php
cat $(PRESTASHOP_DIR)/classes/lang/DataLang.php | grep -A 3 -B 3 'this->translator = '

cd $(PRESTASHOP_DIR) \
&& sed -i "s/SymfonyContainer::getInstance()->get('translator')/\\\\Context::getContext()->getTranslator()/g" classes/Language.php
cat $(PRESTASHOP_DIR)/classes/Language.php | grep -A 3 -B 3 'translator = '

lint:
php-cs-fixer fix --config=$(ROOT_DIR)/.php-cs-fixer.php -v

lint-docker:
docker run --rm -it -w=/app -v ${PWD}:/app oskarstark/php-cs-fixer-ga:latest --config=.php-cs-fixer.php -v

# todo moveto version
test:
cd $(PRESTASHOP_DIR) && composer run-script create-test-db --timeout=0

ifeq ($(COMPOSERV1),1)
cd $(PRESTASHOP_DIR) && php composer.phar run-script create-test-db --timeout=0
cd $(PRESTASHOP_DIR) && php vendor/bin/phpunit -c $(ROOT_DIR)/phpunit.xml.dist
phpunit -c $(ROOT_DIR)/phpunit.xml.dist
else
phpunit -c phpunit.xml.dist
endif
Expand All @@ -91,5 +65,5 @@ coverage:

run_local_tests:
docker-compose up -d --build
docker exec app_test make before_script test
docker exec app_prestashop_test make install_prestashop test
docker-compose down
11 changes: 3 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
version: '3'
services:
app:
container_name: app_test
container_name: app_prestashop_test
build:
context: ./.docker
volumes:
- ./:/code
env_file:
- ./.env
environment:
- BRANCH=${BRANCH}
links:
- db
depends_on:
- db
db:
container_name: mysql_prestashop_test
image: mysql:5.7
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
ports:
- "3306:3306"
- '3306:3306'
3 changes: 3 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
<exclude>tests/helpers</exclude>
</testsuite>
</testsuites>
<php>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled"/>
</php>
<filter>
<whitelist>
<directory suffix=".php">retailcrm</directory>
Expand Down
2 changes: 2 additions & 0 deletions tests/lib/RetailcrmHistoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,8 @@ public function testPaymentStatusUpdate()
RetailcrmHistory::$api = $this->apiMock;

RetailcrmHistory::ordersHistory();

$this->assertTrue(true);
}

public function testOrderAddressUpdate()
Expand Down

0 comments on commit 9af0849

Please sign in to comment.