Improve extension support

This commit is contained in:
Shivam Mathur 2020-06-19 04:09:13 +05:30
parent 70954fb6f8
commit b9404683e1
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A
13 changed files with 93 additions and 165 deletions

View File

@ -1,88 +0,0 @@
name: Experimental workflow
on:
pull_request:
branches:
- nightly
- master
- develop
- verbose
paths-ignore:
- '**.md'
- 'examples/**'
push:
branches:
- nightly
- master
- develop
- verbose
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']
env:
extensions: xml, opcache, pcov
key: cache-v2
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup cache environment
id: cache-env
uses: shivammathur/cache-extensions@develop
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
key: ${{ env.key }}
- name: Cache extensions
uses: actions/cache@v2
with:
path: ${{ steps.cache-env.outputs.dir }}
key: ${{ steps.cache-env.outputs.key }}
restore-keys: ${{ steps.cache-env.outputs.key }}
- name: Setup PHP with extensions and custom config
run: node dist/index.js
env:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
ini-values: post_max_size=256M, short_open_tag=On, date.timezone=Asia/Kolkata
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

@ -24,7 +24,7 @@ jobs:
fail-fast: false
matrix:
operating-system: [ubuntu-20.04, ubuntu-18.04, ubuntu-16.04, windows-latest, macos-latest]
php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
php-versions: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0']
env:
extensions: xml, opcache, xdebug, pcov
key: cache-v2

View File

@ -185,7 +185,7 @@ with:
### 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@v2

View File

@ -36,21 +36,11 @@ 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');
});
it('checking addCoverage with Xdebug on linux', async () => {
const linux: string = await coverage.addCoverage('xdebug', '8.0', 'linux');
expect(linux).toContain('Xdebug currently only supports PHP 7.4 or lower');
});
it('checking addCoverage with Xdebug on darwin', async () => {
const darwin: string = await coverage.addCoverage(
'xdebug',
@ -60,15 +50,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, :intl, phalcon4, ast-beta, grpc-1.2.3, inotify-1.2.3alpha2',
@ -104,8 +110,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('remove_extension intl');
expect(darwin).toContain('add_unstable_extension ast beta extension');
@ -121,7 +127,7 @@ 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.3', 'darwin');
expect(darwin).toContain('sudo pecl install -f xdebug-2.2.7');
@ -133,13 +139,13 @@ describe('Extension tests', () => {
expect(darwin).toContain('sudo pecl install -f xdebug-2.5.5');
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');

52
dist/index.js vendored
View File

@ -2148,9 +2148,6 @@ const config = __importStar(__webpack_require__(641));
*/
async function addCoverageXdebug(version, os_version, pipe) {
switch (version) {
case '8.0':
return ('\n' +
(await utils.addLog('$cross', 'xdebug', 'Xdebug currently only supports PHP 7.4 or lower', os_version)));
case '7.4':
default:
return ((await extensions.addExtension('xdebug', version, os_version, true)) +
@ -2685,9 +2682,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
*
@ -2741,25 +2756,22 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
' ' +
ext_prefix;
return;
// match 5.3xdebug
case /5\.3xdebug/.test(version_extension):
command = command_prefix + 'xdebug-2.2.7' + pipe;
// match 5.3xdebug...5.5xdebug
case /5\.[3-5]xdebug/.test(version_extension):
command =
command_prefix + 'xdebug-' + (await getXdebugVersion(version));
break;
// match 5.4xdebug
case /5\.4xdebug/.test(version_extension):
command = command_prefix + 'xdebug-2.4.1' + 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 5.5xdebug and 5.6xdebug
case /5\.[5-6]xdebug/.test(version_extension):
command = command_prefix + 'xdebug-2.5.5' + pipe;
break;
// match 7.0redis
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):
@ -2774,7 +2786,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):
@ -2787,7 +2799,7 @@ async function addExtensionDarwin(extension_csv, version, pipe) {
version;
return;
default:
command = command_prefix + extension + pipe;
command = command_prefix + extension;
break;
}
add_script +=

Binary file not shown.

Binary file not shown.

View File

@ -15,16 +15,6 @@ export async function addCoverageXdebug(
pipe: string
): Promise<string> {
switch (version) {
case '8.0':
return (
'\n' +
(await utils.addLog(
'$cross',
'xdebug',
'Xdebug currently only supports PHP 7.4 or lower',
os_version
))
);
case '7.4':
default:
return (

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
*
@ -60,25 +78,22 @@ export async function addExtensionDarwin(
' ' +
ext_prefix;
return;
// match 5.3xdebug
case /5\.3xdebug/.test(version_extension):
command = command_prefix + 'xdebug-2.2.7' + pipe;
// match 5.3xdebug...5.5xdebug
case /5\.[3-5]xdebug/.test(version_extension):
command =
command_prefix + 'xdebug-' + (await getXdebugVersion(version));
break;
// match 5.4xdebug
case /5\.4xdebug/.test(version_extension):
command = command_prefix + 'xdebug-2.4.1' + 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 5.5xdebug and 5.6xdebug
case /5\.[5-6]xdebug/.test(version_extension):
command = command_prefix + 'xdebug-2.5.5' + pipe;
break;
// match 7.0redis
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):
@ -93,7 +108,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):
@ -106,7 +121,7 @@ export async function addExtensionDarwin(
version;
return;
default:
command = command_prefix + extension + pipe;
command = command_prefix + extension;
break;
}
add_script +=

View File

@ -91,6 +91,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
@ -172,7 +182,7 @@ add_composertool() {
add_blackfire() {
sudo mkdir -p usr/local/var/run
brew tap blackfireio/homebrew-blackfire >/dev/null 2>&1
brew tap --shallow blackfireio/homebrew-blackfire >/dev/null 2>&1
brew install blackfire-agent >/dev/null 2>&1
if [[ -n $BLACKFIRE_SERVER_ID ]] && [[ -n $BLACKFIRE_SERVER_TOKEN ]]; then
sudo blackfire-agent --register --server-id="$BLACKFIRE_SERVER_ID" --server-token="$BLACKFIRE_SERVER_TOKEN" >/dev/null 2>&1
@ -212,7 +222,7 @@ update_formulae() {
setup_php() {
action=$1
export HOMEBREW_NO_INSTALL_CLEANUP=TRUE
brew tap shivammathur/homebrew-php
brew tap --shallow shivammathur/homebrew-php
if brew list php@"$version" 2>/dev/null | grep -q "Error" && [ "$action" != "upgrade" ]; then
brew unlink php@"$version"
else

View File

@ -120,7 +120,8 @@ add_pdo_extension() {
add_log "$tick" "$pdo_ext" "Enabled"
else
read -r ext ext_name <<< "$1 $1"
sudo rm -rf "$scan_dir"/*pdo.ini >/dev/null 2>&1 && echo "extension=pdo.so" >> "$ini_file"
sudo rm -rf "$scan_dir"/*pdo.ini >/dev/null 2>&1
if ! check_extension "pdo"; then echo "extension=pdo.so" >> "$ini_file"; fi
if [ "$ext" = "mysql" ]; then
enable_extension "mysqlnd" "extension"
ext_name="mysqli"

View File

@ -362,7 +362,8 @@ if($version -lt "5.5") {
}
Update-PhpCAInfo -Path $php_dir -Source $cert_source
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
}