diff --git a/.github/workflows/magento.yml b/.github/workflows/magento.yml new file mode 100644 index 0000000..53ed5dc --- /dev/null +++ b/.github/workflows/magento.yml @@ -0,0 +1,234 @@ +# This is a basic workflow to help you get started with Actions + +name: magento + +on: + push: + branches: + - '**' + tags-ignore: + - '*.*' + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + include: + - php-version: '7.0' + branch: '2.0.2' + coverage: 1 + - php-version: '7.0' + branch: '2.0.4' + - php-version: '7.0' + branch: '2.0.5' + - php-version: '7.0' + branch: '2.0.6' + - php-version: '7.0' + branch: '2.0.7' + - php-version: '7.0' + branch: '2.0.8' + - php-version: '7.0' + branch: '2.0.9' + - php-version: '7.0' + branch: '2.0.10' + - php-version: '7.0' + branch: '2.0.11' + - php-version: '7.0' + branch: '2.0.12' + - php-version: '7.0' + branch: '2.0.13' + - php-version: '7.0' + branch: '2.0.14' + - php-version: '7.0' + branch: '2.0.15' + - php-version: '7.0' + branch: '2.0.16' + - php-version: '7.0' + branch: '2.0.17' + - php-version: '7.0' + branch: '2.0.18' + + - php-version: '7.0' + branch: '2.1.0' + - php-version: '7.0' + branch: '2.1.1' + - php-version: '7.0' + branch: '2.1.2' + - php-version: '7.0' + branch: '2.1.3' + - php-version: '7.0' + branch: '2.1.4' + - php-version: '7.0' + branch: '2.1.5' + - php-version: '7.0' + branch: '2.1.6' + - php-version: '7.0' + branch: '2.1.7' + - php-version: '7.0' + branch: '2.1.8' + - php-version: '7.0' + branch: '2.1.9' + - php-version: '7.0' + branch: '2.1.10' + - php-version: '7.0' + branch: '2.1.11' + - php-version: '7.0' + branch: '2.1.12' + - php-version: '7.0' + branch: '2.1.13' + - php-version: '7.0' + branch: '2.1.14' + - php-version: '7.0' + branch: '2.1.15' + + - php-version: '7.0' + branch: '2.1.16' + - php-version: '7.1' + branch: '2.1.16' + + - php-version: '7.0' + branch: '2.1.17' + - php-version: '7.1' + branch: '2.1.17' + + - php-version: '7.0' + branch: '2.1.18' + - php-version: '7.1' + branch: '2.1.18' + + - php-version: '7.0' + branch: '2.2.0' + - php-version: '7.1' + branch: '2.2.0' + + - php-version: '7.0' + branch: '2.2.1' + - php-version: '7.1' + branch: '2.2.1' + + - php-version: '7.0' + branch: '2.2.2' + - php-version: '7.1' + branch: '2.2.2' + + - php-version: '7.0' + branch: '2.2.3' + - php-version: '7.1' + branch: '2.2.3' + + - php-version: '7.0' + branch: '2.2.4' + - php-version: '7.1' + branch: '2.2.4' + + - php-version: '7.0' + branch: '2.2.5' + - php-version: '7.1' + branch: '2.2.5' + + - php-version: '7.0' + branch: '2.2.6' + - php-version: '7.1' + branch: '2.2.6' + + - php-version: '7.0' + branch: '2.2.7' + - php-version: '7.1' + branch: '2.2.7' + + - php-version: '7.0' + branch: '2.2.8' + - php-version: '7.1' + branch: '2.2.8' + + - php-version: '7.0' + branch: '2.2.9' + - php-version: '7.1' + branch: '2.2.9' + + - php-version: '7.0' + branch: '2.2.10' + - php-version: '7.1' + branch: '2.2.10' + + services: + mysql: + image: mysql:5.7 + env: + MYSQL_ROOT_PASSWORD: root + ports: + - 3306/tcp + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5 + steps: + - uses: actions/checkout@v2 + - name: Setup PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + coverage: xdebug + tools: composer:v1, phpunit:6.4.3 + extensions: gd, mbstring, zip, mcrypt, pdo_mysql, dom, soap, bcmath + - name: Start mysql service + run: sudo /etc/init.d/mysql start + - name: Status mysql service + run: sudo systemctl status mysql + - name: Install Magento + env: + BRANCH: ${{ matrix.branch }} + PUBLIC_KEY: ${{ secrets.PUBLIC_KEY}} + PRIVATE_KEY: ${{ secrets.PRIVATE_KEY}} + run: make before_script + - name: Run tests + run: make test + - name: Coverage + env: + COVERAGE: ${{ matrix.coverage }} + if: env.COVERAGE == 1 + run: | + make coverage + bash <(curl -s https://codecov.io/bash) + + deploy: + needs: ['test'] + if: success() && github.event_name == 'push' && github.repository_owner == 'retailcrm' && github.ref == 'refs/heads/master' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup PHP 7.2 + uses: shivammathur/setup-php@v2 + with: + php-version: '7.2' + tools: composer:v1 + - name: Build release + run: | + git fetch origin --unshallow --tags + export LAST_TAG=`git describe --abbrev=0 --tags` + export VERSION=`cat VERSION` + export ARCHIVE_NAME=retailcrm-$VERSION.ocmod.zip + export ARCHIVE_PATH="/tmp/$ARCHIVE_NAME" + export RELEASE_TAG=v$VERSION + export LAST_COMMIT=`git log --oneline --format=%B -n 1 HEAD | head -n 1` + echo RELEASE_TAG=$RELEASE_TAG >> $GITHUB_ENV + echo LAST_TAG=$LAST_TAG >> $GITHUB_ENV + echo LAST_COMMIT=$LAST_COMMIT >> $GITHUB_ENV + echo ARCHIVE_PATH=$ARCHIVE_PATH >> $GITHUB_ENV + echo ARCHIVE_NAME=$ARCHIVE_NAME >> $GITHUB_ENV + make build_archive + - name: Create Release + id: create_release + uses: actions/create-release@v1 + if: env.LAST_TAG != env.RELEASE_TAG + env: + GITHUB_TOKEN: ${{ secrets.TOKEN }} + with: + tag_name: ${{ env.RELEASE_TAG }} + release_name: ${{ env.RELEASE_TAG }} + body: ${{ env.LAST_COMMIT }} + draft: false + prerelease: false + - name: Cleanup + if: env.LAST_TAG != env.RELEASE_TAG + run: make delete_archive + diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5443c3f..0000000 --- a/.travis.yml +++ /dev/null @@ -1,262 +0,0 @@ -os: linux -dist: trusty -language: php - -if: tag IS blank - -env: - global: - - DB_USER=root - - DB_HOST=localhost - - DB_NAME=magento2_test - - ADMIN_FIRSTNAME=admin_firstname - - ADMIN_LASTNAME=admin_lastname - - ADMIN_EMAIL=example@email.com - - ADMIN_USER=admin - - ADMIN_PASS=admin123 - -stages: - - test - - deploy - -before_install: - - export LAST_TAG=`git describe --abbrev=0 --tags` - - export CURRENT_VERSION=v`cat VERSION` - -before_script: - - bash bin/install.sh - -script: make ci - -jobs: - allow_failures: - - if: fork = true - env: BRANCH=2.0.2 - - if: fork = true - env: BRANCH=2.0.4 - - if: fork = true - env: BRANCH=2.0.5 - - if: fork = true - env: BRANCH=2.0.6 - - if: fork = true - env: BRANCH=2.0.7 - - if: fork = true - env: BRANCH=2.0.8 - - if: fork = true - env: BRANCH=2.0.9 - - if: fork = true - env: BRANCH=2.0.10 - - if: fork = true - env: BRANCH=2.0.11 - - include: - - php: 7.0 - env: BRANCH=2.0.2 - - - php: 7.0 - env: BRANCH=2.0.4 - - - php: 7.0 - env: BRANCH=2.0.5 - - - php: 7.0 - env: BRANCH=2.0.6 - - - php: 7.0 - env: BRANCH=2.0.7 - - - php: 7.0 - env: BRANCH=2.0.8 - - - php: 7.0 - env: BRANCH=2.0.9 - - - php: 7.0 - env: BRANCH=2.0.10 - - - php: 7.0 - env: BRANCH=2.0.11 - - - php: 7.0 - env: BRANCH=2.0.12 - - - php: 7.0 - env: BRANCH=2.0.13 - - - php: 7.0 - env: BRANCH=2.0.14 - - - php: 7.0 - env: BRANCH=2.0.15 - - - php: 7.0 - env: BRANCH=2.0.16 - - - php: 7.0 - env: BRANCH=2.0.17 - - - php: 7.0 - env: BRANCH=2.0.18 - - - php: 7.0 - env: BRANCH=2.1.0 - - - php: 7.0 - env: BRANCH=2.1.1 - - - php: 7.0 - env: BRANCH=2.1.2 - - - php: 7.0 - env: BRANCH=2.1.3 - - - php: 7.0 - env: BRANCH=2.1.4 - - - php: 7.0 - env: BRANCH=2.1.5 - - - php: 7.0 - env: BRANCH=2.1.6 - - - php: 7.0 - env: BRANCH=2.1.7 - - - php: 7.0 - env: BRANCH=2.1.8 - - - php: 7.0 - env: BRANCH=2.1.9 - - - php: 7.0 - env: BRANCH=2.1.10 - - - php: 7.0 - env: BRANCH=2.1.11 - - - php: 7.0 - env: BRANCH=2.1.12 - - - php: 7.0 - env: BRANCH=2.1.13 - - - php: 7.0 - env: BRANCH=2.1.14 - - - php: 7.0 - env: BRANCH=2.1.15 - - - php: 7.0 - env: BRANCH=2.1.16 - - php: 7.1 - env: BRANCH=2.1.16 - - - php: 7.0 - env: BRANCH=2.1.17 - - php: 7.1 - env: BRANCH=2.1.17 - - - php: 7.0 - env: BRANCH=2.1.18 - - php: 7.1 - env: BRANCH=2.1.18 - - - php: 7.0 - env: BRANCH=2.2.0 - - php: 7.1 - env: BRANCH=2.2.0 - - - php: 7.0 - env: BRANCH=2.2.1 - - php: 7.1 - env: BRANCH=2.2.1 - - - php: 7.0 - env: BRANCH=2.2.2 - - php: 7.1 - env: BRANCH=2.2.2 - - - php: 7.0 - env: BRANCH=2.2.3 - - php: 7.1 - env: BRANCH=2.2.3 - - - php: 7.0 - env: BRANCH=2.2.4 - - php: 7.1 - env: BRANCH=2.2.4 - - - php: 7.0 - env: BRANCH=2.2.5 - - php: 7.1 - env: BRANCH=2.2.5 - - - php: 7.0 - env: BRANCH=2.2.6 - - php: 7.1 - env: BRANCH=2.2.6 - - - php: 7.0 - env: BRANCH=2.2.7 - - php: 7.1 - env: BRANCH=2.2.7 - - - php: 7.0 - env: BRANCH=2.2.8 - - php: 7.1 - env: BRANCH=2.2.8 - - - php: 7.0 - env: BRANCH=2.2.9 - - php: 7.1 - env: BRANCH=2.2.9 - - - php: 7.0 - env: BRANCH=2.2.10 - - php: 7.1 - env: BRANCH=2.2.10 - - php: 7.2 - env: BRANCH=2.2.10 - - - php: 7.1 - env: BRANCH=2.3.0 - - php: 7.2 - env: BRANCH=2.3.0 - - - php: 7.1 - env: BRANCH=2.3.1 - - php: 7.2 - env: BRANCH=2.3.1 - - - php: 7.1 - env: BRANCH=2.3.2 - - php: 7.2 - env: BRANCH=2.3.2 - - - php: 7.1 - env: BRANCH=2.3.3 - - php: 7.2 - env: BRANCH=2.3.3 - - - php: 7.2 - env: BRANCH=2.3.4 - - - stage: deploy - before_script: skip - script: make build_archive - before_deploy: - - export VERSION=`cat VERSION` - - export ARCHIVE_NAME=/tmp/retailcrm-retailcrm-$VERSION.zip - - git config --local user.name "RetailCRM" - - git config --local user.email "support@retailcrm.ru" - - export TRAVIS_TAG=v$VERSION - - git tag $TRAVIS_TAG - deploy: - provider: releases - token: $GITHUB_OAUTH_TOKEN - cleanup: false - file: $ARCHIVE_NAME - on: - condition: "$LAST_TAG != $CURRENT_VERSION" - if: branch = master AND type = push AND fork = false - after_deploy: make delete_archive diff --git a/CHANGELOG.md b/CHANGELOG.md index 849a553..ca4c0c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2021-01-30 v.2.5.2 +* Переход на GitHub Actions + ## 2020-12-17 v.2.5.1 * Ребрендинг RetailCRM diff --git a/Makefile b/Makefile index f0507f4..dc41e66 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,8 @@ -FILE = $(TRAVIS_BUILD_DIR)/VERSION +export ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) + VERSION = `cat $(FILE)` ARCHIVE_NAME = '/tmp/retailcrm-retailcrm-'$(VERSION)'.zip' -MAGE_ROOT = $(TRAVIS_BUILD_DIR)/../magento2 +MAGE_ROOT=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))/../magento2 .PHONY: build_archive delete_archive @@ -11,5 +12,13 @@ build_archive: delete_archive: rm -f $(ARCHIVE_NAME) -ci: +test: + mkdir coverage + php $(MAGE_ROOT)/vendor/phpunit/phpunit/phpunit -c $(MAGE_ROOT)/dev/tests/unit/phpunit.xml.dist $(MAGE_ROOT)/app/code/Retailcrm/Retailcrm/Test/Unit + +before_script: + bash bin/install.sh + +coverage: + wget https://phar.phpunit.de/phpcov-2.0.2.phar && php phpcov-2.0.2.phar merge coverage/ --clover coverage.xml \ No newline at end of file diff --git a/README.md b/README.md index 1628399..a45d879 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ -[![Build Status](https://img.shields.io/travis/retailcrm/magento-module/master.svg?style=flat-square)](https://travis-ci.org/retailcrm/magento-module) -[![GitHub release](https://img.shields.io/github/release/retailcrm/magento-module.svg?style=flat-square)](https://github.com/retailcrm/magento-module/releases) +[![Build Status](https://github.com/retailcrm/magento-module/workflows/magento/badge.svg)](https://github.com/retailcrm/magento-module/actions) +[![Coverage](https://img.shields.io/codecov/c/gh/retailcrm/magento-module/master.svg?logo=github)](https://codecov.io/gh/retailcrm/magento-module) +[![GitHub release](https://img.shields.io/github/release/retailcrm/magento-module.svg?logo=codecov)](https://github.com/retailcrm/magento-module/) [![PHP version](https://img.shields.io/badge/PHP->=5.6-blue.svg?style=flat-square)](https://php.net/) Magento module diff --git a/VERSION b/VERSION index 73462a5..f225a78 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.5.1 +2.5.2 diff --git a/bin/install.sh b/bin/install.sh index 49c9c77..e6e9ac3 100644 --- a/bin/install.sh +++ b/bin/install.sh @@ -1,23 +1,23 @@ #!/usr/bin/env bash -if [ -z $TRAVIS_BUILD_DIR ]; then - exit 0; +if [ -z $ROOT_DIR ]; then + exit 0; fi -MAGE_ROOT=$TRAVIS_BUILD_DIR/../magento2 +MAGE_ROOT=$ROOT_DIR/../magento2 create_db() { - mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS" + mysqladmin create "magento2_test" --user="root" --password="root" } magento_clone() { - cd .. - git clone https://github.com/magento/magento2 - cd magento2 - git checkout $BRANCH + cd .. + git clone https://github.com/magento/magento2 + cd magento2 + git checkout $BRANCH - touch auth.json - echo ' + touch auth.json + echo ' { "http-basic": { "repo.magento.com": { @@ -26,42 +26,40 @@ magento_clone() { } } } - ' > auth.json + ' > auth.json - sudo sed -e "s??$PUBLIC_KEY?g" --in-place auth.json - sudo sed -e "s??$PRIVATE_KEY?g" --in-place auth.json + sudo sed -e "s??$PUBLIC_KEY?g" --in-place auth.json + sudo sed -e "s??$PRIVATE_KEY?g" --in-place auth.json - php -r "copy('https://getcomposer.org/download/1.10.17/composer.phar', 'composer.phar');" - - php composer.phar install --ignore-platform-reqs --no-interaction --prefer-dist - php composer.phar require retailcrm/api-client-php + composer install --no-interaction --prefer-dist + composer require retailcrm/api-client-php } magento_install() { - cd $MAGE_ROOT - - php bin/magento setup:install \ - --db-host="$DB_HOST" \ - --db-name="$DB_NAME" \ - --db-user="$DB_USER" \ - --admin-firstname="$ADMIN_FIRSTNAME" \ - --admin-lastname="$ADMIN_LASTNAME" \ - --admin-email="$ADMIN_EMAIL" \ - --admin-user="$ADMIN_USER" \ - --admin-password="$ADMIN_PASS" \ - --language="en_US" \ - --currency="USD" \ - --timezone="Europe/Moscow" + cd $MAGE_ROOT + php bin/magento setup:install \ + --db-host="localhost" \ + --db-name="magento2_test" \ + --db-user="root" \ + --db-password="root" \ + --admin-firstname="admin_firstname" \ + --admin-lastname="admin_lastname" \ + --admin-email="example@email.com" \ + --admin-user="admin" \ + --admin-password="admin123" \ + --language="en_US" \ + --currency="USD" \ + --timezone="Europe/Moscow" } module_install() { - cd $MAGE_ROOT - mkdir -p app/code/Retailcrm/Retailcrm - cp -R $TRAVIS_BUILD_DIR/src/* app/code/Retailcrm/Retailcrm + cd $MAGE_ROOT + mkdir -p app/code/Retailcrm/Retailcrm + cp -R $ROOT_DIR/src/* app/code/Retailcrm/Retailcrm - php bin/magento module:enable Retailcrm_Retailcrm - php bin/magento setup:upgrade - php bin/magento setup:di:compile + php bin/magento module:enable Retailcrm_Retailcrm + php bin/magento setup:upgrade + php bin/magento setup:di:compile } create_db diff --git a/src/composer.json b/src/composer.json index c4b3c40..550856a 100644 --- a/src/composer.json +++ b/src/composer.json @@ -5,7 +5,7 @@ "retailcrm/api-client-php": "~5.0" }, "type": "magento2-module", - "version": "2.5.1", + "version": "2.5.2", "license": [ "OSL-3.0", "AFL-3.0"