Skip to content

Commit

Permalink
ref #88027 Update Git Action tests (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
uryvskiy-dima authored Sep 25, 2023
1 parent c531f9b commit 31aafde
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 79 deletions.
14 changes: 3 additions & 11 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ 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 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 +17,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
22 changes: 10 additions & 12 deletions .github/workflows/presta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,19 @@ jobs:
- php-version: '7.1'
branch: '1.7.7.0'
composerv1: 1
phpunit-version: 'phpunit:6.4.3'
- php-version: '7.2'
branch: '1.7.7.0'
composerv1: 1
phpunit-version: 'phpunit:6.4.3'
- php-version: '7.1'
branch: '1.7.7.8'
composerv1: 1
phpunit-version: 'phpunit:6.4.3'
- php-version: '7.2'
branch: '1.7.7.8'
- php-version: '7.3'
branch: '1.7.7.0'
composerv1: 1
- php-version: '7.1'
branch: '1.7.8.10'
coverage: 1
phpunit-version: 'phpunit:6.4.3'

- php-version: '7.2'
branch: '1.7.8.10'
- php-version: '7.3'
branch: '1.7.8.10'
services:
mysql:
image: mysql:5.7
Expand All @@ -47,7 +45,7 @@ jobs:
with:
php-version: ${{ matrix.php-version }}
coverage: xdebug
tools: composer:v2, ${{ matrix.phpunit-version }}
tools: composer:v2, phpunit:6.4.3
extensions: gd, mbstring, zip, mcrypt, pdo_mysql, dom
- name: Start mysql service
run: sudo /etc/init.d/mysql start
Expand All @@ -60,7 +58,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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v3.6.1
* Добавлены тесты для новых версий PrestaShop

## v3.6.0
* Добавлена поддержка PrestaShop 1.7.8.10

Expand Down
68 changes: 20 additions & 48 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,74 +14,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 +63,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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.6.0
3.6.1
9 changes: 3 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
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: 1 addition & 1 deletion retailcrm/retailcrm.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

class RetailCRM extends Module
{
const VERSION = '3.6.0';
const VERSION = '3.6.1';

const API_URL = 'RETAILCRM_ADDRESS';
const API_KEY = 'RETAILCRM_API_TOKEN';
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 31aafde

Please sign in to comment.