Skip to content

Commit ea7a134

Browse files
authored
Use GitHub actions
1 parent 8958f99 commit ea7a134

File tree

6 files changed

+97
-33
lines changed

6 files changed

+97
-33
lines changed

.github/workflows/build.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: build
2+
3+
on: [push, pull_request]
4+
5+
env:
6+
DEFAULT_COMPOSER_FLAGS: "--prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi"
7+
8+
jobs:
9+
phpunit:
10+
name: PHP ${{ matrix.php }} on ${{ matrix.os }}
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: [ubuntu-latest]
16+
php: ['7.2', '7.3', '7.4', '8.0']
17+
18+
steps:
19+
- name: Install sendmail
20+
run: sudo apt-get install -y sendmail
21+
- name: Checkout
22+
uses: actions/checkout@v2
23+
- name: Install PHP
24+
uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: ${{ matrix.php }}
27+
- name: Get composer cache directory
28+
id: composer-cache
29+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
30+
- name: Cache composer dependencies
31+
uses: actions/cache@v1
32+
with:
33+
path: ${{ steps.composer-cache.outputs.dir }}
34+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
35+
restore-keys: ${{ runner.os }}-composer-
36+
- name: Install dependencies
37+
run: composer update $DEFAULT_COMPOSER_FLAGS
38+
- name: Run unit tests with coverage
39+
run: vendor/bin/phpunit --verbose --coverage-clover=coverage.clover --colors=always
40+
if: matrix.php == '7.1'
41+
- name: Run unit tests without coverage
42+
run: vendor/bin/phpunit --verbose --colors=always
43+
if: matrix.php != '7.1'
44+
- name: Upload code coverage
45+
run: |
46+
wget https://scrutinizer-ci.com/ocular.phar
47+
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
48+
if: matrix.php == '7.1'
49+
continue-on-error: true # if is fork

.travis.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ For license information check the [LICENSE](LICENSE.md)-file.
1212

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

1717
Installation
1818
------------

composer.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"swiftmailer/swiftmailer": "~6.0"
2323
},
2424
"require-dev": {
25-
"phpunit/phpunit": "<7"
25+
"cweagans/composer-patches": "^1.7",
26+
"phpunit/phpunit": "4.8.34"
2627
},
2728
"repositories": [
2829
{
@@ -36,6 +37,16 @@
3637
"extra": {
3738
"branch-alias": {
3839
"dev-master": "2.1.x-dev"
40+
},
41+
"composer-exit-on-patch-failure": true,
42+
"patches": {
43+
"phpunit/phpunit-mock-objects": {
44+
"Fix PHP 7 and 8 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_mock_objects.patch"
45+
},
46+
"phpunit/phpunit": {
47+
"Fix PHP 7 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_php7.patch",
48+
"Fix PHP 8 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_php8.patch"
49+
}
3950
}
4051
}
4152
}

tests/bootstrap.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@
1212
require_once(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');
1313

1414
Yii::setAlias('@yiiunit/extensions/swiftmailer', __DIR__);
15-
Yii::setAlias('@yii/swiftmailer', dirname(__DIR__) . '/src');
15+
Yii::setAlias('@yii/swiftmailer', dirname(__DIR__) . '/src');
16+
17+
require_once(__DIR__ . '/compatibility.php');

tests/compatibility.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/*
3+
* Ensures compatibility with PHPUnit < 6.x
4+
*/
5+
6+
namespace PHPUnit\Framework\Constraint {
7+
if (!class_exists('PHPUnit\Framework\Constraint\Constraint') && class_exists('PHPUnit_Framework_Constraint')) {
8+
abstract class Constraint extends \PHPUnit_Framework_Constraint {}
9+
}
10+
}
11+
12+
namespace PHPUnit\Framework {
13+
if (!class_exists('PHPUnit\Framework\TestCase') && class_exists('PHPUnit_Framework_TestCase')) {
14+
abstract class TestCase extends \PHPUnit_Framework_TestCase {
15+
/**
16+
* @param string $exception
17+
*/
18+
public function expectException($exception)
19+
{
20+
$this->setExpectedException($exception);
21+
}
22+
23+
/**
24+
* @param string $message
25+
*/
26+
public function expectExceptionMessage($message)
27+
{
28+
$this->setExpectedException($this->getExpectedException(), $message);
29+
}
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)