Skip to content

Commit 567a663

Browse files
committed
Merge pull request mongodb#1859 from Smolevich/add-support-for-github-actions
Add support for GitHub actions
2 parents 15810d2 + 4c7eeb5 commit 567a663

File tree

4 files changed

+71
-2
lines changed

4 files changed

+71
-2
lines changed

.github/workflows/build-ci.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
tags:
7+
pull_request:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
php: [7.1, 7.2, 7.3]
15+
services:
16+
mongo:
17+
image: mongo
18+
ports:
19+
- 27017:27017
20+
mysql:
21+
image: mysql:5.7
22+
ports:
23+
- 3307:3306
24+
env:
25+
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
26+
MYSQL_DATABASE: 'unittest'
27+
MYSQL_ROOT_PASSWORD:
28+
29+
steps:
30+
- uses: actions/checkout@v1
31+
- name: Show php version
32+
run: php${{ matrix.php }} -v && composer -V
33+
- name: Show docker and docker-compose versions
34+
run: |
35+
docker version
36+
- name: Debug if needed
37+
run: if [[ "$DEBUG" == "true" ]]; then env; fi
38+
env:
39+
DEBUG: ${{secrets.DEBUG}}
40+
- name: Install dependencies
41+
run: |
42+
composer install --no-interaction
43+
- name: Generating code coverage
44+
run: |
45+
mkdir -p build/logs
46+
./vendor/bin/phpunit --coverage-clover build/logs/clover.xml
47+
env:
48+
MONGO_HOST: 0.0.0.0
49+
MYSQL_HOST: 0.0.0.0
50+
MYSQL_PORT: 3307
51+
- name: Send coveralls
52+
run: vendor/bin/php-coveralls -v
53+
env:
54+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}

composer.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,16 @@
2929
"phpunit/phpunit": "^6.0|^7.0|^8.0",
3030
"orchestra/testbench": "^3.1|^4.0",
3131
"mockery/mockery": "^1.0",
32-
"satooshi/php-coveralls": "^2.0",
33-
"doctrine/dbal": "^2.5"
32+
"php-coveralls/php-coveralls": "dev-add-support-for-github-actions",
33+
"doctrine/dbal": "^2.5",
34+
"phpunit/phpcov": "5.0.0"
3435
},
36+
"repositories": [
37+
{
38+
"type": "vcs",
39+
"url": "https://github.com/Smolevich/php-coveralls"
40+
}
41+
],
3542
"autoload": {
3643
"psr-0": {
3744
"Jenssegers\\Mongodb": "src/"

phpunit.xml.dist

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,17 @@
4040
<file>tests/ValidationTest.php</file>
4141
</testsuite>
4242
</testsuites>
43+
<filter>
44+
<whitelist processUncoveredFilesFromWhitelist="true">
45+
<directory suffix=".php">./src</directory>
46+
</whitelist>
47+
</filter>
4348
<php>
4449
<env name="MONGO_HOST" value="mongodb"/>
4550
<env name="MONGO_DATABASE" value="unittest"/>
4651
<env name="MONGO_PORT" value="27017"/>
4752
<env name="MYSQL_HOST" value="mysql"/>
53+
<env name="MYSQL_PORT" value="3306"/>
4854
<env name="MYSQL_DATABASE" value="unittest"/>
4955
<env name="MYSQL_USERNAME" value="root"/>
5056
<env name="QUEUE_CONNECTION" value="database"/>

tests/config/database.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
$mongoHost = env('MONGO_HOST', 'mongodb');
44
$mongoPort = env('MONGO_PORT') ? (int) env('MONGO_PORT') : 27017;
5+
$mysqlPort = env('MYSQL_PORT') ? (int) env('MYSQL_PORT') : 3306;
56

67
return [
78

@@ -23,6 +24,7 @@
2324
'mysql' => [
2425
'driver' => 'mysql',
2526
'host' => env('MYSQL_HOST', 'mysql'),
27+
'port' => $mysqlPort,
2628
'database' => env('MYSQL_DATABASE', 'unittest'),
2729
'username' => env('MYSQL_USERNAME', 'root'),
2830
'password' => env('MYSQL_PASSWORD', ''),

0 commit comments

Comments
 (0)