Skip to content

Add support for GitHub actions #1859

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Jan 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/build-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: CI

on:
push:
branches:
tags:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
php: [7.1, 7.2, 7.3]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since 7.4 is out is that something we want to look at supporting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cann add 7.4 to matrix in any time

services:
mongo:
image: mongo
ports:
- 27017:27017
mysql:
image: mysql:5.7
ports:
- 3307:3306
env:
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
MYSQL_DATABASE: 'unittest'
MYSQL_ROOT_PASSWORD:

steps:
- uses: actions/checkout@v1
- name: Show php version
run: php${{ matrix.php }} -v && composer -V
- name: Show docker and docker-compose versions
run: |
docker version
- name: Debug if needed
run: if [[ "$DEBUG" == "true" ]]; then env; fi
env:
DEBUG: ${{secrets.DEBUG}}
- name: Install dependencies
run: |
composer install --no-interaction
- name: Generating code coverage
run: |
mkdir -p build/logs
./vendor/bin/phpunit --coverage-clover build/logs/clover.xml
env:
MONGO_HOST: 0.0.0.0
MYSQL_HOST: 0.0.0.0
MYSQL_PORT: 3307

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to set env vars before we run phpunit?
Also I see we are setting the MYSQL_PORT to 3306 in the phpunit.xml.dist, will that overwrite our 3307 from this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

env variable MYSQL_PORT override value in phpunit.xml

- name: Send coveralls
run: vendor/bin/php-coveralls -v
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11 changes: 9 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,16 @@
"phpunit/phpunit": "^6.0|^7.0|^8.0",
"orchestra/testbench": "^3.1|^4.0",
"mockery/mockery": "^1.0",
"satooshi/php-coveralls": "^2.0",
"doctrine/dbal": "^2.5"
"php-coveralls/php-coveralls": "dev-add-support-for-github-actions",
"doctrine/dbal": "^2.5",
"phpunit/phpcov": "5.0.0"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/Smolevich/php-coveralls"
}
],
"autoload": {
"psr-0": {
"Jenssegers\\Mongodb": "src/"
Expand Down
6 changes: 6 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,17 @@
<file>tests/ValidationTest.php</file>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
<php>
<env name="MONGO_HOST" value="mongodb"/>
<env name="MONGO_DATABASE" value="unittest"/>
<env name="MONGO_PORT" value="27017"/>
<env name="MYSQL_HOST" value="mysql"/>
<env name="MYSQL_PORT" value="3306"/>
<env name="MYSQL_DATABASE" value="unittest"/>
<env name="MYSQL_USERNAME" value="root"/>
<env name="QUEUE_CONNECTION" value="database"/>
Expand Down
2 changes: 2 additions & 0 deletions tests/config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since we are starting the mysql service on port 3307, if for some reason the env variable isn't set will this connect?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or can to connect or connect was failed

return [

Expand All @@ -23,6 +24,7 @@
'mysql' => [
'driver' => 'mysql',
'host' => env('MYSQL_HOST', 'mysql'),
'port' => $mysqlPort,
'database' => env('MYSQL_DATABASE', 'unittest'),
'username' => env('MYSQL_USERNAME', 'root'),
'password' => env('MYSQL_PASSWORD', ''),
Expand Down