Skip to content

Commit b1f551f

Browse files
Fix Github Actions, add PHP versions 8.2, 8.3, 8.4. (#369)
1 parent e2a70a6 commit b1f551f

34 files changed

+218
-209
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ trim_trailing_whitespace = true
1212

1313
[*.md]
1414
trim_trailing_whitespace = false
15+
16+
[*.yml]
17+
indent_size = 2

.github/workflows/build.yml

Lines changed: 67 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,71 @@
1-
name: build
1+
on:
2+
pull_request:
3+
paths-ignore:
4+
- 'docs/**'
5+
- 'README.md'
6+
- 'CHANGELOG.md'
7+
- '.gitignore'
8+
- '.gitattributes'
9+
- 'infection.json.dist'
10+
- 'psalm.xml'
211

3-
on: [push, pull_request]
12+
push:
13+
paths-ignore:
14+
- 'docs/**'
15+
- 'README.md'
16+
- 'CHANGELOG.md'
17+
- '.gitignore'
18+
- '.gitattributes'
19+
- 'infection.json.dist'
20+
- 'psalm.xml'
421

5-
env:
6-
DEFAULT_COMPOSER_FLAGS: "--prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi"
22+
name: build
723

824
jobs:
9-
phpunit:
10-
name: PHP ${{ matrix.php }} (mongodb ${{ matrix.mongoext }}) on ${{ matrix.os }}
11-
runs-on: ${{ matrix.os }}
12-
services:
13-
mongodb:
14-
image: mongo:${{ matrix.mongo }}
15-
ports:
16-
- 27017:27017
17-
strategy:
18-
fail-fast: false
19-
matrix:
20-
os: [ubuntu-latest]
21-
php: ['7.4', '8.0', '8.1']
22-
mongo: ['4.0']
23-
mongoext: ['1.20.1']
24-
25-
steps:
26-
- name: Checkout
27-
uses: actions/checkout@v2
28-
- name: Install PHP
29-
uses: shivammathur/setup-php@v2
30-
with:
31-
php-version: ${{ matrix.php }}
32-
tools: pecl
33-
extensions: mongodb-${{ matrix.mongoext }}
34-
ini-values: date.timezone='UTC'
35-
- name: Get composer cache directory
36-
id: composer-cache
37-
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
38-
- name: Cache composer dependencies
39-
uses: actions/cache@v1
40-
with:
41-
path: ${{ steps.composer-cache.outputs.dir }}
42-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
43-
restore-keys: ${{ runner.os }}-composer-
44-
- name: Install dependencies
45-
run: composer update $DEFAULT_COMPOSER_FLAGS
46-
- name: Run unit tests with coverage
47-
run: vendor/bin/phpunit --verbose --coverage-clover=coverage.clover --colors=always
48-
if: matrix.php == '7.1'
49-
- name: Run unit tests without coverage
50-
run: vendor/bin/phpunit --verbose --colors=always
51-
if: matrix.php != '7.1'
52-
- name: Upload code coverage
53-
run: |
54-
wget https://scrutinizer-ci.com/ocular.phar
55-
php ocular.phar code-coverage:upload --format=php-clover coverage.clover
56-
if: matrix.php == '7.1'
57-
continue-on-error: true # if is fork
25+
phpunit:
26+
name: PHP ${{ matrix.php }} (mongodb ${{ matrix.mongoext }}) on ${{ matrix.os }}
27+
28+
runs-on: ${{ matrix.os }}
29+
30+
services:
31+
mongodb:
32+
image: mongo:${{ matrix.mongo }}
33+
ports:
34+
- 27017:27017
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
os: [ubuntu-latest]
39+
php: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
40+
mongo: ['4.0']
41+
mongoext: ['1.20.1']
42+
43+
steps:
44+
- name: Checkout.
45+
uses: actions/checkout@v2
46+
47+
- name: Install PHP.
48+
uses: shivammathur/setup-php@v2
49+
with:
50+
php-version: ${{ matrix.php }}
51+
tools: pecl
52+
extensions: mongodb-${{ matrix.mongoext }}
53+
ini-values: date.timezone='UTC'
54+
55+
- name: Install dependencies with composer.
56+
run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
57+
58+
- name: Run tests with phpunit.
59+
if: matrix.php != '8.1'
60+
run: vendor/bin/phpunit --colors=always
61+
62+
- name: Run tests with phpunit and generate coverage.
63+
if: matrix.php == '8.1'
64+
run: vendor/bin/phpunit --coverage-clover=coverage.xml --colors=always
65+
66+
- name: Upload coverage to Codecov.
67+
if: matrix.php == '8.1'
68+
uses: codecov/codecov-action@v3
69+
with:
70+
token: ${{ secrets.CODECOV_TOKEN }}
71+
file: ./coverage.xml

.scrutinizer.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
checks:
2+
php: true
3+
4+
filter:
5+
paths:
6+
- src/
7+
8+
build:
9+
image: default-bionic
10+
11+
environment:
12+
php:
13+
version: 8.2
14+
ini:
15+
xdebug.mode: coverage
16+
17+
nodes:
18+
analysis:
19+
tests:
20+
override:
21+
- php-scrutinizer-run
22+
23+
phpunit:
24+
services:
25+
mongo-db:
26+
image: mongo:4.0
27+
28+
ports:
29+
- 27017
30+
31+
dependencies:
32+
override:
33+
- yes "" | pecl install mongodb-1.20.1
34+
- composer self-update
35+
- composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi
36+
37+
tests:
38+
override:
39+
- command: ./vendor/bin/phpunit

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ Documentation is at [docs/guide/README.md](docs/guide/README.md).
1515
[![Latest Stable Version](https://poser.pugx.org/yiisoft/yii2-mongodb/v/stable.png)](https://packagist.org/packages/yiisoft/yii2-mongodb)
1616
[![Total Downloads](https://poser.pugx.org/yiisoft/yii2-mongodb/downloads.png)](https://packagist.org/packages/yiisoft/yii2-mongodb)
1717
[![Build Status](https://github.com/yiisoft/yii2-mongodb/workflows/build/badge.svg)](https://github.com/yiisoft/yii2-mongodb/actions)
18+
[![codecov](https://codecov.io/gh/yiisoft/yii2-mongodb/graph/badge.svg?token=1Xo867R6He)](https://codecov.io/gh/yiisoft/yii2-mongodb)
1819

20+
Requirements
21+
------------
22+
23+
- PHP 7.3 or higher.
1924

2025
Installation
2126
------------

composer.json

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@
1818
}
1919
],
2020
"require": {
21-
"yiisoft/yii2": "~2.0.39",
2221
"ext-mongodb": ">=1.20.1",
23-
"paragonie/random_compat": ">=1"
22+
"yiisoft/yii2": "~2.0.39"
2423
},
2524
"require-dev": {
26-
"cweagans/composer-patches": "^1.7",
27-
"phpunit/phpunit": "4.8.34"
25+
"phpunit/phpunit": "^9.6"
2826
},
2927
"repositories": [
3028
{
@@ -38,22 +36,10 @@
3836
"extra": {
3937
"branch-alias": {
4038
"dev-master": "2.1.x-dev"
41-
},
42-
"composer-exit-on-patch-failure": true,
43-
"patches": {
44-
"phpunit/phpunit-mock-objects": {
45-
"Fix PHP 7 and 8 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_mock_objects.patch"
46-
},
47-
"phpunit/phpunit": {
48-
"Fix PHP 7 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_php7.patch",
49-
"Fix PHP 8 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_php8.patch",
50-
"Fix PHP 8.1 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_php81.patch"
51-
}
5239
}
5340
},
5441
"config": {
5542
"allow-plugins": {
56-
"cweagans/composer-patches": true,
5743
"yiisoft/yii2-composer": true
5844
}
5945
}

phpunit.xml.dist

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<phpunit bootstrap="./tests/bootstrap.php"
3-
colors="true"
4-
convertErrorsToExceptions="true"
5-
convertNoticesToExceptions="true"
6-
convertWarningsToExceptions="true"
7-
stopOnFailure="false">
8-
<testsuites>
9-
<testsuite name="Yii2-mongodb Test Suite">
10-
<directory>./tests</directory>
11-
</testsuite>
12-
</testsuites>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
bootstrap="./tests/bootstrap.php"
5+
colors="true" convertErrorsToExceptions="true"
6+
convertNoticesToExceptions="true"
7+
convertWarningsToExceptions="true"
8+
stopOnFailure="false"
9+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
10+
>
11+
12+
<php>
13+
<ini name="error_reporting" value="-1"/>
14+
</php>
15+
16+
<testsuites>
17+
<testsuite name="Yii2-MongoDb">
18+
<directory>./tests</directory>
19+
</testsuite>
20+
</testsuites>
21+
22+
<coverage>
23+
<include>
24+
<directory>./src</directory>
25+
</include>
26+
</coverage>
1327
</phpunit>

tests/ActiveDataProviderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010

1111
class ActiveDataProviderTest extends TestCase
1212
{
13-
protected function setUp()
13+
protected function setUp(): void
1414
{
1515
parent::setUp();
1616
$this->mockApplication();
1717
ActiveRecord::$db = $this->getConnection();
1818
$this->setUpTestRows();
1919
}
2020

21-
protected function tearDown()
21+
protected function tearDown(): void
2222
{
2323
$this->dropCollection(Customer::collectionName());
2424
parent::tearDown();

tests/ActiveFixtureTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010

1111
class ActiveFixtureTest extends TestCase
1212
{
13-
protected function setUp()
13+
protected function setUp(): void
1414
{
1515
parent::setUp();
1616
$this->mockApplication();
1717
}
1818

19-
protected function tearDown()
19+
protected function tearDown(): void
2020
{
2121
$this->dropCollection(Customer::collectionName());
2222
FileHelper::removeDirectory(Yii::getAlias('@runtime/fixtures'));
@@ -163,4 +163,4 @@ class {$className} extends \yii\mongodb\ActiveFixture
163163
$rows = $this->findAll($this->getConnection()->getCollection(Customer::collectionName()));
164164
$this->assertCount(3, $rows);
165165
}
166-
}
166+
}

tests/ActiveRecordTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ class ActiveRecordTest extends TestCase
1919
*/
2020
protected $testRows = [];
2121

22-
protected function setUp()
22+
protected function setUp(): void
2323
{
2424
parent::setUp();
2525
ActiveRecord::$db = $this->getConnection();
2626
$this->setUpTestRows();
2727
}
2828

29-
protected function tearDown()
29+
protected function tearDown(): void
3030
{
3131
$this->dropCollection(Customer::collectionName());
3232
parent::tearDown();
@@ -518,4 +518,4 @@ public function testEmulateExecution()
518518
->distinct('name');
519519
$this->assertSame([], $values);
520520
}
521-
}
521+
}

tests/ActiveRelationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99

1010
class ActiveRelationTest extends TestCase
1111
{
12-
protected function setUp()
12+
protected function setUp(): void
1313
{
1414
parent::setUp();
1515
ActiveRecord::$db = $this->getConnection();
1616
$this->setUpTestRows();
1717
}
1818

19-
protected function tearDown()
19+
protected function tearDown(): void
2020
{
2121
$this->dropCollection(Customer::collectionName());
2222
$this->dropCollection(CustomerOrder::collectionName());

0 commit comments

Comments
 (0)