Skip to content

Commit

Permalink
Use GitHub actions (#447)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
TonisOrmisson committed Feb 17, 2022
1 parent c32a2ca commit 422a17d
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 70 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -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


65 changes: 0 additions & 65 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# CHANGELOG

## 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)
- Enh: Added minimum requirements when a new password is automatically generated (MatteoF96)
- Fix #380: Avoid rewriting AccessRule::matchRole (maxxer)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
[![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)
[![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)
[![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)

Expand Down
5 changes: 3 additions & 2 deletions codeception.dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@ paths:
log: tests/_output
data: tests/_data
helpers: tests/_support
bootstrap: _bootstrap.php
settings:
bootstrap: _bootstrap.php
colors: true
memory_limit: 1024M
modules:
config:
Db:
dsn: 'mysql:host=127.0.0.1;dbname=yii2-usuario-test'
user: 'root'
password: ''
password: 'password'
dump: tests/_data/schema.sql
Yii2:
configFile: 'tests/_app/config/test.php'
cleanup: false
transaction: false
coverage:
enabled: true
whitelist:
Expand Down
1 change: 1 addition & 0 deletions src/User/Service/UserCreateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public function run()
$model->addError('username', $error_msg);
}
$transaction->rollBack();
Yii::error($error_msg, 'usuario');
return false;
}
$transaction->commit();
Expand Down
4 changes: 2 additions & 2 deletions tests/_app/config/db.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

$db = [
'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',
'password' => '',
'password' => 'password',
'charset' => 'utf8',
];

Expand Down

0 comments on commit 422a17d

Please sign in to comment.