Skip to content

Commit

Permalink
Use GitHub actions
Browse files Browse the repository at this point in the history
  • Loading branch information
samdark committed Oct 30, 2020
1 parent 9485ff1 commit aa5307c
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 47 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/build.yml
@@ -0,0 +1,68 @@
name: build

on: [push, pull_request]

env:
DEFAULT_COMPOSER_FLAGS: "--prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi"

jobs:
phpunit:
name: PHP ${{ matrix.php }} on ${{ matrix.os }}
services:
postgres:
image: postgres:9.6
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: yiitest
ports:
- 5432:5432
options: --name=postgres --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=3
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v1
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install dependencies
run: composer update $DEFAULT_COMPOSER_FLAGS
- name: Load database data
env:
PGHOST: 127.0.0.1
PGUSER: postgres
PGDATABASE: yiitest
PGPASSWORD: postgres
PGPORT: ${{ job.services.postgres.ports['5432'] }}
run: |
sudo apt-get update && sudo apt-get install -y postgresql-client
psql -U postgres yiitest < tests/data/pgsql.sql
echo "<?php unset(\$config['databases']['pgsql']['fixture']);" > tests/data/config.local.php
- name: Run unit tests with coverage
run: vendor/bin/phpunit --verbose --coverage-clover=coverage.clover --colors=always
if: matrix.php == '7.1'
- name: Run unit tests without coverage
run: vendor/bin/phpunit --verbose --colors=always
if: matrix.php != '7.1'
- name: Upload code coverage
run: |
wget https://scrutinizer-ci.com/ocular.phar
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
if: matrix.php == '7.1'
continue-on-error: true # if is fork
44 changes: 0 additions & 44 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -15,7 +15,7 @@ Documentation is at [docs/guide/README.md](docs/guide/README.md).

[![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2-gii/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-gii)
[![Total Downloads](https://poser.pugx.org/yiisoft/yii2-gii/downloads.png)](https://packagist.org/packages/yiisoft/yii2-gii)
[![Build Status](https://travis-ci.com/yiisoft/yii2-gii.svg?branch=master)](https://travis-ci.com/yiisoft/yii2-gii)
[![Build Status](https://github.com/yiisoft/yii2-gii/workflows/build/badge.svg)](https://github.com/yiisoft/yii2-gii/actions)


Installation
Expand Down
13 changes: 12 additions & 1 deletion composer.json
Expand Up @@ -28,7 +28,8 @@
},
"require-dev": {
"yiisoft/yii2-coding-standards": "~2.0",
"phpunit/phpunit": "<7"
"cweagans/composer-patches": "^1.7",
"phpunit/phpunit": "4.8.34"
},
"autoload": {
"psr-4": {
Expand All @@ -43,6 +44,16 @@
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
},
"composer-exit-on-patch-failure": true,
"patches": {
"phpunit/phpunit-mock-objects": {
"Fix PHP 7 and 8 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_mock_objects.patch"
},
"phpunit/phpunit": {
"Fix PHP 7 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_php7.patch",
"Fix PHP 8 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_php8.patch"
}
}
},
"config": {
Expand Down
3 changes: 2 additions & 1 deletion tests/ModuleTest.php
Expand Up @@ -9,6 +9,7 @@ class ModuleTest extends TestCase
{
public function testDefaultVersion()
{
$this->mockApplication();
Yii::$app->extensions['yiisoft/yii2-gii'] = [
'name' => 'yiisoft/yii2-gii',
'version' => '2.0.6',
Expand All @@ -18,4 +19,4 @@ public function testDefaultVersion()

$this->assertEquals('2.0.6', $module->getVersion());
}
}
}

0 comments on commit aa5307c

Please sign in to comment.