Use GitHub actions (#447)

* init github actions

* init github actions: test run on feature branch

* github actions: remove alternative mysql port

* github actions: expose mysql port

* github actions: install & try migrations

* github actions: adjust test db configuration for github actions

* github actions: run tests

* github actions: fix codeception db connection add actions badge

* github actions: try only php8

* github actions: add php 7.4

* github actions: dont fail fast

* github actions: save test-outputs as artifacts

* github actions: save test-outputs only on fail

* github actions: save runtime folder in artifacts on failed build

* github actions: save runtime folder in artifacts on failed build

* github actions: save error  logs for tests

* github actions: log error if unable to send email on new user creation

* github actions: change log conf

* github actions: add tests yii2:transaction=false to pass tests on php < 8

* github actions: add tests yii2:transaction=false to pass tests on php < 8

* github actions: remove travis

* github actions: add changelog
This commit is contained in:
Tõnis Ormisson
2022-02-17 14:45:34 +02:00
committed by GitHub
parent c32a2ca4a9
commit 422a17d8dc
7 changed files with 88 additions and 70 deletions

79
.github/workflows/php.yml vendored Normal file
View File

@ -0,0 +1,79 @@
name: Build
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
operating-system: ['ubuntu-latest']
php-versions: ['8.1', '8.0','7.4','7.3', '7.2','7.1','7.0', '5.6']
services:
mariadb:
image: mariadb:latest
ports:
- 3306:3306
env:
MYSQL_USER: user
MYSQL_PASSWORD: password
MYSQL_DATABASE: yii2-usuario-test
MYSQL_ROOT_PASSWORD: password
options: --health-cmd="mysqladmin ping" --health-interval=5s --health-timeout=2s --health-retries=3
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: mbstring, intl, gd
ini-values: post_max_size=256M, max_execution_time=180
coverage: xdebug
- uses: actions/checkout@v2
- name: Verify MariaDB connection
run: |
while ! mysqladmin ping -h"127.0.0.1" --silent; do
sleep 1
done
- name: Validate PHP version
run: php -v
- 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: Verify db connection & databases
run: mysql -e "SHOW DATABASES;" -h127.0.0.1 -uroot -ppassword
- name: Install
run: composer install --prefer-dist --no-interaction
- name: Run migrations
run: php tests/_app/yii.php migrate/up --interactive=0 --migrationPath=@yii/rbac/migrations
- name: Run tests
run: XDEBUG_MODE=coverage php vendor/bin/codecept run --coverage --coverage-xml
- name: Archive failed tests artifacts - test output & log
uses: actions/upload-artifact@v2
if: failure()
with:
name: test-outputs-php-${{ matrix.php-versions }}
path: tests/_output

View File

@ -1,65 +0,0 @@
# faster builds on new travis setup not using sudo
sudo: false
language: php
php:
- 5.6
- 7.1
- 7.2
- 7.3
- 7.4
- nightly
services:
- mysql
matrix:
fast_finish: true
allow_failures:
- php: nightly
# cache vendor dirs
# cache:
# directories:
# - vendor
# - $HOME/.composer/cache
install:
- |
if [[ $TRAVIS_PHP_VERSION != '7.1' && $TRAVIS_PHP_VERSION != '7.2' && $TRAVIS_PHP_VERSION != hhv* ]]; then
# disable xdebug for performance reasons when code coverage is not needed
# note: xdebug on hhvm is disabled by default
phpenv config-rm xdebug.ini || echo "xdebug is not installed"
fi
- travis_retry composer self-update && composer --version
- export PATH="$HOME/.composer/vendor/bin:$PATH"
- COMPOSER_MEMORY_LIMIT=-1 travis_retry composer install --prefer-dist --no-interaction
before_script:
- php -r "echo INTL_ICU_VERSION . \"\n\";"
- php -r "echo INTL_ICU_DATA_VERSION . \"\n\";"
- mysql --version
# initialize database
- mysql -e 'CREATE DATABASE `yii2-usuario-test`;';
- php tests/_app/yii.php migrate/up --interactive=0
- php tests/_app/yii.php migrate/up --interactive=0 --migrationPath=@yii/rbac/migrations
# enable code coverage on PHP 7.2, only one PHP version needs to generate coverage data
- |
if [ $TRAVIS_PHP_VERSION = '7.2' ]; then
CODECEPTION_FLAGS="--coverage-xml"
fi
script:
- composer validate --no-check-lock
- vendor/bin/codecept run $CODECEPTION_FLAGS
after_script:
- |
if [ $TRAVIS_PHP_VERSION = '7.2' ]; then
travis_retry wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover tests/_output/coverage.xml
fi

View File

@ -1,6 +1,7 @@
# CHANGELOG # CHANGELOG
## work in progress ## work in progress
- Fix replace non-working travis build with working github actions build (TonisOrmisson)
- Fix user login events not triggered on ajax requests (TonisOrmisson) - Fix user login events not triggered on ajax requests (TonisOrmisson)
- Enh: Added minimum requirements when a new password is automatically generated (MatteoF96) - Enh: Added minimum requirements when a new password is automatically generated (MatteoF96)
- Fix #380: Avoid rewriting AccessRule::matchRole (maxxer) - Fix #380: Avoid rewriting AccessRule::matchRole (maxxer)

View File

@ -6,7 +6,8 @@ Yii 2 Usuario Extension
[![Packagist Version](https://img.shields.io/packagist/v/2amigos/yii2-usuario.svg?style=flat-square)](https://packagist.org/packages/2amigos/yii2-usuario) [![Packagist Version](https://img.shields.io/packagist/v/2amigos/yii2-usuario.svg?style=flat-square)](https://packagist.org/packages/2amigos/yii2-usuario)
[![Latest Stable Version](https://poser.pugx.org/2amigos/yii2-usuario/version)](https://packagist.org/packages/2amigos/yii2-usuario) [![Latest Stable Version](https://poser.pugx.org/2amigos/yii2-usuario/version)](https://packagist.org/packages/2amigos/yii2-usuario)
[![Total Downloads](https://poser.pugx.org/2amigos/yii2-usuario/downloads)](https://packagist.org/packages/2amigos/yii2-usuario) [![Total Downloads](https://poser.pugx.org/2amigos/yii2-usuario/downloads)](https://packagist.org/packages/2amigos/yii2-usuario)
[![Build Status](https://travis-ci.org/2amigos/yii2-usuario.svg?branch=master)](https://travis-ci.org/2amigos/yii2-usuario) [![Build Status](https://github.com/2amigos/yii2-usuario/actions/workflows/php.yml/badge.svg)](https://github.com/2amigos/yii2-usuario/actions/)
[![Latest Unstable Version](https://poser.pugx.org/2amigos/yii2-usuario/v/unstable)](//packagist.org/packages/2amigos/yii2-usuario) [![Latest Unstable Version](https://poser.pugx.org/2amigos/yii2-usuario/v/unstable)](//packagist.org/packages/2amigos/yii2-usuario)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/2amigos/yii2-usuario/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/2amigos/yii2-usuario/?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/2amigos/yii2-usuario/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/2amigos/yii2-usuario/?branch=master)

View File

@ -4,8 +4,8 @@ paths:
log: tests/_output log: tests/_output
data: tests/_data data: tests/_data
helpers: tests/_support helpers: tests/_support
settings:
bootstrap: _bootstrap.php bootstrap: _bootstrap.php
settings:
colors: true colors: true
memory_limit: 1024M memory_limit: 1024M
modules: modules:
@ -13,11 +13,12 @@ modules:
Db: Db:
dsn: 'mysql:host=127.0.0.1;dbname=yii2-usuario-test' dsn: 'mysql:host=127.0.0.1;dbname=yii2-usuario-test'
user: 'root' user: 'root'
password: '' password: 'password'
dump: tests/_data/schema.sql dump: tests/_data/schema.sql
Yii2: Yii2:
configFile: 'tests/_app/config/test.php' configFile: 'tests/_app/config/test.php'
cleanup: false cleanup: false
transaction: false
coverage: coverage:
enabled: true enabled: true
whitelist: whitelist:

View File

@ -87,6 +87,7 @@ class UserCreateService implements ServiceInterface
$model->addError('username', $error_msg); $model->addError('username', $error_msg);
} }
$transaction->rollBack(); $transaction->rollBack();
Yii::error($error_msg, 'usuario');
return false; return false;
} }
$transaction->commit(); $transaction->commit();

View File

@ -2,9 +2,9 @@
$db = [ $db = [
'class' => 'yii\db\Connection', 'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=localhost;dbname=yii2-usuario-test', 'dsn' => 'mysql:host=127.0.0.1;dbname=yii2-usuario-test',
'username' => 'root', 'username' => 'root',
'password' => '', 'password' => 'password',
'charset' => 'utf8', 'charset' => 'utf8',
]; ];