Skip to content

Commit 7bdd1ac

Browse files
committed
Merge pull request #235 from shivammathur/develop
2.3.1
2 parents 70954fb + 66eac8a commit 7bdd1ac

33 files changed

+391
-462
lines changed

.github/workflows/experimental-workflow.yml

Lines changed: 0 additions & 88 deletions
This file was deleted.

.github/workflows/workflow.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
fail-fast: false
2525
matrix:
2626
operating-system: [ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, windows-latest, macos-latest]
27-
php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
27+
php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
2828
env:
2929
extensions: xml, opcache, xdebug, pcov
3030
key: cache-v2
@@ -33,7 +33,7 @@ jobs:
3333
uses: actions/checkout@v2
3434

3535
- name: Setup cache environment
36-
id: cache-env
36+
id: extcache
3737
uses: shivammathur/cache-extensions@develop
3838
with:
3939
php-version: ${{ matrix.php-versions }}
@@ -43,9 +43,9 @@ jobs:
4343
- name: Cache extensions
4444
uses: actions/cache@v2
4545
with:
46-
path: ${{ steps.cache-env.outputs.dir }}
47-
key: ${{ steps.cache-env.outputs.key }}
48-
restore-keys: ${{ steps.cache-env.outputs.key }}
46+
path: ${{ steps.extcache.outputs.dir }}
47+
key: ${{ steps.extcache.outputs.key }}
48+
restore-keys: ${{ steps.extcache.outputs.key }}
4949

5050
- name: Setup PHP with extensions and custom config
5151
run: node dist/index.js

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ with:
185185
### Xdebug
186186

187187
Specify `coverage: xdebug` to use `Xdebug`.
188-
Runs on all [PHP versions supported](#tada-php-support "List of PHP versions supported on this GitHub Action") except `8.0`.
188+
Runs on all [PHP versions supported](#tada-php-support "List of PHP versions supported on this GitHub Action").
189189

190190
```yaml
191191
uses: shivammathur/setup-php@v2
@@ -470,7 +470,7 @@ steps:
470470
uses: actions/checkout@v2
471471
472472
- name: Setup cache environment
473-
id: cache-env
473+
id: extcache
474474
uses: shivammathur/cache-extensions@v1
475475
with:
476476
php-version: ${{ matrix.php-versions }}
@@ -480,9 +480,9 @@ steps:
480480
- name: Cache extensions
481481
uses: actions/cache@v2
482482
with:
483-
path: ${{ steps.cache-env.outputs.dir }}
484-
key: ${{ steps.cache-env.outputs.key }}
485-
restore-keys: ${{ steps.cache-env.outputs.key }}
483+
path: ${{ steps.extcache.outputs.dir }}
484+
key: ${{ steps.extcache.outputs.key }}
485+
restore-keys: ${{ steps.extcache.outputs.key }}
486486
487487
- name: Setup PHP
488488
uses: shivammathur/setup-php@v2
@@ -499,13 +499,13 @@ If your project uses composer, you can persist composer's internal cache directo
499499

500500
```yaml
501501
- name: Get composer cache directory
502-
id: composer-cache
502+
id: composercache
503503
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
504504
505505
- name: Cache dependencies
506506
uses: actions/cache@v2
507507
with:
508-
path: ${{ steps.composer-cache.outputs.dir }}
508+
path: ${{ steps.composercache.outputs.dir }}
509509
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
510510
restore-keys: ${{ runner.os }}-composer-
511511
@@ -527,13 +527,13 @@ If your project has node.js dependencies, you can persist npm's or yarn's cache
527527

528528
```yaml
529529
- name: Get node.js cache directory
530-
id: node-cache-dir
530+
id: nodecache
531531
run: echo "::set-output name=dir::$(npm config get cache)" # Use $(yarn cache dir) for yarn
532532
533533
- name: Cache dependencies
534534
uses: actions/cache@v2
535535
with:
536-
path: ${{ steps.node-cache-dir.outputs.dir }}
536+
path: ${{ steps.nodecache.outputs.dir }}
537537
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} # Use '**/yarn.lock' for yarn
538538
restore-keys: ${{ runner.os }}-node-
539539
```

__tests__/coverage.test.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,15 @@ describe('Config tests', () => {
3636
expect(win32).toContain('add_extension xdebug');
3737
});
3838

39-
it('checking addCoverage with Xdebug on windows', async () => {
40-
const win32: string = await coverage.addCoverage('xdebug', '8.0', 'win32');
41-
expect(win32).toContain('Xdebug currently only supports PHP 7.4 or lower');
42-
});
43-
4439
it('checking addCoverage with Xdebug on linux', async () => {
4540
const linux: string = await coverage.addCoverage('xdebug', '7.4', 'linux');
4641
expect(linux).toContain('add_extension xdebug');
4742
});
4843

4944
it('checking addCoverage with Xdebug on linux', async () => {
5045
const linux: string = await coverage.addCoverage('xdebug', '8.0', 'linux');
51-
expect(linux).toContain('Xdebug currently only supports PHP 7.4 or lower');
46+
expect(linux).toContain('add_extension xdebug');
47+
expect(linux).toContain('echo "xdebug.mode=coverage"');
5248
});
5349

5450
it('checking addCoverage with Xdebug on darwin', async () => {
@@ -60,15 +56,6 @@ describe('Config tests', () => {
6056
expect(darwin).toContain('add_extension xdebug');
6157
});
6258

63-
it('checking addCoverage with Xdebug on darwin', async () => {
64-
const darwin: string = await coverage.addCoverage(
65-
'xdebug',
66-
'8.0',
67-
'darwin'
68-
);
69-
expect(darwin).toContain('Xdebug currently only supports PHP 7.4 or lower');
70-
});
71-
7259
it('checking disableCoverage windows', async () => {
7360
const win32 = await coverage.addCoverage('none', '7.4', 'win32');
7461
expect(win32).toContain('Remove-Extension xdebug');

__tests__/extensions.test.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import * as extensions from '../src/extensions';
22

33
describe('Extension tests', () => {
4+
it('checking getXdebugVersion', async () => {
5+
expect(await extensions.getXdebugVersion('5.3')).toContain('2.2.7');
6+
expect(await extensions.getXdebugVersion('5.4')).toContain('2.4.1');
7+
expect(await extensions.getXdebugVersion('5.5')).toContain('2.5.5');
8+
expect(await extensions.getXdebugVersion('5.6')).toContain('2.9.6');
9+
});
410
it('checking addExtensionOnWindows', async () => {
511
let win32: string = await extensions.addExtension(
612
'Xdebug, pcov, sqlite, :intl, phalcon4, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2',
@@ -104,8 +110,8 @@ describe('Extension tests', () => {
104110
'7.2',
105111
'darwin'
106112
);
107-
expect(darwin).toContain('sudo pecl install -f xdebug');
108-
expect(darwin).toContain('sudo pecl install -f pcov');
113+
expect(darwin).toContain('add_brew_extension xdebug');
114+
expect(darwin).toContain('add_brew_extension pcov');
109115
expect(darwin).toContain('sudo pecl install -f sqlite3');
110116
expect(darwin).toContain('remove_extension intl');
111117
expect(darwin).toContain('add_unstable_extension ast beta extension');
@@ -121,7 +127,7 @@ describe('Extension tests', () => {
121127
expect(darwin).toContain('sudo pecl install -f pcov');
122128

123129
darwin = await extensions.addExtension('pcov', '7.2', 'darwin');
124-
expect(darwin).toContain('sudo pecl install -f pcov');
130+
expect(darwin).toContain('add_brew_extension pcov');
125131

126132
darwin = await extensions.addExtension('xdebug', '5.3', 'darwin');
127133
expect(darwin).toContain('sudo pecl install -f xdebug-2.2.7');
@@ -133,13 +139,13 @@ describe('Extension tests', () => {
133139
expect(darwin).toContain('sudo pecl install -f xdebug-2.5.5');
134140

135141
darwin = await extensions.addExtension('xdebug', '5.6', 'darwin');
136-
expect(darwin).toContain('sudo pecl install -f xdebug-2.5.5');
142+
expect(darwin).toContain('add_brew_extension xdebug');
137143

138144
darwin = await extensions.addExtension('xdebug', '7.0', 'darwin');
139-
expect(darwin).toContain('sudo pecl install -f xdebug-2.9.0');
145+
expect(darwin).toContain('add_brew_extension xdebug');
140146

141147
darwin = await extensions.addExtension('xdebug', '7.2', 'darwin');
142-
expect(darwin).toContain('sudo pecl install -f xdebug');
148+
expect(darwin).toContain('add_brew_extension xdebug');
143149

144150
darwin = await extensions.addExtension('redis', '5.6', 'darwin');
145151
expect(darwin).toContain('sudo pecl install -f redis-2.2.8');

dist/index.js

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,16 +2147,15 @@ const config = __importStar(__webpack_require__(641));
21472147
* @param pipe
21482148
*/
21492149
async function addCoverageXdebug(version, os_version, pipe) {
2150-
switch (version) {
2151-
case '8.0':
2152-
return ('\n' +
2153-
(await utils.addLog('$cross', 'xdebug', 'Xdebug currently only supports PHP 7.4 or lower', os_version)));
2154-
case '7.4':
2150+
const xdebug = (await extensions.addExtension('xdebug', version, os_version, true)) + pipe;
2151+
const ini = await config.addINIValues('xdebug.mode=coverage', os_version, true);
2152+
const log = await utils.addLog('$tick', 'xdebug', 'Xdebug enabled as coverage driver', os_version);
2153+
switch (true) {
2154+
case /8.[0-9]/.test(version):
2155+
return xdebug + '\n' + ini + '\n' + log;
2156+
case /5\.[3-6]|7.[0-4]/.test(version):
21552157
default:
2156-
return ((await extensions.addExtension('xdebug', version, os_version, true)) +
2157-
pipe +
2158-
'\n' +
2159-
(await utils.addLog('$tick', 'xdebug', 'Xdebug enabled as coverage driver', os_version)));
2158+
return xdebug + '\n' + log;
21602159
}
21612160
}
21622161
exports.addCoverageXdebug = addCoverageXdebug;
@@ -2685,9 +2684,27 @@ var __importStar = (this && this.__importStar) || function (mod) {
26852684
return result;
26862685
};
26872686
Object.defineProperty(exports, "__esModule", { value: true });
2688-
exports.addExtension = exports.addExtensionLinux = exports.addExtensionWindows = exports.addExtensionDarwin = void 0;
2687+
exports.addExtension = exports.addExtensionLinux = exports.addExtensionWindows = exports.addExtensionDarwin = exports.getXdebugVersion = void 0;
26892688
const path = __importStar(__webpack_require__(622));
26902689
const utils = __importStar(__webpack_require__(163));
2690+
/**
2691+
* Function to get Xdebug version compatible with php versions
2692+
*
2693+
* @param version
2694+
*/
2695+
async function getXdebugVersion(version) {
2696+
switch (version) {
2697+
case '5.3':
2698+
return '2.2.7';
2699+
case '5.4':
2700+
return '2.4.1';
2701+
case '5.5':
2702+
return '2.5.5';
2703+
default:
2704+
return '2.9.6';
2705+
}
2706+
}
2707+
exports.getXdebugVersion = getXdebugVersion;
26912708
/**
26922709
* Install and enable extensions for darwin
26932710
*
@@ -2741,25 +2758,22 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
27412758
' ' +
27422759
ext_prefix;
27432760
return;
2744-
// match 5.3xdebug
2745-
case /5\.3xdebug/.test(version_extension):
2746-
command = command_prefix + 'xdebug-2.2.7' + pipe;
2747-
break;
2748-
// match 5.4xdebug
2749-
case /5\.4xdebug/.test(version_extension):
2750-
command = command_prefix + 'xdebug-2.4.1' + pipe;
2761+
// match 5.3xdebug...5.5xdebug
2762+
case /5\.[3-5]xdebug/.test(version_extension):
2763+
command =
2764+
command_prefix + 'xdebug-' + (await getXdebugVersion(version));
27512765
break;
2752-
// match 5.5xdebug and 5.6xdebug
2753-
case /5\.[5-6]xdebug/.test(version_extension):
2754-
command = command_prefix + 'xdebug-2.5.5' + pipe;
2766+
// match 5.6xdebug, 7.0xdebug...7.4xdebug, 8.0xdebug
2767+
case /(5\.6|7\.[0-4]|8\.[0-9])xdebug/.test(version_extension):
2768+
command = 'add_brew_extension xdebug';
27552769
break;
2756-
// match 7.0redis
2757-
case /7\.0xdebug/.test(version_extension):
2758-
command = command_prefix + 'xdebug-2.9.0' + pipe;
2770+
// match 7.1pcov...7.4pcov, 8.0pcov
2771+
case /(7\.[1-4]|8\.[0-9])pcov/.test(version_extension):
2772+
command = 'add_brew_extension pcov';
27592773
break;
27602774
// match 5.6redis
27612775
case /5\.6redis/.test(version_extension):
2762-
command = command_prefix + 'redis-2.2.8' + pipe;
2776+
command = command_prefix + 'redis-2.2.8';
27632777
break;
27642778
// match imagick
27652779
case /^imagick$/.test(extension):
@@ -2774,7 +2788,7 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
27742788
// match sqlite
27752789
case /^sqlite$/.test(extension):
27762790
extension = 'sqlite3';
2777-
command = command_prefix + extension + pipe;
2791+
command = command_prefix + extension;
27782792
break;
27792793
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
27802794
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
@@ -2787,7 +2801,7 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
27872801
version;
27882802
return;
27892803
default:
2790-
command = command_prefix + extension + pipe;
2804+
command = command_prefix + extension;
27912805
break;
27922806
}
27932807
add_script +=

0 commit comments

Comments
 (0)