Move CI to GitHub Actions (#158)
This commit is contained in:
parent
460b254a13
commit
e705ba456a
113
.github/workflows/ci.yml
vendored
Normal file
113
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
name: ci
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '**'
|
||||
tags-ignore:
|
||||
- '*.*'
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
DB_BITRIX_HOST: 0.0.0.0
|
||||
DB_BITRIX_LOGIN: root
|
||||
DB_BITRIX_PASS: root
|
||||
DB_BITRIX_NAME: bitrix
|
||||
BITRIX_PATH: ${{ github.workspace }}/bitrix
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
php-version: ['7.1', '7.2', '7.3']
|
||||
bitrix-edition: ['small_business_encode', 'business_encode']
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:5.7
|
||||
env:
|
||||
MYSQL_ROOT_PASSWORD: ${{ env.DB_BITRIX_PASS }}
|
||||
MYSQL_DATABASE: bitrix
|
||||
ports:
|
||||
- 3306:3306
|
||||
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 }}
|
||||
ini-values: short_open_tag=On, mbstring.func_overload=2, mbstring.internal_encoding="UTF-8"
|
||||
coverage: xdebug
|
||||
- name: Install Bitrix
|
||||
env:
|
||||
BITRIX_EDITION: ${{ matrix.bitrix-edition }}
|
||||
run: make bitrix_install
|
||||
- name: Enable debug mode for tests
|
||||
run: php bin/enable_debugging "${{ env.BITRIX_PATH }}"
|
||||
- name: Validate composer.json and composer.lock
|
||||
run: composer validate
|
||||
- name: Cache Composer packages
|
||||
id: composer-cache
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: vendor
|
||||
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-php-
|
||||
- name: Install dependencies
|
||||
if: steps.composer-cache.outputs.cache-hit != 'true'
|
||||
run: make deps
|
||||
- name: Run tests
|
||||
run: make test
|
||||
- name: Coverage
|
||||
run: 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
|
||||
ini-values: short_open_tag=On, mbstring.func_overload=2, mbstring.internal_encoding="UTF-8"
|
||||
- name: Build release
|
||||
run: |
|
||||
git fetch origin --unshallow --tags
|
||||
export CURRENT_VERSION=`php bin/bitrix-version`
|
||||
export ARCHIVE_PATH="${{ github.workspace }}/release/$CURRENT_VERSION.tar.gz"
|
||||
export LAST_TAG=`git describe --tags $(git rev-list --tags --max-count=1) || true`
|
||||
echo CURRENT_VERSION=$CURRENT_VERSION >> $GITHUB_ENV
|
||||
echo LAST_TAG=$LAST_TAG >> $GITHUB_ENV
|
||||
echo ARCHIVE_NAME="$CURRENT_VERSION.tar.gz" >> $GITHUB_ENV
|
||||
echo ARCHIVE_PATH=$ARCHIVE_PATH >> $GITHUB_ENV
|
||||
echo RELEASE_TAG=v$CURRENT_VERSION >> $GITHUB_ENV
|
||||
make build_release
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
if: env.LAST_TAG != env.RELEASE_TAG
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ env.RELEASE_TAG }}
|
||||
release_name: ${{ env.RELEASE_TAG }}
|
||||
body_path: ${{ github.workspace }}/intaro.retailcrm/description.ru
|
||||
draft: false
|
||||
prerelease: false
|
||||
- name: Upload Release Asset
|
||||
id: upload-release-asset
|
||||
if: env.LAST_TAG != env.RELEASE_TAG
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ${{ env.ARCHIVE_PATH }}
|
||||
asset_name: ${{ env.ARCHIVE_NAME }}
|
||||
asset_content_type: application/gzip
|
||||
- name: Cleanup
|
||||
if: env.LAST_TAG != env.RELEASE_TAG
|
||||
run: make cleanup
|
70
.travis.yml
70
.travis.yml
@ -1,70 +0,0 @@
|
||||
os: linux
|
||||
dist: trusty
|
||||
|
||||
language: php
|
||||
|
||||
if: tag IS blank
|
||||
|
||||
env:
|
||||
global:
|
||||
- DB_BITRIX_HOST=localhost
|
||||
- DB_BITRIX_LOGIN=root
|
||||
- DB_BITRIX_PASS=root
|
||||
- DB_BITRIX_NAME=bitrix
|
||||
- BITRIX_PATH=$TRAVIS_BUILD_DIR/bitrix
|
||||
|
||||
stages:
|
||||
- test
|
||||
- deploy
|
||||
|
||||
install:
|
||||
- echo 'short_open_tag = On' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
|
||||
- echo 'mbstring.func_overload = 2' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
|
||||
- echo 'mbstring.internal_encoding = "UTF-8"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
|
||||
- export LAST_TAG=`git describe --abbrev=0 --tags`
|
||||
- export CURRENT_VERSION=v`php bin/bitrix-version`
|
||||
|
||||
before_script:
|
||||
- make create_db
|
||||
- make bitrix_install
|
||||
|
||||
script: make test
|
||||
|
||||
jobs:
|
||||
include:
|
||||
- php: 7.0
|
||||
env: NOT_USE_VENDOR=1 BITRIX_EDITION=small_business_encode
|
||||
after_success: bash <(curl -s https://codecov.io/bash)
|
||||
- php: 7.1
|
||||
env: BITRIX_EDITION=small_business_encode
|
||||
- php: 7.2
|
||||
env: BITRIX_EDITION=small_business_encode
|
||||
- php: 7.3
|
||||
env: BITRIX_EDITION=small_business_encode
|
||||
- php: 7.0
|
||||
env: NOT_USE_VENDOR=1 BITRIX_EDITION=business_encode
|
||||
- php: 7.1
|
||||
env: BITRIX_EDITION=business_encode
|
||||
- php: 7.2
|
||||
env: BITRIX_EDITION=business_encode
|
||||
- php: 7.3
|
||||
env: BITRIX_EDITION=business_encode
|
||||
- stage: deploy
|
||||
php: 7.1
|
||||
before_script: export VERSION=`php bin/bitrix-version`
|
||||
script: make build_release
|
||||
before_deploy:
|
||||
- export ARCHIVE_NAME=$TRAVIS_BUILD_DIR/release/$VERSION.tar.gz
|
||||
- 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
|
||||
file: $ARCHIVE_NAME
|
||||
skip_cleanup: true
|
||||
on:
|
||||
condition: "$LAST_TAG != $CURRENT_VERSION"
|
||||
if: branch = master AND type = push AND fork = false
|
||||
after_deploy: make cleanup
|
20
Makefile
20
Makefile
@ -1,13 +1,9 @@
|
||||
ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
test: prepare_module
|
||||
ifeq ($(NOT_USE_VENDOR),1)
|
||||
composer tests7
|
||||
else
|
||||
composer tests
|
||||
endif
|
||||
|
||||
prepare_module: deps
|
||||
prepare_module:
|
||||
composer pre-module-install
|
||||
|
||||
deps:
|
||||
@ -29,29 +25,25 @@ bitrix_install: download_bitrix
|
||||
|
||||
download_bitrix:
|
||||
ifeq ("$(wildcard $(BITRIX_PATH)/bitrix/php_interface/dbconn.php)","")
|
||||
wget -O /tmp/$(BITRIX_EDITION).tar.gz https://www.1c-bitrix.ru/download/$(BITRIX_EDITION).tar.gz
|
||||
wget --progress=dot -e dotbytes=10M -O /tmp/$(BITRIX_EDITION).tar.gz https://www.1c-bitrix.ru/download/$(BITRIX_EDITION).tar.gz
|
||||
mkdir -p $(BITRIX_PATH)
|
||||
chmod -R 777 $(BITRIX_PATH)
|
||||
tar -xf /tmp/$(BITRIX_EDITION).tar.gz -C $(BITRIX_PATH)
|
||||
rm /tmp/$(BITRIX_EDITION).tar.gz
|
||||
endif
|
||||
|
||||
create_db:
|
||||
echo "USE mysql;\nUPDATE user SET password=PASSWORD('root') WHERE user='root';\nFLUSH PRIVILEGES;\n" | mysql -u root
|
||||
mysqladmin create $(DB_BITRIX_NAME) --user=$(DB_BITRIX_LOGIN) --password=$(DB_BITRIX_PASS)
|
||||
|
||||
build_release:
|
||||
ifneq ($(LAST_TAG),$(CURRENT_VERSION))
|
||||
ifneq ($(LAST_TAG),$(RELEASE_TAG))
|
||||
git diff --name-status $(LAST_TAG) HEAD > $(ROOT_DIR)/release/diff
|
||||
php bin/build-release
|
||||
bash bin/build $(VERSION) $(ROOT_DIR)/release/
|
||||
bash bin/build $(CURRENT_VERSION) $(ROOT_DIR)/release/
|
||||
else
|
||||
@exit 0
|
||||
endif
|
||||
|
||||
cleanup:
|
||||
@rm -rf $(ROOT_DIR)/release/$(VERSION)
|
||||
@rm $(ROOT_DIR)/release/$(VERSION).tar.gz
|
||||
@rm -rf $(ROOT_DIR)/release/$(CURRENT_VERSION)
|
||||
@rm $(ROOT_DIR)/release/$(CURRENT_VERSION).tar.gz
|
||||
|
||||
# docker commands
|
||||
install:
|
||||
|
@ -1,4 +1,4 @@
|
||||
[![Build Status](https://img.shields.io/travis/retailcrm/bitrix-module/master.svg?style=flat-square)](https://travis-ci.org/retailcrm/bitrix-module)
|
||||
[![Build Status](https://github.com/retailcrm/bitrix-module/workflows/ci/badge.svg)](https://github.com/retailcrm/bitrix-module/actions)
|
||||
[![Coverage](https://img.shields.io/codecov/c/gh/retailcrm/bitrix-module/master.svg?style=flat-square)](https://codecov.io/gh/retailcrm/bitrix-module)
|
||||
[![GitHub release](https://img.shields.io/github/release/retailcrm/bitrix-module.svg?style=flat-square)](https://github.com/retailcrm/bitrix-module/releases)
|
||||
[![PHP version](https://img.shields.io/badge/PHP->=5.3-blue.svg?style=flat-square)](https://php.net/)
|
||||
|
@ -16,6 +16,7 @@ if (!file_exists($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/install/wizar
|
||||
throw new \RuntimeException('Bitrix`s install files is not exists');
|
||||
}
|
||||
|
||||
ob_start();
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/install/wizard/wizard.php';
|
||||
require_once __DIR__ . '/../helpers/installation/ExtendedCreateModulesStep.php';
|
||||
require_once __DIR__ . '/../helpers/installation/Installer.php';
|
||||
@ -24,6 +25,8 @@ $installer = new Installer();
|
||||
|
||||
$step = $argv[1];
|
||||
|
||||
ob_clean();
|
||||
|
||||
switch ($step) {
|
||||
case 'db_type':
|
||||
$installer->dbTypeStep();
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
set_time_limit(0);
|
||||
|
||||
if (ini_get('memory_limit') > 0 && (int)ini_get('memory_limit') < 784) {
|
||||
if (ini_get('memory_limit') > 0 && (int) ini_get('memory_limit') < 784) {
|
||||
ini_set('memory_limit', '784M');
|
||||
}
|
||||
|
||||
|
6
bin/enable_debugging
Normal file
6
bin/enable_debugging
Normal file
@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
$file = $argv[1] . '/bitrix/.settings.php';
|
||||
$params = include $file;
|
||||
$params['exception_handling']['value']['debug'] = true;
|
||||
file_put_contents($file, "<?php\nreturn " . var_export($params, true) . ';', LOCK_EX);
|
@ -2,8 +2,7 @@
|
||||
"name": "retailcrm/bitrix-module",
|
||||
"scripts": {
|
||||
"pre-module-install": "cp -R intaro.retailcrm $BITRIX_PATH/bitrix/modules",
|
||||
"tests": "php vendor/bin/phpunit -c phpunit.xml.dist --whitelist=$BITRIX_PATH/bitrix/modules/intaro.retailcrm",
|
||||
"tests7": "phpunit -c phpunit.xml.dist --whitelist=$BITRIX_PATH/bitrix/modules/intaro.retailcrm"
|
||||
"tests": "php vendor/bin/phpunit -c phpunit.xml.dist --whitelist=$BITRIX_PATH/bitrix/modules/intaro.retailcrm"
|
||||
},
|
||||
"description": "Integration module for Bitrix & RetailCRM",
|
||||
"type": "bitrix-module",
|
||||
|
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
ob_start();
|
||||
require_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/install/wizard/wizard.php';
|
||||
ob_clean();
|
||||
|
||||
/**
|
||||
* Class Installer
|
||||
|
Loading…
Reference in New Issue
Block a user