Compare commits

..

6 Commits
1.3.8 ... 1.3.9

Author SHA1 Message Date
7e81c058fb Merge pull request #54 from shivammathur/develop
Add option to disable coverage drivers
2019-10-05 15:32:11 +05:30
754ab9515b Add option to disable coverage drivers 2019-10-05 15:00:00 +05:30
f866c880c2 Merge pull request #52 from shivammathur/develop
Fix links in README. Broken in #51
2019-10-05 07:01:38 +05:30
eb21cb8fb3 Fix links in README. Broken in #51 2019-10-05 07:00:06 +05:30
aee6b953c3 Merge pull request #51 from shivammathur/develop
Fix examples and add coverage badge
2019-10-05 06:54:59 +05:30
21c3c8db47 Fix examples and add coverage badge 2019-10-05 06:44:08 +05:30
10 changed files with 108 additions and 19 deletions

View File

@ -8,6 +8,7 @@
<p align="left">
<a href="https://github.com/shivammathur/setup-php"><img alt="GitHub Actions status" src="https://github.com/shivammathur/setup-php/workflows/Main%20workflow/badge.svg"></a>
<a href="https://codecov.io/gh/shivammathur/setup-php"><img alt="Codecov Code Coverage" src="https://codecov.io/gh/shivammathur/setup-php/branch/master/graph/badge.svg"></a>
<a href="https://github.com/shivammathur/setup-php/blob/master/LICENSE"><img alt="LICENSE" src="https://img.shields.io/badge/license-MIT-428f7e.svg"></a>
<a href="#tada-php-support"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg"></a>
<a href="https://www.patreon.com/shivammathur"><img alt="Support me on Patreon" src="https://shivammathur.com/badges/patreon.svg"></a> <a href="https://www.paypal.me/shivammathur"><img alt="Support me on PayPal" src="https://shivammathur.com/badges/paypal.svg"></a>
@ -47,17 +48,23 @@ Setup PHP with required extensions, php.ini configuration and composer in [GitHu
- Extensions which cannot be installed gracefully leave an error message in the logs, the action is not interrupted.
## :signal_strength: Coverage support
- Specify `coverage: xdebug` to use `Xdebug`.
- Runs on all [PHP versions supported](#tada-php-support)
### Xdebug
Specify `coverage: xdebug` to use `Xdebug`.
Runs on all [PHP versions supported](#tada-php-support)
```
uses: shivammathur/setup-php@master
with:
php-version: 7.3
coverage: xdebug
```
- Specify `coverage: pcov` to use `PCOV`. `PCOV` is way faster than `Xdebug`
- For `pcov.directory` to be other than `src`, `lib` or, `app`, specify it using the `ini-values-csv` input.
- `PCOV` needs `PHPUnit >= 8.0` and `PHP >= 7.1`, `PHPUnit` needs `PHP >= 7.2`. So use `PHP >= 7.2` with `PCOV`
### PCOV
Specify `coverage: pcov` to use `PCOV`. `PCOV` is way faster than `Xdebug`.
For `pcov.directory` to be other than `src`, `lib` or, `app`, specify it using the `ini-values-csv` input.
`PCOV` needs `PHPUnit >= 8.0` and `PHP >= 7.1`, `PHPUnit` needs `PHP >= 7.2`. So use `PHP >= 7.2` with `PCOV`
```
uses: shivammathur/setup-php@master
with:
@ -66,6 +73,15 @@ with:
coverage: pcov
```
### Disable coverage
Specify `coverage: none` to disable both `Xdebug` and `PCOV`.
```
uses: shivammathur/setup-php@master
with:
php-version: 7.3
coverage: none
```
## :memo: Usage
Inputs supported by this GitHub Action.
@ -135,9 +151,9 @@ Examples for setting up this GitHub Action with different PHP Frameworks/Package
**Note:** Make sure you add steps to run your tests after the setup steps given in these examples.
- [Laravel with MySQL](./example/laravel-mysql.yml)
- [Laravel with PostgreSQL](./example/laravel-postgres.yml)
- [Slim Framework](./example/slim-framework.yml)
- [Laravel with MySQL](./examples/laravel-mysql.yml)
- [Laravel with PostgreSQL](./examples/laravel-postgres.yml)
- [Slim Framework](./examples/slim-framework.yml)
## :scroll: License

View File

@ -178,6 +178,10 @@ describe('Features tests', () => {
win32 = await features.addCoverage('pcov', '5.6', 'win32');
expect(win32).toContain('PCOV requires PHP 7.1 or newer');
win32 = await features.addCoverage('none', '7.4', 'win32');
expect(win32).toContain('Disable-PhpExtension xdebug');
expect(win32).toContain('Disable-PhpExtension pcov');
win32 = await features.addCoverage('', '7.4', 'win32');
expect(win32).toEqual('');
});
@ -191,6 +195,12 @@ describe('Features tests', () => {
expect(linux).toContain('sudo sed -i "/xdebug/d" $ini_file');
expect(linux).toContain('sudo phpdismod xdebug');
linux = await features.addCoverage('none', '7.4', 'linux');
expect(linux).toContain('sudo phpdismod xdebug');
expect(linux).toContain('sudo phpdismod pcov');
expect(linux).toContain('sudo sed -i "/xdebug/d" $ini_file');
expect(linux).toContain('sudo sed -i "/pcov/d" $ini_file');
linux = await features.addCoverage('', '7.4', 'linux');
expect(linux).toEqual('');
});
@ -205,6 +215,10 @@ describe('Features tests', () => {
darwin = await features.addCoverage('pcov', '7.4', 'darwin');
expect(darwin).toContain('sh ./pcov.sh');
darwin = await features.addCoverage('none', '7.4', 'darwin');
expect(darwin).toContain('sudo sed -i \'\' "/xdebug/d" $ini_file');
expect(darwin).toContain('sudo sed -i \'\' "/pcov/d" $ini_file');
darwin = await features.addCoverage('', '7.4', 'win32');
expect(darwin).toEqual('');
});

View File

@ -15,7 +15,7 @@ inputs:
description: '(Optional) Custom values you want to set in php.ini'
required: false
coverage:
description: '(Optional) Driver to calculate code coverage (Accepts: xdebug and pcov)'
description: '(Optional) Driver to calculate code coverage (Accepts: xdebug, pcov and none)'
required: false
runs:
using: 'node12'

View File

@ -9,6 +9,11 @@ jobs:
CACHE_DRIVER: redis
QUEUE_CONNECTION: redis
SESSION_DRIVER: redis
DB_CONNECTION: pgsql
DB_HOST: localhost
DB_PASSWORD: postgres
DB_USERNAME: postgres
DB_DATABASE: postgres
services:
postgres:
image: postgres:10.8
@ -50,5 +55,4 @@ jobs:
- name: Run Migration
run: php artisan migrate -v
env:
POSTGRES_HOST: localhost
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
DB_PORT: ${{ job.services.postgres.ports[5432] }}

View File

@ -297,8 +297,7 @@ function addINIValuesWindows(ini_values_csv) {
exports.addINIValuesWindows = addINIValuesWindows;
function addCoverage(coverage, version, os_version) {
return __awaiter(this, void 0, void 0, function* () {
let script = '';
script += '\n';
let script = '\n';
coverage = coverage.toLowerCase();
// pcov
switch (coverage) {
@ -340,7 +339,33 @@ function addCoverage(coverage, version, os_version) {
script += yield addExtension('xdebug', version, os_version, 'Set Coverage Driver');
script += yield utils.log('Xdebug enabled as coverage driver', os_version, 'success', 'Set Coverage Driver');
break;
// unknown coverage driver
case 'none':
switch (os_version) {
case 'linux':
script +=
'if [ -e /etc/php/' +
version +
'/mods-available/xdebug.ini ]; then sudo phpdismod xdebug; fi\n';
script +=
'if [ -e /etc/php/' +
version +
'/mods-available/pcov.ini ]; then sudo phpdismod pcov; fi\n';
script += 'sudo sed -i "/xdebug/d" $ini_file\n';
script += 'sudo sed -i "/pcov/d" $ini_file\n';
break;
case 'darwin':
script += 'sudo sed -i \'\' "/xdebug/d" $ini_file\n';
script += 'sudo sed -i \'\' "/pcov/d" $ini_file\n';
break;
case 'win32':
script +=
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php }\n';
script +=
'if(php -m | findstr -i pcov) { Disable-PhpExtension pcov C:\\tools\\php }\n';
break;
}
script += yield utils.log('Disabled Xdebug and PCOV', os_version, 'success', 'Set Coverage Driver');
break;
default:
script = '';
}

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "setup-php",
"version": "1.3.8",
"version": "1.3.9",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "setup-php",
"version": "1.3.8",
"version": "1.3.9",
"private": false,
"description": "Setup php action",
"main": "lib/setup-php.js",

View File

@ -364,8 +364,7 @@ export async function addCoverage(
version: string,
os_version: string
): Promise<string> {
let script: string = '';
script += '\n';
let script: string = '\n';
coverage = coverage.toLowerCase();
// pcov
switch (coverage) {
@ -434,7 +433,38 @@ export async function addCoverage(
'Set Coverage Driver'
);
break;
// unknown coverage driver
case 'none':
switch (os_version) {
case 'linux':
script +=
'if [ -e /etc/php/' +
version +
'/mods-available/xdebug.ini ]; then sudo phpdismod xdebug; fi\n';
script +=
'if [ -e /etc/php/' +
version +
'/mods-available/pcov.ini ]; then sudo phpdismod pcov; fi\n';
script += 'sudo sed -i "/xdebug/d" $ini_file\n';
script += 'sudo sed -i "/pcov/d" $ini_file\n';
break;
case 'darwin':
script += 'sudo sed -i \'\' "/xdebug/d" $ini_file\n';
script += 'sudo sed -i \'\' "/pcov/d" $ini_file\n';
break;
case 'win32':
script +=
'if(php -m | findstr -i xdebug) { Disable-PhpExtension xdebug C:\\tools\\php }\n';
script +=
'if(php -m | findstr -i pcov) { Disable-PhpExtension pcov C:\\tools\\php }\n';
break;
}
script += await utils.log(
'Disabled Xdebug and PCOV',
os_version,
'success',
'Set Coverage Driver'
);
break;
default:
script = '';
}