Browse Source

Use GitHub actions

tags/2.1.3
Alexander Makarov 4 years ago committed by GitHub
parent
commit
ea7a13455c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 49
      .github/workflows/build.yml
  2. 30
      .travis.yml
  3. 2
      README.md
  4. 13
      composer.json
  5. 2
      tests/bootstrap.php
  6. 32
      tests/compatibility.php

49
.github/workflows/build.yml

@ -0,0 +1,49 @@
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 }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
php: ['7.2', '7.3', '7.4', '8.0']
steps:
- name: Install sendmail
run: sudo apt-get install -y sendmail
- 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: 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

30
.travis.yml

@ -1,30 +0,0 @@
language: php
php:
- 7.0
- 7.1
- 7.2
# faster builds on new travis setup not using sudo
sudo: false
# cache vendor dirs
cache:
directories:
- $HOME/.composer/cache
install:
- sudo apt-get install -y sendmail
- travis_retry composer self-update && composer --version
- export PATH="$HOME/.composer/vendor/bin:$PATH"
- travis_retry composer install --prefer-dist --no-interaction
before_script:
- |
if [ $TRAVIS_PHP_VERSION = '5.6' ]; then
PHPUNIT_FLAGS="--coverage-clover=coverage.clover"
fi
script:
- ./vendor/bin/phpunit --verbose $PHPUNIT_FLAGS

2
README.md

@ -12,7 +12,7 @@ For license information check the [LICENSE](LICENSE.md)-file.
[![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2-swiftmailer/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-swiftmailer)
[![Total Downloads](https://poser.pugx.org/yiisoft/yii2-swiftmailer/downloads.png)](https://packagist.org/packages/yiisoft/yii2-swiftmailer)
[![Build Status](https://travis-ci.com/yiisoft/yii2-swiftmailer.svg?branch=master)](https://travis-ci.com/yiisoft/yii2-swiftmailer)
[![Build Status](https://github.com/yiisoft/yii2-swiftmailer/workflows/build/badge.svg)](https://github.com/yiisoft/yii2-swiftmailer/actions)
Installation
------------

13
composer.json

@ -22,7 +22,8 @@
"swiftmailer/swiftmailer": "~6.0"
},
"require-dev": {
"phpunit/phpunit": "<7"
"cweagans/composer-patches": "^1.7",
"phpunit/phpunit": "4.8.34"
},
"repositories": [
{
@ -36,6 +37,16 @@
"extra": {
"branch-alias": {
"dev-master": "2.1.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"
}
}
}
}

2
tests/bootstrap.php

@ -13,3 +13,5 @@ require_once(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');
Yii::setAlias('@yiiunit/extensions/swiftmailer', __DIR__);
Yii::setAlias('@yii/swiftmailer', dirname(__DIR__) . '/src');
require_once(__DIR__ . '/compatibility.php');

32
tests/compatibility.php

@ -0,0 +1,32 @@
<?php
/*
* Ensures compatibility with PHPUnit < 6.x
*/
namespace PHPUnit\Framework\Constraint {
if (!class_exists('PHPUnit\Framework\Constraint\Constraint') && class_exists('PHPUnit_Framework_Constraint')) {
abstract class Constraint extends \PHPUnit_Framework_Constraint {}
}
}
namespace PHPUnit\Framework {
if (!class_exists('PHPUnit\Framework\TestCase') && class_exists('PHPUnit_Framework_TestCase')) {
abstract class TestCase extends \PHPUnit_Framework_TestCase {
/**
* @param string $exception
*/
public function expectException($exception)
{
$this->setExpectedException($exception);
}
/**
* @param string $message
*/
public function expectExceptionMessage($message)
{
$this->setExpectedException($this->getExpectedException(), $message);
}
}
}
}
Loading…
Cancel
Save