Compare commits

..

24 Commits
1.7.2 ... 1.7.4

Author SHA1 Message Date
e01b2f0bf7 Merge pull request #157 from shivammathur/develop
Fix description in actions.yml
2020-01-22 02:20:27 +05:30
f7f8ecb931 Fix description in actions.yml 2020-01-22 01:54:16 +05:30
4f0d810cbc Merge pull request #156 from shivammathur/develop
1.7.4
2020-01-22 01:48:36 +05:30
47335179aa Bump version to 1.7.4 2020-01-22 01:13:19 +05:30
63c4aea452 Refactor scripts to enable pre-existing ext-phalcon 2020-01-21 19:53:17 +05:30
898b6fa1f9 macOS-latest -> macos-latest 2020-01-21 08:25:14 +05:30
747c8838bc Add phive and ts support to readme 2020-01-21 08:24:33 +05:30
9d6b61c5af Add support for phive 2020-01-21 07:21:36 +05:30
5108c81610 Add support for ext-imagick on darwin 2020-01-21 01:06:31 +05:30
e58c704985 Use ppa:ondrej/php for phalcon4 on PHP7.4 2020-01-21 00:50:38 +05:30
e9c783eef0 Add support for specifying nts/ts builds on windows 2020-01-21 00:44:53 +05:30
b44e5e009f Use ppa:ondrej/php for phalcon except for PHP7.4 2020-01-20 21:07:51 +05:30
8489dbf4de Merge pull request #152 from shivammathur/develop
1.7.3
2020-01-17 17:16:16 +05:30
f23ae2e6f7 Fix xdebug and phalcon logs on linux 2020-01-17 16:53:12 +05:30
d2b233e45f Bump version to 1.7.3 2020-01-17 13:45:04 +05:30
320474a245 Add support for phpize and php-config 2020-01-17 13:21:39 +05:30
65ccfb36dc Fix extensions.ts 2020-01-17 06:07:33 +05:30
88fb99b592 Fix logs on windows for pre-installed version 2020-01-16 10:16:44 +05:30
9e7bc5c91f Fix phalcon.ps1 2020-01-16 09:23:04 +05:30
ca2f547a35 Fix log for composer on darwin 2020-01-16 09:06:55 +05:30
9f21c80d24 Install phalcon v4 from PECL on windows 2020-01-16 09:04:43 +05:30
c4317135df Disable composer process-timeout 2020-01-14 12:06:52 +05:30
a2dd688679 Improve test workflows 2020-01-14 11:42:08 +05:30
bd214a2dca Update old Xdebug version for coverage: xdebug 2020-01-14 11:02:17 +05:30
26 changed files with 1452 additions and 401 deletions

View File

@ -25,13 +25,11 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest] operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['8.0'] php-versions: ['8.0']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Setup Node.js 12.x - name: Setup Node.js 12.x
uses: actions/setup-node@v1 uses: actions/setup-node@v1

View File

@ -23,13 +23,11 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest] operating-system: [ubuntu-latest, 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']
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Setup Node.js 12.x - name: Setup Node.js 12.x
uses: actions/setup-node@v1 uses: actions/setup-node@v1

View File

@ -13,7 +13,7 @@
<a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg"></a> <a href="#tada-php-support" title="PHP Versions Supported"><img alt="PHP Versions Supported" src="https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg"></a>
</p> </p>
Setup PHP with required extensions, php.ini configuration, code-coverage support and tools like composer in [GitHub Actions](https://github.com/features/actions "GitHub Actions"). This action gives you a cross platform interface to setup the PHP environment you need to test your application. Refer to [Usage](#memo-usage "How to use this") section and [examples](#examples "Examples of use") to see how to use this. Setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer in [GitHub Actions](https://github.com/features/actions "GitHub Actions"). This action gives you a cross platform interface to setup the PHP environment you need to test your application. Refer to [Usage](#memo-usage "How to use this") section and [examples](#examples "Examples of use") to see how to use this.
## Contents ## Contents
@ -28,7 +28,8 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
- [Usage](#memo-usage) - [Usage](#memo-usage)
- [Basic Setup](#basic-setup) - [Basic Setup](#basic-setup)
- [Matrix Setup](#matrix-setup) - [Matrix Setup](#matrix-setup)
- [Experimental Setup](#experimental-setup) - [Experimental Setup](#experimental-setup)
- [Thread Safe Setup](#thread-safe-setup)
- [Cache dependencies](#cache-dependencies) - [Cache dependencies](#cache-dependencies)
- [Problem Matchers](#problem-matchers) - [Problem Matchers](#problem-matchers)
- [Examples](#examples) - [Examples](#examples)
@ -59,7 +60,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
|Windows Server 2019|`windows-latest` or `windows-2019`| |Windows Server 2019|`windows-latest` or `windows-2019`|
|Ubuntu 18.04|`ubuntu-latest` or `ubuntu-18.04`| |Ubuntu 18.04|`ubuntu-latest` or `ubuntu-18.04`|
|Ubuntu 16.04|`ubuntu-16.04`| |Ubuntu 16.04|`ubuntu-16.04`|
|macOS X Catalina 10.15|`macOS-latest` or `macOS-10.15`| |macOS X Catalina 10.15|`macos-latest` or `macOS-10.15`|
## :heavy_plus_sign: PHP Extension Support ## :heavy_plus_sign: PHP Extension Support
- On `ubuntu` by default extensions which are available as a package can be installed. If the extension is not available as a package but it is on `PECL`, it can be installed by specifying `pecl` in the tools input. - On `ubuntu` by default extensions which are available as a package can be installed. If the extension is not available as a package but it is on `PECL`, it can be installed by specifying `pecl` in the tools input.
@ -72,7 +73,7 @@ Setup PHP with required extensions, php.ini configuration, code-coverage support
These tools can be setup globally using the `tools` input. These tools can be setup globally using the `tools` input.
`codeception`, `composer`, `composer-prefetcher`, `deployer`, `pecl`, `phinx`, `phpcbf`, `phpcpd`, `php-cs-fixer`, `phpcs`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `psalm` `codeception`, `composer`, `composer-prefetcher`, `deployer`, `pecl`, `phinx`, `phive`, `phpcbf`, `phpcpd`, `php-config`, `php-cs-fixer`, `phpcs`, `phpize`, `phpmd`, `phpstan`, `phpunit`, `prestissimo`, `psalm`
```yaml ```yaml
uses: shivammathur/setup-php@v1 uses: shivammathur/setup-php@v1
@ -184,7 +185,7 @@ jobs:
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
strategy: strategy:
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest] operating-system: [ubuntu-latest, 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']
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }} name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
steps: steps:
@ -226,6 +227,29 @@ steps:
tools: php-cs-fixer, phpunit #optional, setup tools globally tools: php-cs-fixer, phpunit #optional, setup tools globally
``` ```
### Thread Safe Setup
- `NTS` versions are setup by default.
- On `ubuntu` and `macOS` only NTS versions are supported.
- On `windows` both `TS` and `NTS` versions are supported.
```yaml
jobs:
run:
runs-on: windows-latest
name: Setup PHP TS on Windows
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v1
with:
php-version: '7.4'
env:
PHPTS: ts # specify ts or nts
```
### Cache dependencies ### Cache dependencies
You can persist composer's internal cache directory using the [`action/cache`](https://github.com/actions/cache "GitHub Action to cache files") GitHub Action. Dependencies cached are loaded directly instead of downloading them while installation. The files cached are available across check-runs and will reduce the workflow execution time. You can persist composer's internal cache directory using the [`action/cache`](https://github.com/actions/cache "GitHub Action to cache files") GitHub Action. Dependencies cached are loaded directly instead of downloading them while installation. The files cached are available across check-runs and will reduce the workflow execution time.

View File

@ -30,10 +30,7 @@ describe('Extension tests', () => {
'7.4', '7.4',
'linux' 'linux'
); );
expect(linux).toContain( expect(linux).toContain('update_extension xdebug 2.9.0');
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-xdebug'
);
expect(linux).toContain('pecl install xdebug');
expect(linux).toContain( expect(linux).toContain(
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-pcov' 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php7.4-pcov'
); );
@ -44,30 +41,21 @@ describe('Extension tests', () => {
linux = await extensions.addExtension('gearman', '7.1', 'linux'); linux = await extensions.addExtension('gearman', '7.1', 'linux');
expect(linux).toContain('gearman.sh 7.1'); expect(linux).toContain('gearman.sh 7.1');
linux = await extensions.addExtension( linux = await extensions.addExtension('gearman', '7.2', 'linux');
'phalcon3, phalcon4, gearman',
'7.2',
'linux'
);
expect(linux).toContain('phalcon.sh phalcon3 7.2');
expect(linux).toContain('phalcon.sh phalcon4 7.2');
expect(linux).toContain('gearman.sh 7.2'); expect(linux).toContain('gearman.sh 7.2');
linux = await extensions.addExtension( linux = await extensions.addExtension('gearman', '7.3', 'linux');
'phalcon3, phalcon4, gearman',
'7.3',
'linux'
);
expect(linux).toContain('phalcon.sh phalcon3 7.3');
expect(linux).toContain('phalcon.sh phalcon4 7.3');
expect(linux).toContain('gearman.sh 7.3'); expect(linux).toContain('gearman.sh 7.3');
linux = await extensions.addExtension('phalcon4, gearman', '7.4', 'linux'); linux = await extensions.addExtension('gearman', '7.4', 'linux');
expect(linux).toContain('phalcon.sh phalcon4 7.4');
expect(linux).toContain('gearman.sh 7.4'); expect(linux).toContain('gearman.sh 7.4');
linux = await extensions.addExtension('xdebug', '7.2', 'fedora'); linux = await extensions.addExtension('xdebug', '7.2', 'fedora');
expect(linux).toContain('Platform fedora is not supported'); expect(linux).toContain('Platform fedora is not supported');
linux = await extensions.addExtension('phalcon3, phalcon4', '7.3', 'linux');
expect(linux).toContain('phalcon.sh phalcon3 7.3');
expect(linux).toContain('phalcon.sh phalcon4 7.3');
}); });
it('checking addExtensionOnDarwin', async () => { it('checking addExtensionOnDarwin', async () => {
@ -94,6 +82,9 @@ describe('Extension tests', () => {
darwin = await extensions.addExtension('xdebug', '5.6', 'darwin'); darwin = await extensions.addExtension('xdebug', '5.6', 'darwin');
expect(darwin).toContain('sudo pecl install xdebug-2.5.5'); expect(darwin).toContain('sudo pecl install xdebug-2.5.5');
darwin = await extensions.addExtension('xdebug', '7.0', 'darwin');
expect(darwin).toContain('sudo pecl install xdebug-2.9.0');
darwin = await extensions.addExtension('xdebug', '7.2', 'darwin'); darwin = await extensions.addExtension('xdebug', '7.2', 'darwin');
expect(darwin).toContain('sudo pecl install xdebug'); expect(darwin).toContain('sudo pecl install xdebug');
@ -103,6 +94,14 @@ describe('Extension tests', () => {
darwin = await extensions.addExtension('redis', '7.2', 'darwin'); darwin = await extensions.addExtension('redis', '7.2', 'darwin');
expect(darwin).toContain('sudo pecl install redis'); expect(darwin).toContain('sudo pecl install redis');
darwin = await extensions.addExtension('imagick', '5.6', 'darwin');
expect(darwin).toContain('brew install pkg-config imagemagick');
expect(darwin).toContain('sudo pecl install imagick');
darwin = await extensions.addExtension('imagick', '7.4', 'darwin');
expect(darwin).toContain('brew install pkg-config imagemagick');
expect(darwin).toContain('sudo pecl install imagick');
darwin = await extensions.addExtension( darwin = await extensions.addExtension(
'does_not_exist', 'does_not_exist',
'7.2', '7.2',

View File

@ -160,6 +160,18 @@ describe('Tools tests', () => {
); );
}); });
it('checking addPhive', async () => {
let script: string = await tools.addPhive('1.2.3', 'linux');
expect(script).toContain(
'add_tool https://github.com/phar-io/phive/releases/download/1.2.3/phive-1.2.3.phar phive'
);
script = await tools.addPhive('latest', 'win32');
expect(script).toContain(
'Add-Tool https://phar.io/releases/phive.phar phive'
);
});
it('checking getPhpunitUri', async () => { it('checking getPhpunitUri', async () => {
expect(await tools.getPhpunitUrl('tool', 'latest')).toBe( expect(await tools.getPhpunitUrl('tool', 'latest')).toBe(
'https://phar.phpunit.de/tool.phar' 'https://phar.phpunit.de/tool.phar'
@ -239,6 +251,35 @@ describe('Tools tests', () => {
expect(script).toContain('Platform fedora is not supported'); expect(script).toContain('Platform fedora is not supported');
}); });
it('checking addDevTools', async () => {
let script: string = await tools.addDevTools('phpize', 'linux');
expect(script).toContain('add_devtools');
expect(script).toContain('add_log "$tick" "phpize" "Added"');
script = await tools.addDevTools('php-config', 'linux');
expect(script).toContain('add_devtools');
expect(script).toContain('add_log "$tick" "php-config" "Added"');
script = await tools.addDevTools('phpize', 'darwin');
expect(script).toContain('add_log "$tick" "phpize" "Added"');
script = await tools.addDevTools('php-config', 'darwin');
expect(script).toContain('add_log "$tick" "php-config" "Added"');
script = await tools.addDevTools('phpize', 'win32');
expect(script).toContain(
'Add-Log "$cross" "phpize" "phpize is not a windows tool"'
);
script = await tools.addDevTools('php-config', 'win32');
expect(script).toContain(
'Add-Log "$cross" "php-config" "php-config is not a windows tool"'
);
script = await tools.addDevTools('tool', 'fedora');
expect(script).toContain('Platform fedora is not supported');
});
it('checking addPackage', async () => { it('checking addPackage', async () => {
let script: string = await tools.addPackage( let script: string = await tools.addPackage(
'tool', 'tool',
@ -260,7 +301,7 @@ describe('Tools tests', () => {
it('checking addTools on linux', async () => { it('checking addTools on linux', async () => {
const script: string = await tools.addTools( const script: string = await tools.addTools(
'php-cs-fixer, phpstan, phpunit, pecl, phinx, phinx:1.2.3', 'php-cs-fixer, phpstan, phpunit, pecl, phinx, phinx:1.2.3, phive, php-config, phpize',
'7.4', '7.4',
'linux' 'linux'
); );
@ -273,16 +314,22 @@ describe('Tools tests', () => {
expect(script).toContain( expect(script).toContain(
'add_tool https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar phpstan' 'add_tool https://github.com/phpstan/phpstan/releases/latest/download/phpstan.phar phpstan'
); );
expect(script).toContain(
'add_tool https://phar.io/releases/phive.phar phive'
);
expect(script).toContain( expect(script).toContain(
'add_tool https://phar.phpunit.de/phpunit.phar phpunit' 'add_tool https://phar.phpunit.de/phpunit.phar phpunit'
); );
expect(script).toContain('add_pecl'); expect(script).toContain('add_pecl');
expect(script).toContain('add_composer_tool phinx phinx robmorgan/'); expect(script).toContain('add_composer_tool phinx phinx robmorgan/');
expect(script).toContain('add_composer_tool phinx phinx:1.2.3 robmorgan/'); expect(script).toContain('add_composer_tool phinx phinx:1.2.3 robmorgan/');
expect(script).toContain('add_devtools');
expect(script).toContain('add_log "$tick" "php-config" "Added"');
expect(script).toContain('add_log "$tick" "phpize" "Added"');
}); });
it('checking addTools on darwin', async () => { it('checking addTools on darwin', async () => {
const script: string = await tools.addTools( const script: string = await tools.addTools(
'phpcs, phpcbf, phpcpd, phpmd, psalm, phinx, composer-prefetcher:1.2.3', 'phpcs, phpcbf, phpcpd, phpmd, psalm, phinx, phive:1.2.3, composer-prefetcher:1.2.3, phpize, php-config',
'7.4', '7.4',
'darwin' 'darwin'
); );
@ -305,13 +352,18 @@ describe('Tools tests', () => {
'https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm' 'https://github.com/vimeo/psalm/releases/latest/download/psalm.phar psalm'
); );
expect(script).toContain('add_composer_tool phinx phinx robmorgan/'); expect(script).toContain('add_composer_tool phinx phinx robmorgan/');
expect(script).toContain(
'add_tool https://github.com/phar-io/phive/releases/download/1.2.3/phive-1.2.3.phar phive'
);
expect(script).toContain( expect(script).toContain(
'add_composer_tool composer-prefetcher composer-prefetcher:1.2.3 narrowspark/automatic-' 'add_composer_tool composer-prefetcher composer-prefetcher:1.2.3 narrowspark/automatic-'
); );
expect(script).toContain('add_log "$tick" "phpize" "Added"');
expect(script).toContain('add_log "$tick" "php-config" "Added"');
}); });
it('checking addTools on windows', async () => { it('checking addTools on windows', async () => {
const script: string = await tools.addTools( const script: string = await tools.addTools(
'codeception, deployer, prestissimo, phpmd, phinx, does_not_exit', 'codeception, deployer, prestissimo, phpmd, phinx, phive:0.13.2, php-config, phpize, does_not_exit',
'7.4', '7.4',
'win32' 'win32'
); );
@ -324,7 +376,16 @@ describe('Tools tests', () => {
expect(script).toContain( expect(script).toContain(
'Add-Composer-Tool prestissimo prestissimo hirak/' 'Add-Composer-Tool prestissimo prestissimo hirak/'
); );
expect(script).toContain(
'Add-Tool https://github.com/phpmd/phpmd/releases/latest/download/phpmd.phar phpmd'
);
expect(script).toContain('Add-Composer-Tool phinx phinx robmorgan/'); expect(script).toContain('Add-Composer-Tool phinx phinx robmorgan/');
expect(script).toContain(
'Add-Tool https://github.com/phar-io/phive/releases/download/0.13.2/phive-0.13.2.phar phive'
);
expect(script).toContain('phpize is not a windows tool');
expect(script).toContain('php-config is not a windows tool');
expect(script).toContain('Tool does_not_exit is not supported');
expect(script).toContain('Tool does_not_exit is not supported'); expect(script).toContain('Tool does_not_exit is not supported');
}); });
it('checking addTools with composer tool using user/tool as input', async () => { it('checking addTools with composer tool using user/tool as input', async () => {

View File

@ -1,6 +1,6 @@
name: 'Setup PHP Action' name: 'Setup PHP Action'
author: shivammathur author: shivammathur
description: 'GitHub action to setup PHP with required extensions, php.ini configuration, code-coverage support and composer' description: 'Setup PHP with required extensions, php.ini configuration, code-coverage support and various tools like composer'
branding: branding:
color: 'purple' color: 'purple'
inputs: inputs:

93
dist/index.js vendored
View File

@ -1297,13 +1297,20 @@ class Command {
let cmdStr = CMD_STRING + this.command; let cmdStr = CMD_STRING + this.command;
if (this.properties && Object.keys(this.properties).length > 0) { if (this.properties && Object.keys(this.properties).length > 0) {
cmdStr += ' '; cmdStr += ' ';
let first = true;
for (const key in this.properties) { for (const key in this.properties) {
if (this.properties.hasOwnProperty(key)) { if (this.properties.hasOwnProperty(key)) {
const val = this.properties[key]; const val = this.properties[key];
if (val) { if (val) {
if (first) {
first = false;
}
else {
cmdStr += ',';
}
// safely append the val - avoid blowing up when attempting to // safely append the val - avoid blowing up when attempting to
// call .replace() if message is not a string for some reason // call .replace() if message is not a string for some reason
cmdStr += `${key}=${escape(`${val || ''}`)},`; cmdStr += `${key}=${escape(`${val || ''}`)}`;
} }
} }
} }
@ -1724,6 +1731,31 @@ function getCodeceptionUri(version, php_version) {
}); });
} }
exports.getCodeceptionUri = getCodeceptionUri; exports.getCodeceptionUri = getCodeceptionUri;
/**
* Helper function to get script to setup phive
*
* @param tool
* @param version
* @param url
* @param os_version
*/
function addPhive(version, os_version) {
return __awaiter(this, void 0, void 0, function* () {
switch (version) {
case 'latest':
return ((yield getArchiveCommand(os_version)) +
'https://phar.io/releases/phive.phar phive');
default:
return ((yield getArchiveCommand(os_version)) +
'https://github.com/phar-io/phive/releases/download/' +
version +
'/phive-' +
version +
'.phar phive');
}
});
}
exports.addPhive = addPhive;
/** /**
* Function to get the PHPUnit url * Function to get the PHPUnit url
* *
@ -1813,6 +1845,29 @@ function addArchive(tool, version, url, os_version) {
}); });
} }
exports.addArchive = addArchive; exports.addArchive = addArchive;
/**
* Function to get the script to setup php-config and phpize
*
* @param tool
* @param os_version
*/
function addDevTools(tool, os_version) {
return __awaiter(this, void 0, void 0, function* () {
switch (os_version) {
case 'linux':
return ('add_devtools' +
'\n' +
(yield utils.addLog('$tick', tool, 'Added', 'linux')));
case 'darwin':
return yield utils.addLog('$tick', tool, 'Added', 'darwin');
case 'win32':
return yield utils.addLog('$cross', tool, tool + ' is not a windows tool', 'win32');
default:
return yield utils.log('Platform ' + os_version + ' is not supported', os_version, 'error');
}
});
}
exports.addDevTools = addDevTools;
/** /**
* Helper function to get script to setup a tool using composer * Helper function to get script to setup a tool using composer
* *
@ -1858,6 +1913,9 @@ function addTools(tools_csv, php_version, os_version) {
url = github + 'squizlabs/PHP_CodeSniffer/' + uri; url = github + 'squizlabs/PHP_CodeSniffer/' + uri;
script += yield addArchive(tool, version, url, os_version); script += yield addArchive(tool, version, url, os_version);
break; break;
case 'phive':
script += yield addPhive(version, os_version);
break;
case 'phpstan': case 'phpstan':
url = github + 'phpstan/phpstan/' + uri; url = github + 'phpstan/phpstan/' + uri;
script += yield addArchive(tool, version, url, os_version); script += yield addArchive(tool, version, url, os_version);
@ -1902,6 +1960,10 @@ function addTools(tools_csv, php_version, os_version) {
case 'pecl': case 'pecl':
script += yield getPECLCommand(os_version); script += yield getPECLCommand(os_version);
break; break;
case 'php-config':
case 'phpize':
script += yield addDevTools(tool, os_version);
break;
default: default:
script += yield utils.addLog('$cross', tool, 'Tool ' + tool + ' is not supported', os_version); script += yield utils.addLog('$cross', tool, 'Tool ' + tool + ' is not supported', os_version);
break; break;
@ -2537,9 +2599,19 @@ function addExtensionDarwin(extension_csv, version, pipe) {
case /5\.6xdebug/.test(version_extension): case /5\.6xdebug/.test(version_extension):
install_command = 'sudo pecl install xdebug-2.5.5' + pipe; install_command = 'sudo pecl install xdebug-2.5.5' + pipe;
break; break;
case /7\.0xdebug/.test(version_extension):
install_command = 'sudo pecl install xdebug-2.9.0' + pipe;
break;
case /5\.6redis/.test(version_extension): case /5\.6redis/.test(version_extension):
install_command = 'sudo pecl install redis-2.2.8' + pipe; install_command = 'sudo pecl install redis-2.2.8' + pipe;
break; break;
case /[5-9]\.\dimagick/.test(version_extension):
install_command =
'brew install pkg-config imagemagick' +
pipe +
' && sudo pecl install imagick' +
pipe;
break;
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
install_command = install_command =
'sh ' + 'sh ' +
@ -2631,17 +2703,24 @@ function addExtensionLinux(extension_csv, version, pipe) {
version + version +
pipe; pipe;
break; break;
// match 7.0phalcon3..7.3phalcon3 and 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 or 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
install_command = script +=
'sh ' + '\nsh ' +
path.join(__dirname, '../src/scripts/ext/phalcon.sh') + path.join(__dirname, '../src/scripts/ext/phalcon.sh') +
' ' + ' ' +
extension + extension +
' ' + ' ' +
version + version;
pipe; return;
break; // match 7.0xdebug..7.4xdebug
case /^7\.[0-4]xdebug$/.test(version_extension):
script +=
'\nupdate_extension xdebug 2.9.0' +
pipe +
'\n' +
(yield utils.addLog('$tick', 'xdebug', 'Enabled', 'linux'));
return;
default: default:
install_command = install_command =
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php' + 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php' +

View File

@ -6,7 +6,7 @@ jobs:
tests: tests:
strategy: strategy:
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest] operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.2', '7.3', '7.4'] php-versions: ['7.2', '7.3', '7.4']
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
steps: steps:

View File

@ -5,7 +5,7 @@ jobs:
build: build:
strategy: strategy:
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest] operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.2', '7.3', '7.4'] php-versions: ['7.2', '7.3', '7.4']
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
steps: steps:

View File

@ -8,7 +8,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest] operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.2', '7.3', '7.4'] php-versions: ['7.2', '7.3', '7.4']
steps: steps:
- name: Checkout - name: Checkout

View File

@ -8,7 +8,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest] operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.2', '7.3', '7.4'] php-versions: ['7.2', '7.3', '7.4']
steps: steps:
- name: Checkout - name: Checkout

View File

@ -5,7 +5,7 @@ jobs:
build: build:
strategy: strategy:
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest] operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.2', '7.3', '7.4'] php-versions: ['7.2', '7.3', '7.4']
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
steps: steps:

View File

@ -8,7 +8,7 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest] operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.3', '7.4'] php-versions: ['7.3', '7.4']
steps: steps:
- name: Checkout - name: Checkout

View File

@ -5,7 +5,7 @@ jobs:
build: build:
strategy: strategy:
matrix: matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest] operating-system: [ubuntu-latest, windows-latest, macos-latest]
php-versions: ['7.2', '7.3', '7.4'] php-versions: ['7.2', '7.3', '7.4']
runs-on: ${{ matrix.operating-system }} runs-on: ${{ matrix.operating-system }}
steps: steps:

1251
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "setup-php", "name": "setup-php",
"version": "1.7.2", "version": "1.7.4",
"private": false, "private": false,
"description": "Setup PHP for use with GitHub Actions", "description": "Setup PHP for use with GitHub Actions",
"main": "dist/index.js", "main": "dist/index.js",

Binary file not shown.

BIN
src/bin/php_ts_pcov.dll Normal file

Binary file not shown.

View File

@ -24,9 +24,19 @@ export async function addExtensionDarwin(
case /5\.6xdebug/.test(version_extension): case /5\.6xdebug/.test(version_extension):
install_command = 'sudo pecl install xdebug-2.5.5' + pipe; install_command = 'sudo pecl install xdebug-2.5.5' + pipe;
break; break;
case /7\.0xdebug/.test(version_extension):
install_command = 'sudo pecl install xdebug-2.9.0' + pipe;
break;
case /5\.6redis/.test(version_extension): case /5\.6redis/.test(version_extension):
install_command = 'sudo pecl install redis-2.2.8' + pipe; install_command = 'sudo pecl install redis-2.2.8' + pipe;
break; break;
case /[5-9]\.\dimagick/.test(version_extension):
install_command =
'brew install pkg-config imagemagick' +
pipe +
' && sudo pecl install imagick' +
pipe;
break;
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
install_command = install_command =
'sh ' + 'sh ' +
@ -118,17 +128,24 @@ export async function addExtensionLinux(
version + version +
pipe; pipe;
break; break;
// match 7.0phalcon3..7.3phalcon3 and 7.2phalcon4...7.4phalcon4 // match 7.0phalcon3...7.3phalcon3 or 7.2phalcon4...7.4phalcon4
case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension): case /^7\.[0-3]phalcon3$|^7\.[2-4]phalcon4$/.test(version_extension):
install_command = script +=
'sh ' + '\nsh ' +
path.join(__dirname, '../src/scripts/ext/phalcon.sh') + path.join(__dirname, '../src/scripts/ext/phalcon.sh') +
' ' + ' ' +
extension + extension +
' ' + ' ' +
version + version;
pipe; return;
break; // match 7.0xdebug..7.4xdebug
case /^7\.[0-4]xdebug$/.test(version_extension):
script +=
'\nupdate_extension xdebug 2.9.0' +
pipe +
'\n' +
(await utils.addLog('$tick', 'xdebug', 'Enabled', 'linux'));
return;
default: default:
install_command = install_command =
'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php' + 'sudo DEBIAN_FRONTEND=noninteractive apt-get install -y php' +

View File

@ -53,6 +53,8 @@ add_tool() {
tool=$2 tool=$2
if [ "$tool" = "composer" ]; then if [ "$tool" = "composer" ]; then
brew install composer >/dev/null 2>&1 brew install composer >/dev/null 2>&1
composer -q global config process-timeout 0
add_log "$tick" "$tool" "Added"
else else
if [ ! -e /usr/local/bin/"$tool" ]; then if [ ! -e /usr/local/bin/"$tool" ]; then
rm -rf /usr/local/bin/"${tool:?}" rm -rf /usr/local/bin/"${tool:?}"
@ -65,6 +67,11 @@ add_tool() {
add_log "$cross" "$tool" "Could not setup $tool" add_log "$cross" "$tool" "Could not setup $tool"
fi fi
fi fi
if [ "$tool" = "phive" ]; then
add_extension curl >/dev/null 2>&1
add_extension mbstring >/dev/null 2>&1
add_extension xml >/dev/null 2>&1
fi
} }
add_composer_tool() { add_composer_tool() {

View File

@ -10,18 +10,47 @@ Param (
[string] [string]
$version $version
) )
# Function to install phalcon
Function Install-Phalcon() {
if ($extension_version -eq '4') {
Install-Phpextension phalcon -MinimumStability stable -Path $php_dir
} else {
$installed = Get-Php -Path $php_dir
$nts = if (!$installed.ThreadSafe) { "_nts" } else { "" }
$match = Invoke-WebRequest -UseBasicParsing -Uri $domain/phalcon/cphalcon/releases | Select-String -Pattern "href=`"(.*phalcon_x64_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)`""
$zip_file = $match.Matches[0].Groups[1].Value
Invoke-WebRequest -UseBasicParsing -Uri $domain/$zip_file -OutFile $ENV:RUNNER_TOOL_CACHE\phalcon.zip > $null 2>&1
Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\phalcon.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\phalcon -Force > $null 2>&1
New-Item -ItemType SymbolicLink -Path $ext_dir\php_phalcon.dll -Target $ENV:RUNNER_TOOL_CACHE\phalcon\php_phalcon.dll > $null 2>&1
Enable-PhpExtension -Extension phalcon -Path $php_dir
}
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "32" $tick $extension "Installed and enabled"
}
$tick = ([char]8730) $tick = ([char]8730)
$domain = 'https://github.com' $domain = 'https://github.com'
$php_dir = 'C:\tools\php' $php_dir = 'C:\tools\php'
$ext_dir = $php_dir + '\ext' $ext_dir = $php_dir + '\ext'
$installed = Get-Php -Path $php_dir
$extension_version = $extension.substring($extension.Length - 1) $extension_version = $extension.substring($extension.Length - 1)
$nts = if(! $installed.ThreadSafe ) { "_nts" } else { "" }
$match = Invoke-WebRequest -UseBasicParsing -Uri $domain/phalcon/cphalcon/releases | Select-String -Pattern "href=`"(.*phalcon_x64_.*_php${version}_${extension_version}.*[0-9]${nts}.zip)`"" if($extension_version -eq '4') {
$zip_file = $match.Matches[0].Groups[1].Value if (Test-Path $ext_dir\php_psr.dll) {
Invoke-WebRequest -UseBasicParsing -Uri $domain/$zip_file -OutFile $ENV:RUNNER_TOOL_CACHE\phalcon.zip >$null 2>&1 Enable-PhpExtension -Extension psr -Path $php_dir
Expand-Archive -Path $ENV:RUNNER_TOOL_CACHE\phalcon.zip -DestinationPath $ENV:RUNNER_TOOL_CACHE\phalcon -Force >$null 2>&1 } else {
New-Item -ItemType SymbolicLink -Path $ext_dir\php_phalcon.dll -Target $ENV:RUNNER_TOOL_CACHE\phalcon\php_phalcon.dll >$null 2>&1 Install-Phpextension psr -MinimumStability stable -Path $php_dir
Install-Phpextension psr -MinimumStability stable -Path $php_dir }
Enable-PhpExtension -Extension phalcon -Path $php_dir }
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "32" $tick $extension "Installed and enabled"
if(Test-Path $ext_dir\php_phalcon.dll) {
$phalcon = Get-PhpExtension $ext_dir\php_phalcon.dll
if($phalcon.Version[0] -eq $extension_version) {
Enable-PhpExtension -Extension phalcon -Path $php_dir
printf "\033[%s;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s \033[0m\n" "32" $tick $extension "Enabled"
} else {
Remove-Item $ext_dir\php_phalcon.dll
Install-Phalcon
}
} else {
Install-Phalcon
}

View File

@ -1,22 +1,82 @@
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g") # Function to log result of a operation
find /etc/apt/sources.list.d -type f -name 'ondrej-ubuntu-php*.list' -exec sudo DEBIAN_FRONTEND=noninteractive apt-fast update -o Dir::Etc::sourcelist="{}" ';' >/dev/null 2>&1 add_log() {
curl -s https://packagecloud.io/install/repositories/phalcon/stable/script.deb.sh | sudo bash mark=$1
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$2"-psr subject=$2
message=$3
if [ "$mark" = "$tick" ]; then
printf "\033[32;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
else
printf "\033[31;1m%s \033[0m\033[34;1m%s \033[0m\033[90;1m%s\033[0m\n" "$mark" "$subject" "$message"
fi
}
if [ ! "$(apt-cache search php"$2"-psr)" ]; then # Function to update php ppa
sudo DEBIAN_FRONTEND=noninteractive apt-fast install -y php"$2"-dev update_ppa() {
for tool in php-config phpize; do if [ "$ppa_updated" = "false" ]; then
if [ -e "/usr/bin/$tool$2" ]; then find /etc/apt/sources.list.d -type f -name 'ondrej-ubuntu-php*.list' -exec sudo DEBIAN_FRONTEND=noninteractive apt-get update -o Dir::Etc::sourcelist="{}" ';' >/dev/null 2>&1
sudo update-alternatives --set $tool /usr/bin/"$tool$2" ppa_updated="true"
fi
}
# Function to install phalcon
install_phalcon() {
extension=$1
version=$2
(sudo DEBIAN_FRONTEND=noninteractive apt-get install -y "php$version-$extension" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") ||
(update_ppa && sudo DEBIAN_FRONTEND=noninteractive apt-get install -y "php$version-$extension" >/dev/null 2>&1 && add_log "$tick" "$extension" "Installed and enabled") ||
add_log "$cross" "$extension" "Could not install $extension on PHP $semver"
}
# Function to remove an extensions
remove_extension() {
extension=$1
sudo sed -i "/$extension/d" "$ini_file"
rm -rf "$ext_dir/$extension.so"
}
ini_file=$(php --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
semver=$(php -v | head -n 1 | cut -f 2 -d ' ' | cut -f 1 -d '-')
extension_major_version=$(echo "$1" | grep -i -Po '\d')
ppa_updated="false"
tick="✓"
cross="✗"
if [ "$extension_major_version" = "4" ]; then
if [ -e "$ext_dir/psr.so" ]; then
echo "extension=psr" >>"$ini_file"
fi
if [ -e "$ext_dir/phalcon.so" ]; then
if php -m | grep -i -q -w psr; then
echo "extension=phalcon" >>"$ini_file"
phalcon_version=$(php -r "echo phpversion('phalcon');" | cut -d'.' -f 1)
if [ "$phalcon_version" != "$extension_major_version" ]; then
remove_extension "psr" >/dev/null 2>&1
remove_extension "phalcon" >/dev/null 2>&1
install_phalcon "$1" "$2"
else
add_log "$tick" "$1" "Enabled"
fi
else
install_phalcon "$1" "$2"
fi fi
done else
cd ~ && git clone --depth=1 https://github.com/jbboehr/php-psr.git install_phalcon "$1" "$2"
cd php-psr && sudo /usr/bin/phpize"$2" fi
./configure --with-php-config=/usr/bin/php-config"$2"
make -j2 && sudo make -j2 install
echo "extension=psr.so" >> "$ini_file"
fi fi
extension_major_version=$(echo "$1" | grep -i -Po '\d') if [ "$extension_major_version" = "3" ]; then
extension_version=$(apt-cache policy -- *phalcon | grep -i -Po "$extension_major_version\.\d\.\d.*php$2" | head -n 1) if [ -e "$ext_dir/phalcon.so" ]; then
sudo DEBIAN_FRONTEND=noninteractive apt-fast -o Dpkg::Options::="--force-overwrite" install -y php"$2"-phalcon="$extension_version" echo "extension=phalcon" >>"$ini_file"
phalcon_version=$(php -r "echo phpversion('phalcon');" | cut -d'.' -f 1)
if [ "$phalcon_version" != "$extension_major_version" ]; then
remove_extension "phalcon" >/dev/null 2>&1
install_phalcon "$1" "$2"
else
add_log "$tick" "$1" "Enabled"
fi
else
install_phalcon "$1" "$2"
fi
fi

View File

@ -1,5 +1,22 @@
extension=$1 extension=$1
extension_major=${extension: -1} extension_major=${extension: -1}
php_version=$2 php_version=$2
brew tap shivammathur/homebrew-phalcon ini_file=$(php -d "date.timezone=UTC" --ini | grep "Loaded Configuration" | sed -e "s|.*:s*||" | sed "s/ //g")
brew install phalcon@"$php_version"_"$extension_major" ext_dir=$(php -i | grep "extension_dir => /usr" | sed -e "s|.*=> s*||")
if [ -e "$ext_dir/psr.so" ] && [ -e "$ext_dir/phalcon.so" ]; then
echo "extension=psr" >>"$ini_file"
echo "extension=phalcon" >>"$ini_file"
phalcon_semver=$(php -r "echo phpversion('phalcon');")
phalcon_version=$(echo "$phalcon_semver" | cut -d'.' -f 1)
if [ "$phalcon_version" != "$extension_major" ]; then
sudo sed -i '' "/psr/d" "$ini_file"
sudo sed -i '' "/phalcon/d" "$ini_file"
rm -rf "$ext_dir"/psr.so
rm -rf "$ext_dir"/phalcon.so
brew tap shivammathur/homebrew-phalcon
brew install phalcon@"$php_version"_"$extension_major"
fi
else
brew tap shivammathur/homebrew-phalcon
brew install phalcon@"$php_version"_"$extension_major"
fi

View File

@ -51,6 +51,21 @@ remove_extension() {
sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1 sudo rm -rf "$ext_dir"/"$extension".so >/dev/null 2>&1
} }
# Function to update extension
update_extension() {
extension=$1
latest_version=$2
current_version=$(php -r "echo phpversion('$extension');")
final_version=$(printf "%s\n%s" "$current_version" "$latest_version" | sort | tail -n 1)
if [ "$final_version" != "$current_version" ]; then
version_exists=$(apt-cache policy -- *"$extension" | grep "$final_version")
if [ -z "$version_exists" ]; then
update_ppa
fi
$apt_install php"$version"-"$extension"
fi
}
# Function to setup a remote tool # Function to setup a remote tool
add_tool() { add_tool() {
url=$1 url=$1
@ -65,6 +80,14 @@ add_tool() {
else else
add_log "$cross" "$tool" "Could not setup $tool" add_log "$cross" "$tool" "Could not setup $tool"
fi fi
if [ "$tool" = "composer" ]; then
composer -q global config process-timeout 0
fi
if [ "$tool" = "phive" ]; then
add_extension curl >/dev/null 2>&1
add_extension mbstring >/dev/null 2>&1
add_extension xml >/dev/null 2>&1
fi
} }
add_composer_tool() { add_composer_tool() {
@ -78,6 +101,15 @@ add_composer_tool() {
) || add_log "$cross" "$tool" "Could not setup $tool" ) || add_log "$cross" "$tool" "Could not setup $tool"
} }
# Function to setup phpize and php-config
add_devtools() {
if ! [ -e "/usr/bin/phpize$version" ] || ! [ -e "/usr/bin/php-config$version" ]; then
$apt_install php"$version"-dev php"$version"-xml >/dev/null 2>&1
fi
sudo update-alternatives --set php-config /usr/bin/php-config"$version" >/dev/null 2>&1
sudo update-alternatives --set phpize /usr/bin/phpize"$version" >/dev/null 2>&1
}
# Function to setup the nightly build from master branch # Function to setup the nightly build from master branch
setup_master() { setup_master() {
tar_file=php_"$version"%2Bubuntu"$(lsb_release -r -s)".tar.xz tar_file=php_"$version"%2Bubuntu"$(lsb_release -r -s)".tar.xz
@ -94,9 +126,7 @@ setup_master() {
# Function to setup PECL # Function to setup PECL
add_pecl() { add_pecl() {
update_ppa update_ppa
$apt_install php"$version"-dev php"$version"-xml >/dev/null 2>&1 add_devtools
sudo update-alternatives --set php-config /usr/bin/php-config"$version" >/dev/null 2>&1
sudo update-alternatives --set phpize /usr/bin/phpize"$version" >/dev/null 2>&1
wget https://github.com/pear/pearweb_phars/raw/master/install-pear-nozlib.phar >/dev/null 2>&1 wget https://github.com/pear/pearweb_phars/raw/master/install-pear-nozlib.phar >/dev/null 2>&1
sudo php install-pear-nozlib.phar >/dev/null 2>&1 sudo php install-pear-nozlib.phar >/dev/null 2>&1
sudo rm -rf install-pear-nozlib.phar >/dev/null 2>&1 sudo rm -rf install-pear-nozlib.phar >/dev/null 2>&1

View File

@ -91,6 +91,7 @@ Function Add-Tool() {
) )
if($tool -eq "composer") { if($tool -eq "composer") {
Install-Composer -Scope System -Path $php_dir -PhpPath $php_dir Install-Composer -Scope System -Path $php_dir -PhpPath $php_dir
composer -q global config process-timeout 0
Add-Log $tick $tool "Added" Add-Log $tick $tool "Added"
} else { } else {
if (Test-Path $php_dir\$tool) { if (Test-Path $php_dir\$tool) {
@ -114,6 +115,11 @@ Function Add-Tool() {
Add-Log $cross $tool "Could not add $tool" Add-Log $cross $tool "Could not add $tool"
} }
} }
if($tool -eq "phive") {
Add-Extension curl >$null 2>&1
Add-Extension mbstring >$null 2>&1
Add-Extension xml >$null 2>&1
}
} }
Function Add-Composer-Tool() { Function Add-Composer-Tool() {
@ -155,7 +161,11 @@ $php_dir = 'C:\tools\php'
$ext_dir = $php_dir + '\ext' $ext_dir = $php_dir + '\ext'
$ProgressPreference = 'SilentlyContinue' $ProgressPreference = 'SilentlyContinue'
$master_version = '8.0' $master_version = '8.0'
$arch='x64' $arch = 'x64'
$ts = $false
if((Test-Path env:PHPTS) -and $env:PHPTS -eq 'ts') {
$ts = $true
}
Step-Log "Setup PhpManager" Step-Log "Setup PhpManager"
Install-Module -Name PhpManager -Force -Scope CurrentUser Install-Module -Name PhpManager -Force -Scope CurrentUser
@ -170,7 +180,8 @@ if (Test-Path -LiteralPath $php_dir -PathType Container) {
} }
} }
Step-Log "Setup PHP" Step-Log "Setup PHP"
if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.')))) { $status = "Installed"
if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version -replace '^(\d+(\.\d+)*).*', '$1.'))) -or $ts -ne $installed.ThreadSafe) {
if ($version -lt '7.0') { if ($version -lt '7.0') {
Install-Module -Name VcRedist -Force Install-Module -Name VcRedist -Force
$arch='x86' $arch='x86'
@ -179,10 +190,12 @@ if ($null -eq $installed -or -not("$($installed.Version).".StartsWith(($version
$version = 'master' $version = 'master'
} }
Install-Php -Version $version -Architecture $arch -ThreadSafe $true -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni Production -Force >$null 2>&1 Install-Php -Version $version -Architecture $arch -ThreadSafe $ts -InstallVC -Path $php_dir -TimeZone UTC -InitialPhpIni Production -Force >$null 2>&1
} } else {
else { $updated = Update-Php $php_dir >$null 2>&1
Update-Php $php_dir >$null 2>&1 if($updated -eq $False) {
$status = "Found"
}
} }
$installed = Get-Php -Path $php_dir $installed = Get-Php -Path $php_dir
@ -190,8 +203,12 @@ Set-PhpIniKey -Key 'date.timezone' -Value 'UTC' -Path $php_dir
Enable-PhpExtension -Extension openssl, curl, opcache -Path $php_dir Enable-PhpExtension -Extension openssl, curl, opcache -Path $php_dir
Update-PhpCAInfo -Path $php_dir -Source CurrentUser Update-PhpCAInfo -Path $php_dir -Source CurrentUser
if ($version -eq 'master') { if ($version -eq 'master') {
Copy-Item $dir"\..\src\bin\php_pcov.dll" -Destination $ext_dir"\php_pcov.dll" if($installed.ThreadSafe) {
Copy-Item $dir"\..\src\bin\php_ts_pcov.dll" -Destination $ext_dir"\php_pcov.dll"
} else {
Copy-Item $dir"\..\src\bin\php_pcov.dll" -Destination $ext_dir"\php_pcov.dll"
}
Set-PhpIniKey -Key 'opcache.jit_buffer_size' -Value '256M' -Path $php_dir Set-PhpIniKey -Key 'opcache.jit_buffer_size' -Value '256M' -Path $php_dir
Set-PhpIniKey -Key 'opcache.jit' -Value '1235' -Path $php_dir Set-PhpIniKey -Key 'opcache.jit' -Value '1235' -Path $php_dir
} }
Add-Log $tick "PHP" "Installed PHP $($installed.FullVersion)" Add-Log $tick "PHP" "$status PHP $($installed.FullVersion)"

View File

@ -180,6 +180,36 @@ export async function getCodeceptionUri(
} }
} }
/**
* Helper function to get script to setup phive
*
* @param tool
* @param version
* @param url
* @param os_version
*/
export async function addPhive(
version: string,
os_version: string
): Promise<string> {
switch (version) {
case 'latest':
return (
(await getArchiveCommand(os_version)) +
'https://phar.io/releases/phive.phar phive'
);
default:
return (
(await getArchiveCommand(os_version)) +
'https://github.com/phar-io/phive/releases/download/' +
version +
'/phive-' +
version +
'.phar phive'
);
}
}
/** /**
* Function to get the PHPUnit url * Function to get the PHPUnit url
* *
@ -269,6 +299,41 @@ export async function addArchive(
return (await getArchiveCommand(os_version)) + url + ' ' + tool; return (await getArchiveCommand(os_version)) + url + ' ' + tool;
} }
/**
* Function to get the script to setup php-config and phpize
*
* @param tool
* @param os_version
*/
export async function addDevTools(
tool: string,
os_version: string
): Promise<string> {
switch (os_version) {
case 'linux':
return (
'add_devtools' +
'\n' +
(await utils.addLog('$tick', tool, 'Added', 'linux'))
);
case 'darwin':
return await utils.addLog('$tick', tool, 'Added', 'darwin');
case 'win32':
return await utils.addLog(
'$cross',
tool,
tool + ' is not a windows tool',
'win32'
);
default:
return await utils.log(
'Platform ' + os_version + ' is not supported',
os_version,
'error'
);
}
}
/** /**
* Helper function to get script to setup a tool using composer * Helper function to get script to setup a tool using composer
* *
@ -319,6 +384,9 @@ export async function addTools(
url = github + 'squizlabs/PHP_CodeSniffer/' + uri; url = github + 'squizlabs/PHP_CodeSniffer/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, version, url, os_version);
break; break;
case 'phive':
script += await addPhive(version, os_version);
break;
case 'phpstan': case 'phpstan':
url = github + 'phpstan/phpstan/' + uri; url = github + 'phpstan/phpstan/' + uri;
script += await addArchive(tool, version, url, os_version); script += await addArchive(tool, version, url, os_version);
@ -368,6 +436,10 @@ export async function addTools(
case 'pecl': case 'pecl':
script += await getPECLCommand(os_version); script += await getPECLCommand(os_version);
break; break;
case 'php-config':
case 'phpize':
script += await addDevTools(tool, os_version);
break;
default: default:
script += await utils.addLog( script += await utils.addLog(
'$cross', '$cross',