Improve extension support

This commit is contained in:
Shivam Mathur 2020-06-19 04:09:13 +05:30
parent 6b93e48d83
commit 31411b0d4d
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
11 changed files with 82 additions and 107 deletions

View File

@ -1,64 +0,0 @@
name: Experimental workflow
on:
pull_request:
branches:
- releases/v1
paths-ignore:
- '**.md'
- 'examples/**'
push:
branches:
- releases/v1
paths-ignore:
- '**.md'
- 'examples/**'
jobs:
run:
name: Run
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, windows-latest, macos-latest]
php-versions: ['8.0']
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP with extensions and custom config
run: node dist/index.js
env:
php-version: ${{ matrix.php-versions }}
extensions: xml, opcache, xdebug, pcov #optional
ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata #optional
coverage: pcov
- name: Testing PHP version
run: |
php -v
php -r "if(strpos(phpversion(), '${{ matrix.php-versions }}') === false) {throw new Exception('Wrong PHP version Installed');}"
- name: Testing Composer version
run: |
composer -V
php -r "if(strpos(@exec('composer -V'), 'Composer version') === false) {throw new Exception('Composer not found');}"
- name: Testing Extensions
run: |
php -m
php -r "if(! extension_loaded('mbstring')) {throw new Exception('mbstring not found');}"
php -r "if(! extension_loaded('pcov')) {throw new Exception('PCOV not found');}"
- name: Testing ini values
run: |
php -r "if(ini_get('post_max_size')!='256M') {throw new Exception('post_max_size not added');}"
php -r "if(ini_get('short_open_tag')!=1) {throw new Exception('short_open_tag not added');}"
php -r "if(ini_get('date.timezone')!='Asia/Kolkata') {throw new Exception('date.timezone not added');}"
- name: Test JIT
run: |
php -r "if(! extension_loaded('Zend OPcache')) {throw new Exception('Zend OPcache not found');}"
php -r "if(ini_get('opcache.jit_buffer_size')!='256M') {throw new Exception('opcache.jit_buffer_size not set');}"
php -r "if(ini_get('opcache.jit')!=1235) {throw new Exception('opcache.jit not set');}"
php -r "if(ini_get('pcre.jit')!=1) {throw new Exception('pcre.jit not set');}"
- name: Benchmark JIT
run: |
curl -o bench.php https://raw.githubusercontent.com/php/php-src/master/Zend/bench.php
php bench.php

View File

@ -20,7 +20,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, windows-latest, macos-latest]
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
steps:
- name: Checkout
uses: actions/checkout@v2

View File

@ -111,7 +111,7 @@ Tools which cannot be installed gracefully leave an error message in the logs, t
### Xdebug
Specify `coverage: xdebug` to use `Xdebug`.
Runs on all [PHP versions supported](#tada-php-support "List of PHP versions supported on this GitHub Action") except `8.0`.
Runs on all [PHP versions supported](#tada-php-support "List of PHP versions supported on this GitHub Action").
```yaml
uses: shivammathur/setup-php@v1

View File

@ -36,11 +36,6 @@ describe('Config tests', () => {
expect(win32).toContain('add_extension xdebug');
});
it('checking addCoverage with Xdebug on windows', async () => {
const win32: string = await coverage.addCoverage('xdebug', '8.0', 'win32');
expect(win32).toContain('Xdebug currently only supports PHP 7.4 or lower');
});
it('checking addCoverage with Xdebug on linux', async () => {
const linux: string = await coverage.addCoverage('xdebug', '7.4', 'linux');
expect(linux).toContain('add_extension xdebug');
@ -61,15 +56,6 @@ describe('Config tests', () => {
expect(darwin).toContain('add_extension xdebug');
});
it('checking addCoverage with Xdebug on darwin', async () => {
const darwin: string = await coverage.addCoverage(
'xdebug',
'8.0',
'darwin'
);
expect(darwin).toContain('Xdebug currently only supports PHP 7.4 or lower');
});
it('checking disableCoverage windows', async () => {
const win32 = await coverage.addCoverage('none', '7.4', 'win32');
expect(win32).toContain('Remove-Extension xdebug');

View File

@ -1,6 +1,12 @@
import * as extensions from '../src/extensions';
describe('Extension tests', () => {
it('checking getXdebugVersion', async () => {
expect(await extensions.getXdebugVersion('5.3')).toContain('2.2.7');
expect(await extensions.getXdebugVersion('5.4')).toContain('2.4.1');
expect(await extensions.getXdebugVersion('5.5')).toContain('2.5.5');
expect(await extensions.getXdebugVersion('5.6')).toContain('2.9.6');
});
it('checking addExtensionOnWindows', async () => {
let win32: string = await extensions.addExtension(
'Xdebug, pcov, sqlite, phalcon4, ast-beta',
@ -83,8 +89,8 @@ describe('Extension tests', () => {
'7.2',
'darwin'
);
expect(darwin).toContain('sudo pecl install -f xdebug');
expect(darwin).toContain('sudo pecl install -f pcov');
expect(darwin).toContain('add_brew_extension xdebug');
expect(darwin).toContain('add_brew_extension pcov');
expect(darwin).toContain('sudo pecl install -f sqlite3');
expect(darwin).toContain('add_unstable_extension ast beta extension');
@ -98,16 +104,16 @@ describe('Extension tests', () => {
expect(darwin).toContain('sudo pecl install -f pcov');
darwin = await extensions.addExtension('pcov', '7.2', 'darwin');
expect(darwin).toContain('sudo pecl install -f pcov');
expect(darwin).toContain('add_brew_extension pcov');
darwin = await extensions.addExtension('xdebug', '5.6', 'darwin');
expect(darwin).toContain('sudo pecl install -f xdebug-2.5.5');
expect(darwin).toContain('add_brew_extension xdebug');
darwin = await extensions.addExtension('xdebug', '7.0', 'darwin');
expect(darwin).toContain('sudo pecl install -f xdebug-2.9.0');
expect(darwin).toContain('add_brew_extension xdebug');
darwin = await extensions.addExtension('xdebug', '7.2', 'darwin');
expect(darwin).toContain('sudo pecl install -f xdebug');
expect(darwin).toContain('add_brew_extension xdebug');
darwin = await extensions.addExtension('redis', '5.6', 'darwin');
expect(darwin).toContain('sudo pecl install -f redis-2.2.8');

38
dist/index.js vendored
View File

@ -2648,9 +2648,27 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.addExtension = exports.addExtensionLinux = exports.addExtensionWindows = exports.addExtensionDarwin = void 0;
exports.addExtension = exports.addExtensionLinux = exports.addExtensionWindows = exports.addExtensionDarwin = exports.getXdebugVersion = void 0;
const path = __importStar(__webpack_require__(622));
const utils = __importStar(__webpack_require__(163));
/**
* Function to get Xdebug version compatible with php versions
*
* @param version
*/
async function getXdebugVersion(version) {
switch (version) {
case '5.3':
return '2.2.7';
case '5.4':
return '2.4.1';
case '5.5':
return '2.5.5';
default:
return '2.9.6';
}
}
exports.getXdebugVersion = getXdebugVersion;
/**
* Install and enable extensions for darwin
*
@ -2678,17 +2696,17 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
' ' +
ext_prefix;
return;
// match 5.6xdebug
case /5\.6xdebug/.test(version_extension):
command = command_prefix + 'xdebug-2.5.5' + pipe;
// match 5.6xdebug, 7.0xdebug...7.4xdebug, 8.0xdebug
case /(5\.6|7\.[0-4]|8\.[0-9])xdebug/.test(version_extension):
command = 'add_brew_extension xdebug';
break;
// match 7.0xdebug
case /7\.0xdebug/.test(version_extension):
command = command_prefix + 'xdebug-2.9.0' + pipe;
// match 7.1pcov...7.4pcov, 8.0pcov
case /(7\.[1-4]|8\.[0-9])pcov/.test(version_extension):
command = 'add_brew_extension pcov';
break;
// match 5.6redis
case /5\.6redis/.test(version_extension):
command = command_prefix + 'redis-2.2.8' + pipe;
command = command_prefix + 'redis-2.2.8';
break;
// match imagick
case /^imagick$/.test(extension):
@ -2703,7 +2721,7 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
// match sqlite
case /^sqlite$/.test(extension):
extension = 'sqlite3';
command = command_prefix + extension + pipe;
command = command_prefix + extension;
break;
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
@ -2716,7 +2734,7 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
version;
return;
default:
command = command_prefix + extension + pipe;
command = command_prefix + extension;
break;
}
script +=

Binary file not shown.

Binary file not shown.

View File

@ -1,6 +1,24 @@
import * as path from 'path';
import * as utils from './utils';
/**
* Function to get Xdebug version compatible with php versions
*
* @param version
*/
export async function getXdebugVersion(version: string): Promise<string> {
switch (version) {
case '5.3':
return '2.2.7';
case '5.4':
return '2.4.1';
case '5.5':
return '2.5.5';
default:
return '2.9.6';
}
}
/**
* Install and enable extensions for darwin
*
@ -32,17 +50,17 @@ export async function addExtensionDarwin(
' ' +
ext_prefix;
return;
// match 5.6xdebug
case /5\.6xdebug/.test(version_extension):
command = command_prefix + 'xdebug-2.5.5' + pipe;
// match 5.6xdebug, 7.0xdebug...7.4xdebug, 8.0xdebug
case /(5\.6|7\.[0-4]|8\.[0-9])xdebug/.test(version_extension):
command = 'add_brew_extension xdebug';
break;
// match 7.0xdebug
case /7\.0xdebug/.test(version_extension):
command = command_prefix + 'xdebug-2.9.0' + pipe;
// match 7.1pcov...7.4pcov, 8.0pcov
case /(7\.[1-4]|8\.[0-9])pcov/.test(version_extension):
command = 'add_brew_extension pcov';
break;
// match 5.6redis
case /5\.6redis/.test(version_extension):
command = command_prefix + 'redis-2.2.8' + pipe;
command = command_prefix + 'redis-2.2.8';
break;
// match imagick
case /^imagick$/.test(extension):
@ -57,7 +75,7 @@ export async function addExtensionDarwin(
// match sqlite
case /^sqlite$/.test(extension):
extension = 'sqlite3';
command = command_prefix + extension + pipe;
command = command_prefix + extension;
break;
// match 7.0phalcon3...7.3phalcon3 and 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
@ -70,7 +88,7 @@ export async function addExtensionDarwin(
version;
return;
default:
command = command_prefix + extension + pipe;
command = command_prefix + extension;
break;
}
script +=

View File

@ -68,6 +68,16 @@ add_pecl_extension() {
fi
}
# Function to install a php extension from shivammathur/extensions tap.
add_brew_extension() {
extension=$1
if ! brew tap | grep shivammathur/extensions; then
brew tap --shallow shivammathur/extensions
fi
brew install "$extension@$version"
sudo cp "$(brew --prefix)/opt/$extension@$version/$extension.so" "$ext_dir"
}
# Function to setup extensions
add_extension() {
extension=$1
@ -169,7 +179,7 @@ setup_php() {
update_formulae
fi
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
brew tap shivammathur/homebrew-php
brew tap --shallow shivammathur/homebrew-php
brew install shivammathur/php/php@"$version"
brew link --force --overwrite php@"$version"
}

View File

@ -239,7 +239,8 @@ Set-PhpIniKey -Key 'date.timezone' -Value 'UTC' -Path $php_dir
Enable-PhpExtension -Extension openssl, curl, opcache, mbstring -Path $php_dir
Update-PhpCAInfo -Path $php_dir -Source CurrentUser
if ($version -eq 'master') {
Copy-Item $dir"\..\src\bin\php_$env:PHPTS`_pcov.dll" -Destination $ext_dir"\php_pcov.dll"
Invoke-WebRequest -UseBasicParsing -Uri "https://github.com/shivammathur/php-extensions-windows/releases/latest/download/php_$env:phpts`_$arch`_pcov.dll" -OutFile $ext_dir"\php_pcov.dll" >$null 2>&1
Invoke-WebRequest -UseBasicParsing -Uri "https://github.com/shivammathur/php-extensions-windows/releases/latest/download/php_$env:phpts`_$arch`_xdebug.dll" -OutFile $ext_dir"\php_xdebug.dll" >$null 2>&1
Set-PhpIniKey -Key 'opcache.jit_buffer_size' -Value '256M' -Path $php_dir
Set-PhpIniKey -Key 'opcache.jit' -Value '1235' -Path $php_dir
}